0

I have been trying to login to faceboook and search a friend using Selenium. But I am stuck on this particular popup, and can't resolve this issue to proceed further.

Screenshot with popup

public class FbAutomation {
    public static void main(String[] args) {
        FirefoxDriver browser = new FirefoxDriver();
        browser.get("https://www.facebook.com/");
        browser.manage().window().maximize();
        browser.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
        browser.findElement(By.xpath("//input[@name='email']")).sendKeys("user-email");
        browser.findElement(By.xpath("//input[@name='pass']")).sendKeys("password");
        /*Dimension radi = browser.findElement(By.xpath("//label[@id='loginbutton']")).getSize();
        System.out.println("height is " + radi.height + " and width is " + radi.width);*/
        browser.findElement(By.xpath("//label[@id='loginbutton']")).submit();
        browser.navigate().to("https://www.facebook.com/imshaiknasir");
        Alert alt = browser.switchTo().alert();
        alt.accept();
        /*
         * Not able to handle "Allow notification" popUp box.
         */`enter code here`
        browser.close();
    }
}
Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
  • This alert is not a JS alert, it's browser specific so Selenium can't handle it directly. You should be able to disable it per browser. For FF, see [this](https://stackoverflow.com/a/49111281/2386774). There are other answers in that question that deal with Chrome also. – JeffC May 25 '18 at 14:52
  • Possible duplicate of [How to disable push-notifications using Selenium for Firefox?](https://stackoverflow.com/questions/49741876/how-to-disable-push-notifications-using-selenium-for-firefox) – undetected Selenium Jun 19 '18 at 13:27

0 Answers0