This repository has been archived by the owner on Jul 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First commit, so it's not stuck on my laptop
- Loading branch information
0 parents
commit 0595652
Showing
4 changed files
with
94 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
angular-seed/ |
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
var webdriver = require('/Users/ralphj/selenium/selenium-read-only/build/javascript/node/webdriver'); | ||
var assert = require('assert'); | ||
var util = require('util') | ||
|
||
var waitForAngular = function() { | ||
util.puts('Starting waitForAngular'); | ||
driver.executeAsyncScript(function() { | ||
var callback = arguments[arguments.length - 1]; | ||
angular.element(document.body).injector().get('$browser').notifyWhenNoOutstandingRequests(callback); | ||
}); | ||
util.puts('Ending waitForAngular'); | ||
}; | ||
|
||
|
||
var driver = new webdriver.Builder(). | ||
usingServer('http://localhost:4444/wd/hub'). | ||
withCapabilities({ | ||
'browserName': 'chrome', | ||
'version': '', | ||
'platform': 'ANY', | ||
'javascriptEnabled': true | ||
}). | ||
build(); | ||
|
||
driver.manage().timeouts().setScriptTimeout(10000); | ||
|
||
// driver.get('http://docs.angularjs.org/api/ng.$http'); | ||
|
||
driver.get('http://localhost:8000/app/index.html'); | ||
driver.sleep(2); | ||
|
||
var sample1Button = driver.findElement(webdriver.By.id('sample1')); | ||
var sample2Button = driver.findElement(webdriver.By.id('sample2')); | ||
sample1Button.click(); | ||
|
||
var fetchButton = driver.findElement(webdriver.By.id('fetch')); | ||
fetchButton.click(); | ||
|
||
// The quick RPC works fine. | ||
driver.findElement(webdriver.By.id('statuscode')).getText().then(function(text) { | ||
assert.equal('200', text); | ||
}); | ||
driver.findElement(webdriver.By.id('data')).getText().then(function(text) { | ||
assert.equal('diablo', text); | ||
}); | ||
|
||
// The slow one fails: | ||
sample2Button.click(); | ||
fetchButton.click(); | ||
// Would normally need driver.sleep(2) or something. | ||
waitForAngular(); | ||
driver.findElement(webdriver.By.id('statuscode')).getText().then(function(text) { | ||
assert.equal('200', text); | ||
}); | ||
waitForAngular(); | ||
driver.findElement(webdriver.By.id('data')).getText().then(function(text) { | ||
assert.equal('hello now', text); | ||
}); | ||
|
||
|
||
driver.quit(); | ||
|
||
// Original Angular scenario runner code | ||
/* | ||
describe("api/ng.$http", function() { | ||
beforeEach(function() { | ||
browser().navigateTo("index-nocache.html#!/api/ng.$http"); | ||
}); | ||
it('should make an xhr GET request', function() { | ||
element(':button:contains("Sample GET")').click(); | ||
element(':button:contains("fetch")').click(); | ||
expect(binding('status')).toBe('200'); | ||
expect(binding('data')).toMatch(/Hello, \$http!/); | ||
}); | ||
it('should make a JSONP request to angularjs.org', function() { | ||
element(':button:contains("Sample JSONP")').click(); | ||
element(':button:contains("fetch")').click(); | ||
expect(binding('status')).toBe('200'); | ||
expect(binding('data')).toMatch(/Super Hero!/); | ||
}); | ||
it('should make JSONP request to invalid URL and invoke the error handler', | ||
function() { | ||
element(':button:contains("Invalid JSONP")').click(); | ||
element(':button:contains("fetch")').click(); | ||
expect(binding('status')).toBe('0'); | ||
expect(binding('data')).toBe('Request failed'); | ||
}); | ||
}); | ||
*/ |