How to Handle Browser alerts

Hi,

Any one can help me, how to handle browser alerts.

I have used, ‘WebUI.acceptAlert()’ and
driver.switchTo().alert().accept().

But it is not working. Please check the attached screenshot for alert reference.

Thankyou,
Sree.

Have you tried this :

WebUI.openBrowser('C:\\\\Users\\\\User\\\\Desktop\\\\How to Handle Alerts.html')
 
'Maximize the window of the browser'
 
WebUI.maximizeWindow()
 
'Clicking on  button'
 
WebUI.click(findTestObject('Alerts/button_ClickHere'))
 
'Accepting the Alert'
 
WebUI.acceptAlert()

1.) I have not understood this, here in open browser which path I should need to give.

2.) ‘Clicking on button’

WebUI.click(findTestObject(‘Alerts/button_ClickHere’))

How should I give the xpath for clicking on object, since I don’t have any xpath for alert.

i have same stuck in this alert :sneezing_face:

Complete demo on alerts explained below