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.

1 Like

i have same stuck in this alert :sneezing_face:

1 Like

Complete demo on alerts explained below

1 Like

Do you already solve this? I have the same issue

2 Likes

Use below and replacing correct object repository in to repository .
WebUI.waitForElementVisible(findTestObject(‘Object Repository/’), 5, FailureHandling.OPTIONAL)
WebUI.click(findTestObject(‘Object Repository/’), FailureHandling.OPTIONAL)

1 Like

How can you target the alert via object repository? I cannot capture it via web spy or recording. Alert is the main concern here.

1 Like

Okay Let us see.

1 Like

This is not an alert from your application. this is a Permission request from the Chrome Browser.

you have to use Chrome options to handle this one
i hope the following topics help you

  1. python - How to allow permissions to content in Chrome - Stack Overflow
  2. python 2.7 - Accept permission request in chrome using selenium - Stack Overflow
  3. How do I choose to "always allow" in the popup notification in Google Chrome with Selenium/java? - Stack Overflow
    4.Handling Permission Popups with Selenium WebDriver