I am Automating one test case using Selenium Webdriver and core Java,in which on clicking one button I get browser level notification 'Show notifications with options Allow and Block'. After clicking "Allow" button, I want to validate contents of web push notifications that come as well as click on them. Does anybody know how to do that through selenium.Notifications will come something like this facebook chrome notifications
For my test in Chrome I used the following to check if push notification is visible.
//SITE:
driver.get("http://makemytrip.com/");
//Test for PUSH NOTIFICATION
if(driver.findElement(By.cssSelector("[id='webpush-bubble']" )).isDisplayed()) {
System.out.println("Push Prompt is Present");
//Popup active(as iFrame) so navigate in it and get text
//See=> https://sqa.stackexchange.com/questions/31693/how-to-read-html-source-from-iframe-using-selinium-webdriver
WebElement iFrame = driver.findElements(By.tagName("iframe")).get(6);
driver.switchTo().frame(iFrame);
System.out.println(driver.findElement(By.xpath("//div[@class='description']")).getText());
//Then switch back to normal content for any other navigation
driver.switchTo().defaultContent();
} else {
System.out.println("Push Prompt NOT Present");
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With