我是 Selenium 新手,我正在 Browserstack 上运行我的 selenium 脚本。
一切正常,直到我到达页面底部 10%。
我收到以下错误:
Uncaught WebDriverError: Appium error: unknown error: Element is not clickable at point (20, 324). Other element would receive the click: ... (Session info: chrome=58.0.3029.83) (Driver info: chromedriver=2.29.461571 (8a88bbe0775e2a23afda0ceaf2ef7ee74e822cc5),platform=Linux 3.19.8-100.fc20.x86_64 x86_64)
这是我的代码:
describe.only(testTitle, function () {
before(function () {
driver = driverConfiguration.getDriverConfiguration(testTitle, 'chrome')
})
after(function (done) {
driver.quit().then(done)
})
it('Sample tests', function (done) {
driver.get('https://www.test.com').then(function(){
driver.findElement(webdriver.By.name('cardNumber')).sendKeys('0000000000').then(function(){
driver.findElement(webdriver.By.id('billingLine1')).sendKeys('test');
driver.findElement(webdriver.By.id('billingLine2')).sendKeys('test');
driver.findElement(webdriver.By.id('billingCity')).sendKeys('San Jose');
driver.findElement(webdriver.By.id('agree')).click(); // ERROR!!!!!
}).then(function() {
driver.quit().then(done);
})
});
})
})
当我执行以下操作时:
// return driver.wait(function() {
// return driver.findElement(webdriver.By.id('agree')).isDisplayed();
// }, 1000);
它说的是真的。该元素可见。
在 Samsung Galaxy S8 上使用 Chrome
我不知道如何解决这个问题。
最佳答案
您忽略了问题中错误消息中最重要的部分
Other element would receive the click: ...
...
部分中的元素是阻止点击的元素。正如您所发现的,Selenium 报告该元素已显示/可见。此错误消息只是说明当 Selenium 尝试单击该元素时,另一个元素阻止了单击。如果您查看阻止元素的 HTML 并在页面的 HTML 中搜索它,您应该能够识别该元素。根据我的经验,它是一个对话框,或者可能是页面底部的横幅等。有时您需要关闭它,有时您需要向下/向上滚动一点才能从阻塞 UI 后面获取所需的元素.
关于javascript - Selenium 元素在 javascript 中的点(chrome)处不可点击,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49520633/