找不到具有Selenium的JavaScript呈现元素

2024-09-25 00:32:18 发布

您现在位置:Python中文网/ 问答频道 /正文

我是硒的初学者。我想在搜索框中键入地址。但我找不到这个领域。字段HTML代码:

<input type="text" class="SearchField_SearchField__hDobT" placeholder="Address..." value="">

我正在尝试这样做:

element = driver.find_element_by_xpath("//input[@class='SearchField_SearchField__hDobT']")

element=driver.find_element_by_class_name("SearchField_SearchField__hDobT")

我得到了一个错误:

selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//input[@class='SearchField_SearchField__hDobT']"}
  (Session info: chrome=80.0.3987.132) 

selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":".SearchField_SearchField__hDobT"}
  (Session info: chrome=80.0.3987.132).

我也无法访问其他字段。我用JavaScript呈现HTML内容

我不知道是什么问题。请帮忙


Tags: inputbyhtmldriverseleniumelementcommonfind