H
H
Holopsicon2020-07-20 19:13:22
Python
Holopsicon, 2020-07-20 19:13:22

How to set a condition for the existence of a button on the page at the time of checking the condition?

I can't think of a condition that, if the desired button is visible, will return
True :
The option with waiting for this button to appear (the usual WebDriverWait or any other method that can reduce the speed of the script by normal waiting) is of less priority, because I already wrote this one myself.
In a loop from i to 30, a check is made to see if this button is in the visibility zone, if so, perform an action.

if browser_branch.find_element_by_xpath("//div[@class='_action']").is_displayed() == True:
                print("Найден активный элемент во вторичном окне")

I would be very grateful for any option you suggest.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2020-07-20
@Holopsicon

Why not

for _  in range(30):
    if browser_branch.find_element_by_xpath("//div[@class='_action']"):
        print("Найден активный элемент во вторичном окне")
        break

well, it is desirable to add a delay so that it does not immediately check 30 times

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question