How to capture confirmation message

@nancy.chen If you are only at the stage of getting objects via Web Spy, you may not, however, if you extend yourself, you may be able to create an object that would be like clicking on the OK button or Cancel button, but you would have to create the object in the Object Repository yourself.

  1. If you right click on the folder under Object Repository that you want the new object, then select “New > Test Object”, give the new object a name**, then click OK.
  2. For the new object, select Add, and for Name put in tag and for Value, put in button,
  3. Select Add again, and for Name choose xpath from the drop-down and for Value, put in //button[text()="OK"] (this is such a simple text that if you have more like it within your application, that the button may not work),
  4. In your Test Case, add the statements where this confirmation pop-up would appear,
WebUI.switchToWindowIndex(1)   // this may not be necessary
WebUI.waitForElementVisible(findTestObject('your new object'), 10)
WebUI.click(findTestObject('your new object'))

And I hope this works for you. Edit: you should try with the switchToWindowIndex() and without it.

To make another object for the Cancel button, do the same for object number 2 but obviously change the text to “Cancel”.

**Edit: we use the following 3-part rule to name our objects. The first part is based on the tag, such as “button”. The second part is based on the section of the page where the object is–in this case, maybe “Confirm”. The last part is based on the nearest label–you may use the text you crossed out in red. So, you could put:
button.Confirm.yourHiddenTextHereOk