selenium element not interactable

你离开我真会死。 提交于 2020-06-01 08:05:38

问题


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


回答1:


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();

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.




回答2:


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();


来源:https://stackoverflow.com/questions/54870871/selenium-element-not-interactable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!