How to deal with facebook show notification box | Selenium Forum
M
Posted on 24/05/2016
Hi Ashish,

I am logging in to facebook using chrome webDriver but on the landing page, i am getting one alert(screenshot attached)

not able to click on it using alert. (please note - i tried using alert but getting error saying no alert present)

could you please tell me how to deal with it

code -

System.setProperty("webdriver.chrome.driver","C:\\Users\\ULTRA1\\Downloads\\chromedriver_win32\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.get("http://www.facebook.com");
driver.findElement(By.xpath("//*[@id='email']")).sendKeys("***");
driver.findElement(By.xpath("//*[@id='pass']")).sendKeys("****!");
driver.findElement(By.xpath("//*[@id='loginbutton']")).click();
Alert al = driver.switchTo().alert();
al.dismiss();
driver.switchTo().defaultContent();
System.out.println(driver.getTitle());
Thread.sleep(3000);
// driver.quit();

M
Replied on 24/05/2016

use this

[quote:1zdrs388]driver.findElement(By.xpath("html/body")).sendkeys(Keys.ESC);
[/quote:1zdrs388]


M
Replied on 27/05/2016

thanks Ashish , it worked...