我正在尽我所能点击“允许所有”,然后点击“继续”按钮的slido用户登录网站
webiste_link = "https://auth.slido.com/login?auth_state=eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IkIifQ.eyJqdGkiOiJkY2MwNThlYy03YjY1LTQxNWQtODJkNS00ZThkOWYxOWZjZDUiLCJjbHVzdGVyX2lkIjoiZXUxIiwiY2xpZW50SWQiOiI2OTFmNGMxNi1kZTM1LTExZWItYmE4MC0wMjQyYWMxMzAwMDQiLCJwcm9tcHQiOiJjb25zZW50IiwicmVkaXJlY3RVcmkiOiJodHRwczovL2FkbWluLnNsaS5kby9vYXV0aC1jYWxsYmFjayIsInNjb3BlIjoib3BlbmlkIG9mZmxpbmVfYWNjZXNzIGVtYWlsIHByb2ZpbGUgc3lzdGVtOnNjb3BlOmFjcXVpcmUiLCJzZXNzaW9uIjp7ImlzQXV0aE4iOmZhbHNlLCJpc0ludGVybmFsIjp0cnVlfSwic3RhdGUiOiJleUp5WldScGNtVmpkQ0k2SW1GSVVqQmpTRTAyVEhrNWFGcEhNWEJpYVRWNllrZHJkVnBIT0haYVdGcHNZbTVTZWlKOSIsImNsYWltcyI6e30sImlhdCI6MTY3NTE4MDk4OCwiZXhwIjoxNjc1MTgyNzg4LCJpc3MiOiJodHRwczovL2F1dGguc2xpZG8uY29tIn0.NvC6eFAmguxI25_Dt8lMsMs4zTquP9DHcz9ukuv1pLzt3kSCVmRYJoTHXuoCpz1SKK6isFdfG8P_0-QHOpXWjdb0Gfxuz50fK5IkaO-vNN84eNQN9rV-Q5Tkw2r6tnyap7Hq3hasiwMoexaBEGx5tTk1y8Ab4xOuXFS0OpeyaiBUjVxr9GsH2TrmuZCdePGverwue_5k-6LStmfjVJlsuh7BC2fkLLNKizbC_mckqLloylu-MChV0GfhXFxHwCpSSRvLa64zmNTZ8KJ1FA3WrNCg5PkjIn6KLdHU7wBmR53MhTE0rMvxOF3gkUoVKerkF5DRe_z9xbRFUW_soAt_5A"
我正在尝试下面的代码来做这件事,但它是行不通的:
chrome_driver_path = user\location\chromedriver.exe"
options = webdriver.ChromeOptions()
driver = webdriver.Chrome(executable_path=chrome_driver_path,options=options)
wait = WebDriverWait(driver, 5)
# open the webpage and enter the email id on the login page
driver.get("webiste_link")
wait.until(EC.element_to_be_clickable((By.ID,"email"))).send_keys("ab@xyz.com")
driver.find_element(By.CLASS_NAME, "//span[text()='Allow all']").click()
time.sleep(5)
#then clicking on the continue button and move forward
driver.find_element(By.CLASS_NAME, "//span[text()='Continue']").click()
time.sleep(5)
但是它没有点击这两个按钮。不知道为什么。我在这里做错了什么?
1条答案
按热度按时间qltillow1#
我认为您的定位器是这里的问题所在。不要使用ClassName,尝试XPath
“全部接受”按钮的XPath:
//button[contains(text(),'Allow all')]
“继续”按钮的XPath:
//div[@class='mb8']