硒元素不可相互作用 [英] selenium element not interactable
问题描述
我开始使用selenuim,节点js
i started using selenuim, node js
到目前为止一切正常,突然之间,同一脚本抛出了错误
it was working all perfect so far, sudenly the same script is throwing and error
未处理的承诺拒绝警告元素不可交互"
"unhandled promise rejection warning element not interactable"
我尝试设置等待,直到什么都没有
i tried setting wait, until and nothing
<script>
const {Builder, By, Key, until, wait } = require('selenium-webdriver');
var driver = new Builder()
.forBrowser('chrome')
.build();
driver.manage().window().maximize()
driver.get('http://www.google.com/testsite')
driver.findElement(By.id('username')).sendKeys('test@emal');
driver.findElement(By.id('password')).sendKeys('passowrod');
driver.findElement(By.className('acceder')).click();
driver.quit();
</script>
我到处搜索,但是所有示例都对我没有用,因为它们没有问题,..
i search all over but all examples simply did not work for me, due that they dont have that issues,..
https://www.youtube.com/watch ?v = C6qQojzN7bE& index = 4& list = PLA4JPGpQHctT__mDO9EHvOrWVW0Hkf5Mk
推荐答案
这些定位符为我提供了您共享的网址:
These locators worked for me for the url you shared:
driver.findElement(By.xpath('(//input[@id="username"])[2]')).sendKeys('test@emal');
driver.findElement(By.xpath('(//input[@id="password"])[2]')).sendKeys('passowrod');
driver.findElement(By.xpath('(//button[@class="boton acceder"])[2]')).click();
对所有元素使用第二索引的原因是,HEADER中隐藏了相同的元素.
The reason for using 2nd index for all the elements is that the same elements are in HEADER which are hidden.
注意:我在python中尝试过这些方法,因此请调整是否存在任何字符串语法错误.
Note: I tried these in python, so please adjust if any string syntax error.
这篇关于硒元素不可相互作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!