I am automating a website, I have few 6 digit numbers (for example - 111111, 222222, 333333)
If I am taking 111111 (inside a for loop) and identifying a path :
driver.find_element_by_xpath("//a[@class='button' and @title='Create Work Item Copy']").click()
for first time it is able to find it and click on it, but when the loop is running second time and so on (for 222222, 333333, ...n)I am getting :
Message: no such element: Unable to locate element: {"method":"xpath","selector":"//a[@class='button' and @title='Create Work Item Copy']"}
The above error message is for the button I want to click, upon check the "Inspect Element",
I found that the "id" is changing for every iteration for loop is doing.
<span class="jazz-ui-toolbar-Button" **id="jazz_ui_toolbar_Button_16"** widgetid="jazz_ui_toolbar_Button_16" style=""><a class="button" dojoattachpoint="titleNode,focusNode" href="#" dojoattachevent="onclick:_onClick,onkeypress:_onKeyPress" role="button" title="Create Work Item Copy" aria-disabled="false" tabindex="-1"><img src="/ccm/web/dojo/resources/blank.gif?etag=azf6UBC" class="button-img sprite-image-15" alt="Create Work Item Copy"><span class="button-label" dojoattachpoint="_label" style="display:none"></span></a>
you see in above HTML, the "id" is id="jazz_ui_toolbar_Button_16" is 16 for 1st iteration for for loop, but for second this 16 will become some random number on 2nd iteration of for loop and so on.
Hence I am getting the error.
I tried using absolute xpath, no good. Please help.
If you need any more information, let me know.