mardi 23 mars 2021

If -Else with text on Xpath

A suggestion: I would like to use the IF-Else function, to make Python understand that if in that XPath I have a certain text example:"Loop", it repeats the loop, if instead it appears in the text "stop", it continues and stops the loop (break type) First there is a Click Button that turns that X Path with the text "Loop" or "stop", with these 2 variables:

Xpath: <h1 class="b-34556-loptere" data-nchor-id="a2g0n_10409d129Nd2crC">Loop</h1> or <h1 class="b-34556-loptere" data-nchor-id="a2g0n_10409d129Nd2crC">Stop</h1>

if driver.find_element_by_xpath("//span[contains(text(),'Loop')]") :
       button.click()
       time.sleep(4)

else
         print('exit')
         break

To make you understand how to achieve that result. I'm a newbie, so I've been thinking about this cycle, but it doesn't work. Thanks

Aucun commentaire:

Enregistrer un commentaire