admin管理员组文章数量:1410697
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('')
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,..
;index=4&list=PLA4JPGpQHctT__mDO9EHvOrWVW0Hkf5Mk
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./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./watch?v=C6qQojzN7bE&index=4&list=PLA4JPGpQHctT__mDO9EHvOrWVW0Hkf5Mk
Share Improve this question asked Feb 25, 2019 at 16:40 walter alexanderwalter alexander 1793 silver badges21 bronze badges 6- Is that your working example? The URL provided (google./testsite) generates a 404. – Joao Pereira Commented Feb 25, 2019 at 16:48
- Would you please check the element with classname "acceder" exist before you click?? Or would you post your HTML here? – Robin Ding Commented Feb 25, 2019 at 16:49
- driver.get('exclusivetravelerclub./en/…); ............ that is the currect url, this lies on that it doesnt event do anything after the page is loaded – walter alexander Commented Feb 25, 2019 at 16:54
-
From my understanding, you're trying to access the element whose class name is
boton acceder
. However, there are multiple elements with that class name, and therefore you will need to use thexpath()
method. Try replacingBy.className('acceder'))
withBy.xpath("(//button[@class='boton acceder'])[1]")
. I cannot predict which index will do the trick, you'll have to try it yourself. – Joao Pereira Commented Feb 25, 2019 at 17:24 -
1
Been over this for a few hours, and managed to get the username field filled but it would get stuck in the password step. It's odd because by calling the
getText()
function, an empty string is returned, even if the object exists. By the way, the consideration I made about multiple objects with the same class name, also exists with the ID, since 2 elements share both theusername
andpassword
IDs. – Joao Pereira Commented Feb 25, 2019 at 20:50
2 Answers
Reset to default 2These 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();
The reason for using 2nd index for all the elements is that the same elements are in HEADER which are hidden.
Note: I tried these in python, so please adjust if any string syntax error.
The problem: While running the automation, the window size is is not fully presented on screen so some elements are rendered outside of the visible area in your configured chrome web driver.
The solution would be using this snippet in your base configuration:
browser.driver.manage().window().maximize();
本文标签: javascriptselenium element not interactableStack Overflow
版权声明:本文标题:javascript - selenium element not interactable - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745042032a2639135.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论