How to click on a button (pyautogui)?

Viewed 324

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.

1 Answers

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"
Related