2

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.

3 Answers 3

1

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"
Sign up to request clarification or add additional context in comments.

1 Comment

I know how to find the element. I made a little mistake, I click not through selenium, but through pyautogui, and the problem is actually described above
0

pyautogui only accepts the coordinates, as stated in the documentation In example:

`pyautogui.click(x=100, y=200)  # move to 100, 200, then click the left mouse button.` 

if you would like to select hidden elements a library like Selenium would be better. An example would be:

driver.findElement(By.className("AddContentBTN")).click();

This way you can select any element and search the dom.

Comments

0

The latest version definitely supports clicking on screenshots:

>>> import pyautogui
>>> button7location = pyautogui.locateOnScreen('calc7key.png', confidence=0.9)
>>> button7location
Box(left=1416, top=562, width=50, height=41)

Documentation here

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.