简体   繁体   中英

How to click on a button (pyautogui)?

I have a program that presses buttons on the site, but some buttons are out of sight (that is, to see them and press you to have to scroll through the page), how best can I solve this problem, given that I don't know which of the buttons will be out of sight.

You can copy the Xpath or CSS selector with inspect elements on the website.

By XPATH:

driver.find_element(By.XPATH("Paste here")).click()

By CSS selector:

driver.find_element(By.CSS_SELECTOR("Paste here")).click()

Here are the attributes available for the By class:

  • ID = "id"
  • XPATH = "XPath"
  • LINK_TEXT = "link text"
  • PARTIAL_LINK_TEXT = "partial link text"
  • NAME = "name"
  • TAG_NAME = "tag name"
  • CLASS_NAME = "class name"
  • CSS_SELECTOR = "css selector"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM