Error:org.openqa.selenium.ElementNotVisibleExcepti

2019-09-07 03:39发布

I am getting this error:

org.openqa.selenium.ElementNotVisibleException: You may only interact with visible elements

when I use HtmlUnitDriver. It works for URL, after that when I start with

driver.findElement(By.cssSelector("#from_city_typeahead")).sendKeys("bangalore"); 

such statements, it gives the above error. Help me to solve this issue.

1条回答
男人必须洒脱
2楼-- · 2019-09-07 04:19

You can do the same action with javascript:

webdriver.executeScript("document.getElementById('elementID').setAttribute('value', 'new value for element')");

Visibility does matter in case of standard visible browsers. But it's doesnt matter for javascript in case of any of browsers.

查看更多
登录 后发表回答