我一直收到如下错误:
NameError:name' 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]')))
我的导入是否正确?
答案 0 :(得分:11)
你必须导入它
*, *::before, *::after {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.reply_placeholder {
padding: 30px 30px 20px 65px; /* changed padding-left from 30 to 65px */
position: absolute;
bottom: 0;
width: 100%;
overflow: hidden;
border-top: 1px solid #DDD;
}
.logo {
position: absolute; /* new */
top: 50%; /* new */
left: 0; /* new */
margin-top: -20px; /* new */
background-image: url("http://placekitten.com/g/200/200");
width: 50px;
height: 50px;
border-radius: 3px;
border: 1px solid #dddddd;
background-size: cover;
background-position: center center;
display: block; /* inline-block to block */
margin-right: 10px;
}
.reply_placeholder input {
display: block;
width: 100%;
height: 50px;
float: right;
}
答案 1 :(得分:1)
您可以使用
导入By
selenium.webdriver.common.by import By