【发布时间】:2019-11-06 15:10:14
【问题描述】:
这是我的 Python 代码
from selenium import webdriver
import time
driver = webdriver.Chrome('/usr/local/bin/chromedriver')
driver.get("https://www.immoweb.be")
elem1 = driver.find_element_by_link_text('FRANCAIS')
elem1.click()
elem2 = driver.find_element_by_link_text('Maisons')
elem2.click()
time.sleep(2)
#searchBar = driver.find_element_by_xpath('//*[@id="localisation"]')
searchBar = driver.find_element_by_name('localisation')
searchbar.send_keys('hello')
我想在“本地化”字段中添加文本,但收到以下错误消息。
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":"[name="localisation"]"}
我在其他网站上尝试了完全相同的代码,它运行正常。
【问题讨论】:
标签: python-3.x selenium-webdriver iframe css-selectors webdriverwait