【问题标题】:Test Env Protractor: element is not clickable at point (x, x) other element would receive the click测试环境量角器:元素在点 (x, x) 处不可点击,其他元素将收到点击
【发布时间】:2020-02-27 22:49:58
【问题描述】:

大家好,我在与 e2e 脚本中的表格交互时遇到了一些问题。 element(by.css('#topic_0')).click(); 当我在我的开发环境中时,我可以很好地与之交互,但是当我切换到我的测试环境时与它交互时,我得到了这个错误。 Failed: element click intercepted element id="topic_0" is not clickable at point (x,x). other element would receive the click id="topics_table" 这就是我登录测试环境的方式

 browser.waitForAngularEnabled(false);
    browser.get(browser.baseUrl);
    browser.sleep(10000);
    browser.findElement(by.id('userID')).sendKeys(browser.params.login.user);
    browser.findElement(by.id('password')).sendKeys(browser.params.login.password);
    browser.findElement(by.name('submitButton')).click();
    browser.waitForAngularEnabled(true);

【问题讨论】:

    标签: angular protractor e2e-testing test-environments


    【解决方案1】:

    错误Failed: element click intercepted element id="topic_0" is not clickable at point (x,x). other element would receive the click id="topics_table" 通常发生在量角器无法找到目标元素时(在您的情况下,您的目标是具有#topic_0 css 的元素;来自上面的代码element(by.css('#topic_0')))...

    当您不处理承诺时,量角器通常无法定位元素。我假设您尝试单击的元素在 DOM 上尚不可用,而量角器正在单击另一个元素......这个问题与环境无关。也许在您的情况下,测试环境只是比开发环境慢,这就是为什么它在开发环境中工作,而不是在测试环境中。

    我会说使用expectedConditions 之一,即visibilityOf 预期条件,以便您的代码最终等待元素显示在 DOM 上......所以您的代码将如下所示:

    var EC = protractor.ExpectedConditions;
    // Waits for the element with id 'topic_0' to be visible on the dom.
    browser.wait(EC.visibilityOf($('#topic_0')), 5000);
    element(by.css('#topic_0')).click();
    

    注意when using CSS Selectors as a locator, you can use the shortcut $() notation:

    $('my-css');
    // Is the same as:
    element(by.css('my-css'));
    

    【讨论】:

      猜你喜欢
      • 2017-11-27
      相关资源
      最近更新 更多