Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

hankduan
Copy link
Contributor

@hankduan hankduan commented Jan 9, 2015

...r apps

@hankduan
Copy link
Contributor Author

hankduan commented Jan 9, 2015

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

@juliemr
Copy link
Member

juliemr commented Jan 15, 2015

Can you add the usage notes to the commit message?


it('should have alertIsPresent', function() {
var alertIsPresent = EC.alertIsPresent();
expect(alertIsPresent.call()).toBe(false);
Copy link
Member

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);?

Copy link
Contributor Author

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.

Copy link
Contributor Author

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)

Copy link
Member

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
```
@hankduan
Copy link
Contributor Author

Added usage examples

@juliemr
Copy link
Member

juliemr commented Jan 20, 2015

LGTM!

@hankduan
Copy link
Contributor Author

committed at 9bc1c53

@hankduan hankduan closed this Jan 20, 2015
@JemiloII
Copy link

JemiloII commented Sep 6, 2016

How do we test for non clickable with this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants