I'm using the following code to click a button on a page but the XPath keeps changing so the code keeps breaking:
mydriver.find_element_by_xpath("html/body/div[2]/div[3]/div[1]/div/div[2]/div[2]/div[4]/div/form[2]/span/span/input").click()
Is there a better way I should be doing this? Here is the code for the button I am trying to click:
<input class="a-button-input" type="submit" title="Button 2" name="submit.button2-click.x" value="Button 2 Click"/>
I'd use findelement(by.name(" submit.button2-click.x")).click() or use find element(by.cssSelector("selector ")).click()
Python - Issues with selenium button click using XPath