简体   繁体   English

如何使用 python selenium chrome 驱动程序单击此登录按钮:

[英]How do I click this sign in button using python selenium chrome driver:

I am trying to select and click the sign in button using python selenium chrome driver however I am unsure how to define the button:我正在尝试 select 并使用 python selenium chrome 驱动程序单击登录按钮但是我不确定如何定义按钮:

<button class="Wizard__AccountActionButton-mlu9la-10 fCdYqg flex justify-center items-center  font-din">Sign in</button>

To click on the element with text as Sign in you can use either of the following Locator Strategies :要单击带有文本作为登录的元素,您可以使用以下任一定位器策略

  • Using css_selector :使用css_selector

     driver.find_element(By.CSS_SELECTOR, "button.flex.justify-center.items-center.font-din").click()
  • Using xpath :使用xpath

     driver.find_element(By.XPATH, "//a[contains(@class, 'flex justify-center items-center font-din') and text()='Sign in']").click()

Ideally, to click on the element you need to induce WebDriverWait for the element_to_be_clickable() and you can use either of the following Locator Strategies :理想情况下,要单击需要为element_to_be_clickable()诱导WebDriverWait的元素,您可以使用以下任一Locator Strategies

  • Using CSS_SELECTOR :使用CSS_SELECTOR

     WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "button.flex.justify-center.items-center.font-din"))).click()
  • Using XPATH :使用XPATH

     WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//a[contains(@class, 'flex justify-center items-center font-din') and text()='Sign in']"))).click()
  • Note : You have to add the following imports:注意:您必须添加以下导入:

     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.

相关问题 如何使用 Python 将选项传递给 Selenium Chrome 驱动程序? - How do I pass options to the Selenium Chrome driver using Python? 如何通过 Python 使用 Chrome 驱动程序和 Selenium 登录 Applemusic - How To sign in to Applemusic With Python Using Chrome Driver With Selenium 如何使用 Selenium 和 Python 找到此登录按钮的元素? - How do I find this element for this sign in button using Selenium with Python? Selenium Web驱动程序:如何单击按钮? - Selenium web driver: How do I click on the button? 如何使用python硒单击网页上的Javascript按钮 - How do I click a Javascript button on a webpage using python selenium 如何使用 selenium 和 python 找到并单击此开始按钮? - How do I locate and click this start button using selenium and python? 如何在Python中使用Selenium单击按钮? - How do I click a button using Selenium in Python? 如何使用 Selenium 和 Python 2.7 单击表单中的按钮? - How do I click a button in a form using Selenium and Python 2.7? 如何使用 selenium - python 单击网站上的按钮? - How do I click on a button on a website using selenium - python? 如何使用 Selenium 和 Python 在 Instagram 注册页面中单击注册按钮 - How to click on the Sign up button within Instagram Sign up page using Selenium and Python
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM