Skip to content

Commit

Permalink
[js] Minor style fixes and updating changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
jleyba committed May 21, 2016
1 parent 1eb3d09 commit bdabcc0
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 15 deletions.
2 changes: 2 additions & 0 deletions javascript/node/selenium-webdriver/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

* Allow users to set the agent used for HTTP connections through
`builder.Builder#usingHttpAgent()`
* Added new wait conditions: `until.urlIs()`, `until.urlContains()`,
`until.urlMatches()`

## v2.53.2

Expand Down
24 changes: 13 additions & 11 deletions javascript/node/selenium-webdriver/lib/until.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,34 +183,36 @@ exports.titleMatches = function titleMatches(regex) {
* @param {string} url The expected page url.
* @return {!Condition<boolean>} The new condition.
*/
exports.urlIs = function urlIs(url){
exports.urlIs = function urlIs(url) {
return new Condition(
'for url to be ' + JSON.stringify(url),
function(driver) {
return driver.getCurrentUrl().then(function(u) {
return u === url;
'for URL to be ' + JSON.stringify(url),
function(driver) {
return driver.getCurrentUrl().then(function(u) {
return u === url;
});
});
});
};


/**
* Creates a condition that will wait for the current page's url to contain
* the given substring.
*
* @param {string} substrUrl The substring that should be present in the page
* title.
* @param {string} substrUrl The substring that should be present in the current
* URL.
* @return {!Condition<boolean>} The new condition.
*/
exports.urlContains = function urlContains(substrUrl) {
return new Condition(
'for url to contain ' + JSON.stringify(substrUrl),
'for URL to contain ' + JSON.stringify(substrUrl),
function(driver) {
return driver.getCurrentUrl().then(function(url) {
return url.indexOf(substrUrl) !== -1;
});
});
});
};


/**
* Creates a condition that will wait for the current page's url to match the
* given regular expression.
Expand All @@ -219,7 +221,7 @@ exports.urlContains = function urlContains(substrUrl) {
* @return {!Condition<boolean>} The new condition.
*/
exports.urlMatches = function urlMatches(regex) {
return new Condition('for url to match ' + regex, function(driver) {
return new Condition('for URL to match ' + regex, function(driver) {
return driver.getCurrentUrl().then(function(url) {
return regex.test(url);
});
Expand Down
9 changes: 5 additions & 4 deletions javascript/node/selenium-webdriver/test/lib/until_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ describe('until', function() {
assert.deepStrictEqual(titles, ['google']);
});
});

it('testUntilUrlIs', function() {
var urls = ['http://www.foo.com', 'https://boo.com', 'http://docs.yes.com'];
executor.on(CommandName.GET_CURRENT_URL, () => urls.shift());
Expand All @@ -183,16 +183,17 @@ describe('until', function() {
assert.deepStrictEqual(urls, ['http://docs.yes.com']);
});
});

it('testUntilUrlContains', function() {
var urls = ['http://foo.com', 'https://groups.froogle.com', 'http://google.com'];
var urls =
['http://foo.com', 'https://groups.froogle.com', 'http://google.com'];
executor.on(CommandName.GET_CURRENT_URL, () => urls.shift());

return driver.wait(until.urlContains('oogle.com'), 3000).then(function() {
assert.deepStrictEqual(urls, ['http://google.com']);
});
});

it('testUntilUrlMatches', function() {
var urls = ['foo', 'froogle', 'aaaabc', 'aabbbc', 'google'];
executor.on(CommandName.GET_CURRENT_URL, () => urls.shift());
Expand Down

0 comments on commit bdabcc0

Please sign in to comment.