Home > Software engineering >  How do I click on this button in Selenium, python. Every time i click on it, its link changes, so i
How do I click on this button in Selenium, python. Every time i click on it, its link changes, so i

Time:11-04

i wanted to automate a task which clicks on the next button if the big green button says "completed well done!". but its link changes every time I click on it.first image shows that i tried entering the class but didn't work. second image shows the webpage

i tried using x,y coordinates to click on it but the coordinates I entered didn't work and it just ended up clicking on a random position

CodePudding user response:

It looks like the button, you want to klick, has a html id. That is pretty handy if that id is unique in that html. If so you can just search for that element with that id like so:

driver.find_element_by_id('relationsNextIcon')

Here is an other answer with find_element_by_id: https://stackoverflow.com/a/7732002/12914172

If that id is not unique on that page, you can try to combine some of the attributes of that element with xpath:

driver.find_element_by_xpath('//i[@id="relationsNextIcon"]')

Your Screenshot says that desired element is an "i" html element. In xpath I can tell to only search for "i" html elements with that id to hopefully find a combination which is unique if the id alone isn't.

Here is an answer which uses an or operator in the xpath to search for even more attributes: https://stackoverflow.com/a/46686975/12914172

  • Related