1

i have a div which is dynamically generated though button click. As follows: `

<div id="modal4#{c.requestId}" class="modal-approval-size modal fade modal1" tabindex='-1'>
  <div class="modal-dialog modal_dialog"
    style="background-color: #f5f3f4;">
    <div class="modal-content-new modal-content">
        <div class="modal-header modal_header">
            <h4 class="modal-title">Confirmation Header</h4>
        </div>
        <div class="modal-body modal_body">
            <p>Please confirm the approval by clicking Ok. If you do not wish to approve the request please click Cancel.</p>
        </div>
        <div class="modal_footer">
            <span><a href="#"
                style="color: #000000; text-decoration: underline;"
                data-dismiss="modal" aria-hidden="true">Cancel(Esc)</a></span>
            <button type="button" class="btn btn-primary approve_btn"
                data-dismiss="modal" id="approvalConfirm"  onclick="callFunction('#{c.requestId}','C','A')">OK</button>
        </div>
    </div>
  </div>
</div>`

I want to click on the OK button through selenium WebDriver.

I am using Xpath as below:

//*[@id="approvalConfirm"]

But its not clickable and working. Can you please tell me why and how to fix it?

Mikaël Mayer
  • 10,425
  • 6
  • 64
  • 101
swapna
  • 475
  • 1
  • 6
  • 9
  • Did you try any code for that? If yes then please that code also with question. – Helping Hands Jan 06 '16 at 07:07
  • i was going through way by which i can click while i found http://stackoverflow.com/questions/25268957/selecting-webelements-with-dynamically-generated-ids-by-xpath-selenium-java Which is near to solution but there are many div.. – swapna Jan 06 '16 at 07:10
  • Yes but in you case I think it is popup window , right? – Helping Hands Jan 06 '16 at 07:10
  • then first you have to switch to that popup and then only you will be able to perform some operation with modal. Did you add code for switching to modal window? – Helping Hands Jan 06 '16 at 07:12
  • I added code to click on button which is working fine and its opening modal.. after modal is open it is not able to find OK button.. – swapna Jan 06 '16 at 07:18
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/99894/discussion-between-helping-hands-and-swapna). – Helping Hands Jan 06 '16 at 07:18
  • I wrote a better indentation and fixed some typos, and a final question. – Mikaël Mayer Jan 08 '16 at 18:02

0 Answers0