-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(expectedConditions): add helper library for syncing with non-angula... #1703
Conversation
usage: var EC = protractor.ExpectedConditions;
var button = $('#xyz');
var isClickable = EC.elementToBeClickable(button);
browser.get(URL);
browser.wait(isClickable, 5000); //wait for an element to become clickable
button.click(); You can also customize the conditions: var urlChanged = function() {
return browser.getCurrentUrl().then(function(url) {
return url != 'http://www.angularjs.org';
});
};
// condition to wait for url to change, title to contain 'foo', and $('abc') element to contain text 'bar'
var condition = EC.and(urlChanged, EC.titleContains('foo'), EC.textToBePresentInElement($('abc'), 'bar'));
$('navButton').click();
browser.wait(condition, 5000); //wait for condition to be true.
// do other things |
67f2422
to
77ec49e
Compare
Can you add the usage notes to the commit message? |
|
||
it('should have alertIsPresent', function() { | ||
var alertIsPresent = EC.alertIsPresent(); | ||
expect(alertIsPresent.call()).toBe(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might be being dense, but why not:
expect(alertIsPresent()).toBe(false);
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea that works too. It's just that in cases where I didn't use an extra variable expect(EC.alertIsPresent().call())
looked a little more pleasing than expect(EC.alertIsPresent()())
, but functionally they're the same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternatively, EC.func
can return a promise instead of a function that returns a promise. The down side is that then wait conditions (which I think will be the primary use case will look like browser.wait(function(){return EC.elementToBeClickable(el)}, 100)
instead of browser.wait(EC.elementToBeClickable(el), 100)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that we should optimize for being used in browser.wait
.
I'm fine with either call()
or just ()
, so you can leave as is.
…ular apps usage: ```javascript var EC = protractor.ExpectedConditions; var button = $('#xyz'); var isClickable = EC.elementToBeClickable(button); browser.get(URL); browser.wait(isClickable, 5000); //wait for an element to become clickable button.click(); ``` You can also customize the conditions: ```javascript var urlChanged = function() { return browser.getCurrentUrl().then(function(url) { return url != 'http://www.angularjs.org'; }); }; // condition to wait for url to change, title to contain 'foo', and $('abc') element to contain text 'bar' var condition = EC.and(urlChanged, EC.titleContains('foo'), EC.textToBePresentInElement($('abc'), 'bar')); $('navButton').click(); browser.wait(condition, 5000); //wait for condition to be true. // do other things ```
Added usage examples |
LGTM! |
committed at 9bc1c53 |
How do we test for non clickable with this? |
...r apps