我不断收到如下错误:
名称错误:未定义名称“by”
为了代码
chrome_driver_path = r"C:\chromedriver.exe"
from selenium import webdriver
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
browser = webdriver.Chrome(chrome_driver_path)
browser.delete_all_cookies()
browser.get("https://www.google.com/")
wait = WebDriverWait(browser, 10)
element = wait.until(EC.element_to_be_clickable((By.XPATH, '//*[@id="tsf"]/div[2]/div[3]/center/input[1]')))
我的输入正确吗?
最佳答案
你必须导入它
from selenium.webdriver.common.by import By
关于python - Python Selenium Webdriver(名称“by”未定义),我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/44629970/