简体   繁体   中英

How dismiss ALERT popup while opening a browser

I open a browser: '''

https://portal-qa1.maytronics.co/#/login/login

After successfully logging in (user: Shoval.Ziman@comm-it.com, pass: 123456), I go to the page I need and a ALERT message appears. I tried to remove it in many ways, nothing comes out.

  1. The switchTo() method - doesn't work.

  2. The Robot(), doesn't work two:

     Robot alertAllow = new Robot(); alertAllow.mouseMove(280, 160); alertAllow.mousePress(InputEvent.BUTTON1_DOWN_MASK); alertAllow.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); Thread.sleep(3000);
  3. Also I tried to use the next method:

     WebDriverManager.chromedriver().setup(); Map<String, Object> prefs = new HashMap<String, Object>(); prefs.put("profile.default_content_setting_values.notifications", 2); ChromeOptions options = new ChromeOptions(); options.setExperimentalOption("prefs", prefs);

    and that didn't help either.

Try this:

Thread.sleep(1000);
robot.keyPress(KeyEvent.VK_ENTER);
// or
robot.keyPress(KeyEvent.VK_ESCAPE);

Usually, after hitting enter or escape most alerts go away.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM