Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/414.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 量角器在忽略同步期间等待,浏览器隐式超时vs.browser.wait超时_Javascript_Selenium_Selenium Webdriver_Webdriver_Protractor - Fatal编程技术网

Javascript 量角器在忽略同步期间等待,浏览器隐式超时vs.browser.wait超时

Javascript 量角器在忽略同步期间等待,浏览器隐式超时vs.browser.wait超时,javascript,selenium,selenium-webdriver,webdriver,protractor,Javascript,Selenium,Selenium Webdriver,Webdriver,Protractor,我有一个应用程序,在单击按钮时启动$timeout,因此我必须将ignoreSynchronization设置为true。在这段时间内,我需要等待元素添加到页面中,在等待过程中我遇到了一些有趣的行为: 浏览器运行期间传入的等待超时。等待(元素、超时、错误消息)不执行任何操作。唯一重要的等待是浏览器上的implicitTimeout设置。除此之外,将使用整个隐式超时。如果发现元素存在,它将继续检查,直到超时结束。这意味着在给定的最长时间内,测试将始终缓慢运行 describe('Cool Page

我有一个应用程序,在单击按钮时启动$timeout,因此我必须将ignoreSynchronization设置为true。在这段时间内,我需要等待元素添加到页面中,在等待过程中我遇到了一些有趣的行为:

浏览器运行期间传入的等待超时。等待(元素、超时、错误消息)不执行任何操作。唯一重要的等待是浏览器上的implicitTimeout设置。除此之外,将使用整个隐式超时。如果发现元素存在,它将继续检查,直到超时结束。这意味着在给定的最长时间内,测试将始终缓慢运行

describe('Cool Page', () =>{
  beforeEach(function(){
    browser.ignoreSynchronization = true;
    return browser.sleep(250);
  });

  afterEach(function(){
    browser.ignoreSynchronization = false;
    return browser.sleep(250);
  });

  it('can open menu with timeout', function(){
    // No timeout at this point
    coolPage.wait.ellipsesIcons().then(() =>{
       // Clicking the ellipses icons kicks off a $timeout of 100 seconds
       coolPage.ellipsesIcons.click().then(() =>{
          coolPage.wait.dropdownOptions().then(() => {
             expect(coolPage.dropdownOptions.getText()).toContain('Option 1');
          });
       });
    });
  });
})

通过browser.wait传入的超时在此处无效。我的问题是:

  • browser.wait超时的作用是什么
  • 何时使用隐式等待?我以为它只是在等待页面加载
  • 是否有任何方法可以传递实际使用的超时
  • 如果没有,是否有办法在满足条件后立即退出等待,而不是使用整个超时
尝试使用浏览器等待。查看使用函数
texttobepresentelement
的示例。要检查元素是否存在,我可以尝试
visibilityOf
presenceOf

  export = new CoolPage;
  class CoolPageextends PageObject {
    private elements;

    constructor(){
        super();
        ... // Lots of other stuff
        this.initWait();
    }

    ... // Initializing elements and other things

    private initWait() {
      this.wait = {
        ellipsesIcons: () => {
          // Timeout of 5 seconds will be used - regardless of isPresent resolving as true or false, the entire 5 seconds will be used
          browser.manage().timeouts().implicitlyWait(5000);
          // The 2 milliseconds passed in here does nothing at all
          browser.wait(element(by.css('.fa-ellipses-h')).isPresent(), 2, 'Ellipses Icon(...) was not present in time');
          // Must reset implicit wait back to the original 25 seconds it was set too in the conf
          browser.manage().timeouts().implicitlyWait(25000);
          return browser.sleep(150);
        },
        dropdownOptions: () => {
          // This two seconds wait WILL be used
          browser.manage().timeouts().implicitlyWait(2000);
          // This five second wait WILL NOT be used
          browser.wait(element(by.css('[name="change-status"]')).isPresent(), 5000, 'Options actions menu item was not present in time');
          browser.manage().timeouts().implicitlyWait(25000);
          return browser.sleep(150);
        },
      }
    }