【发布时间】:2016-03-21 13:43:06
【问题描述】:
我正在尝试让带有 Selenium WebDriver 的 Firefox 在此 Boerse Frankfurt webpage 的搜索字段中输入搜索查询。
我可以通过find_element_by_name 或find_element_by_xpath 成功定位web 元素,得到<selenium.webdriver.remote.webelement.WebElement object at 0x10768e490>。
但是,当尝试清除字段、发送密钥或以其他方式单击它时,我收到错误消息:
ElementNotVisibleException:消息:元素当前不可见 因此可能无法与之交互
我以前在使用 Selenium 时不熟悉这个错误,所以我不知道我的代码可能有什么问题:
driver.get("http://en.boerse-frankfurt.de/")
search_string = "test"
search_box = driver.find_element_by_xpath(".//*[@id='searchvalue']")
search_box.send_keys(search_string)
search_box.send_keys(Keys.RETURN)
编辑:这里的问题实际上是驱动程序窗口没有最大化到全屏。请参阅下面的答案/cmets。
【问题讨论】:
标签: python selenium selenium-webdriver