Skip to content
This repository was archived by the owner on Jul 29, 2024. It is now read-only.

ExpectedConditions or method does not seem to short circuit a true condition #2052

Closed
gkohen opened this issue Apr 15, 2015 · 2 comments
Closed

Comments

@gkohen
Copy link
Contributor

gkohen commented Apr 15, 2015

@juliemr, I'm running the latest 2.0 with the fix for #1907 and #1903 mentioned by @hankduan. I have the following piece of logic to make sure an element is not visible or does not exist:

var cssSelector = '.my-class';
browser.wait(ExpectedConditions.or(
                  ExpectedConditions.stalenessOf($(cssSelector)),
                  ExpectedConditions.invisibilityOf($(cssSelector))),
      5000);

I intermittently get a NoSuchElementError: No element found using locator: By.cssSelector('.my-class')
It seems like the or is not short circuiting if the first condition is true since the first condition should check if the elements are even there. Is the promised of each condition being resolved before moving on to the same condition? Am I missing how multi condition should be used?

@hankduan
Copy link
Contributor

hankduan commented May 4, 2015

As mentioned in the referencing issue, can you provide a reproducible case? I just made a sample test, but cannot reproduce this.

spec:

  var EC = protractor.ExpectedConditions;
  it('should get each', function() {
    browser.get('http://localhost:8081');
    var disappearingContent = $('#content');
    var toggleButton = $('#toggleButton');
    expect(disappearingContent.isPresent()).toBeTruthy();
    toggleButton.click(); // disappears after 1 second.
    browser.wait(EC.or(
                EC.stalenessOf(disappearingContent),
                EC.invisibilityOf(disappearingContent)),
                5000);
    expect(disappearingContent.isPresent()).toBeFalsy();
  });

app:

<div>
  <label>Toggle content after 1 seconds: 
    <input type="checkbox" id="toggleButton" ng-model="shouldAppear" ng-init="shouldAppear=true" />
  </label>
  <br/>
  <div ng-if="shouldAppear" id="content" class="fade">
    This is removed on click.
  </div>
</div>

<style>
  .fade.ng-enter {
    transition:1s linear all;
    opacity:0;
  }
  .fade.ng-enter.ng-enter-active {
    opacity:1;
  }
  .fade.ng-leave {
    transition:1s linear all;
    opacity:1;
  }
  .fade.ng-leave.ng-leave-active {
    opacity:0;
  }
</style>

@juliemr
Copy link
Member

juliemr commented Jun 29, 2015

Closing as stale.

@juliemr juliemr closed this as completed Jun 29, 2015
@hankduan hankduan removed their assignment Nov 4, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants