[英]How to click on the Sign up button within Instagram Sign up page using Selenium and Python
[英]How to click on the Sign up button on Spotify sign up page using Python Selenium
我无法点击 Spotify 注册页面上的“注册”按钮。 我找到了按钮 xpath 或 css 但我无法点击。 我尝试了“单击文本”,但结果相同。 你能帮我吗?
代码:
WebDriverWait(driver,10).until(EC.element_to_be_clickable((By.XPATH,'/html/body/div[2]/main/div/div/form/div[9]/div'))).click()
要单击Sign up元素,您需要为element_to_be_clickable()引入WebDriverWait ,并且可以使用以下任一Locator Strategies :
使用CSS_SELECTOR :
driver.get('https://www.spotify.com/in-en/signup') WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "div#onetrust-close-btn-container>button[aria-label='Close']"))).click() WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "input#email"))).send_keys("ggforces@stackoverflow.com") driver.find_element(By.CSS_SELECTOR, "button[type='submit']>div").click()
使用XPATH :
driver.get('https://www.spotify.com/in-en/signup') WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//div[@id='onetrust-close-btn-container']/button[@aria-label='Close']"))).click() WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//input[@id='email']"))).send_keys("ggforces@stackoverflow.com") driver.find_element(By.XPATH, "//button[@type='submit']/div").click()
注意:您必须添加以下导入:
from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.common.by import By from selenium.webdriver.support import expected_conditions as EC
浏览器快照:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.