【发布时间】:2020-08-01 23:25:50
【问题描述】:
我正在检查 Firefox 中的 youtube 搜索栏并得到:
<input id="search" autocapitalize="none" autocomplete="off" autocorrect="off" name="search_query" tabindex="0" type="text" spellcheck="false" placeholder="Search" aria-label="Search" aria-haspopup="false" role="combobox" aria-autocomplete="list" dir="ltr" style="outline: currentcolor none medium;" class="ytd-searchbox">
我有以下代码:
driver = webdriver.Firefox()
driver.get("http://www.youtube.com")
elem = driver.find_element_by_id("search")
elem.send_keys("asdfasdf")
elem.send_keys(Keys.RETURN)
并得到以下错误(使用 firefox gecko webdriver):
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.ElementNotInteractableException: Message: Element <g id="search"> is not reachable by keyboard
为什么?当我检查源代码时,没有 id="search" 的 g 元素,这是怎么回事?
【问题讨论】:
标签: python selenium web web-scraping