错误:org.openqa.selenium.ElementNotVisibleException:您只能使用htmlunitdriver与可见元素进行交互吗? [英] Error:org.openqa.selenium.ElementNotVisibleException: You may only interact with visible elements using htmlunitdriver?

查看:126
本文介绍了错误:org.openqa.selenium.ElementNotVisibleException:您只能使用htmlunitdriver与可见元素进行交互吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到此错误:

org.openqa.selenium.ElementNotVisibleException:您只能与可见元素进行交互

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

当我使用HtmlUnitDriver时.它适用于URL,之后我以

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.

推荐答案

您可以使用javascript执行相同的操作:

You can do the same action with javascript:

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

对于标准的可见浏览器,可见性确实很重要.但这对于使用任何浏览器的javascript都没有关系.

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

这篇关于错误:org.openqa.selenium.ElementNotVisibleException:您只能使用htmlunitdriver与可见元素进行交互吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆