无法使用以下方法单击元素:browser.click和xpath:// input [2]

时间:2018-08-31 14:33:02

标签: javascript node.js selenium-webdriver webdriver-io

似乎收到以下异常:

element not visible
running chrome
Error: An element command could not be completed because the element is not visible on the page.
    at elementIdClick("0.12980231457632274-1") - click.js:20:22

我对我们进行如下测试:

    beforeEach(function() {
      browser.url("https://www.google.com");
    })
    describe('Test Google Homepage', function() {
        it('Should be able to click on im feeling lucky button', function(done) {
          browser.click('(//input)[7]');
    });
});

即使添加浏览器暂停时,似乎xpath也会在上面抛出异常,为什么我会收到异常?

2 个答案:

答案 0 :(得分:1)

因为您不应该使用xpath?

尝试: browser('[aria-label="I\'m Feeling Lucky"]').click()

使用命名事物比依靠页面中事物的顺序更好。

答案 1 :(得分:0)

您可以共享在哪个浏览器上尝试使用的+版本以及正在使用的所有npmModules版本。尝试同时获取browserDriver版本。

PS:我想将此添加为评论,但我没有50点声望。