I'm running into an issue trying to click on a specific button on my web application using Selenium with Python. The button shows up on a dialog that becomes available once another button is pressed.
For example, my form has the following section:
Once the 'Save Answers' button is pressed, an OK button shows up in a dialog above it.
I'm trying to click on this OK button, but it is not working as of right now. When I inspect this element on Chrome, I get the following items:
<div class="bootbox modal fade my-modal in" tabindex="-1" role="dialog" style="display: block;">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-body">
<div class="bootbox-body">Your answers have been saved.</div>
</div>
<div class="modal-footer">
<button data-bb-handler="cancel" type="button" class="btn btn btn-primary">OK</button>
</div></div></div></div>
With <button data-bb-handler="cancel" type="button" class="btn btn btn-primary">OK</button> being the button I am trying to click.
I am using the following Python code to try this:
driver.find_element_by_id("saveQuestionsSection").click() #click Save Answer
driver.find_element_by_xpath("//button[@type='button']").click() #click OK
But it is not working. I have tried to replicate this step using Selenium IDE and it works there, with the command looking like this:
Command: click
Target: xpath=(//button[@type='button'])[26]
But I am not sure how to translate this into Python code.
Any ideas?

