问题
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:
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.
来源:https://stackoverflow.com/questions/32858986/errororg-openqa-selenium-elementnotvisibleexception-you-may-only-interact-with