不和谐元素点击
我试图点击不和谐登录页面上的按钮,我试过找到类,但是类是随机的,我相信每个会话,我试过找到ID,但它没有ID。
我的目标是插入文本(我已经这样做了),然后单击"登录"。按钮
import selenium
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
driver = webdriver.Chrome(r"C:/Users/sexyv/Downloads/chromedriver_win32/chromedriver.exe")
driver.get("https://discord.com/login")
email_box = driver.find_element(by=By.NAME, value="email")
password_box = driver.find_element(by=By.NAME, value="password")
submit_button = driver.find_element(by=By.ID, value="login-button")
def login(driver, email_box, password_box):
driver.implicitly_wait(3)
driver.implicitly_wait(5)
email_box.send_keys("johnsonkalel15@gmail.com")
password_box.send_keys("Kalel12345shjd")
login(driver=driver,email_box=email_box, password_box=password_box)```
如果您想在click
上login
按钮使用下面的定位器并单击它
CSS选择器
button[type='submit']
XPATH或
//button[@type='submit']