如何在IE中接受物理位置警报

问题描述 投票:0回答:1

在我的项目中,我在导航到“位置”选项卡后在IE中收到以下警报。

enter image description here

现在我想接受相同的,为此我添加了以下功能,但它不起作用。

System.setProperty("webdriver.ie.driver",properties.getProperty("InternetExplorerDriverPath"));
DesiredCapabilities ieCapabilities = DesiredCapabilities.internetExplorer();
ieCapabilities.setCapability("nativeEvents", true);
ieCapabilities.setCapability("window.confirm", true);
ieCapabilities.setCapability("unexpectedAlertBehaviour", "accept");
ieCapabilities.setCapability("disable-popup-blocking", true);
ieCapabilities.setCapability("enablePersistentHover", true);
driver = new InternetExplorerDriver(ieCapabilities);

请帮忙。

selenium-webdriver iedriverserver
1个回答
1
投票

我无法打开网址。在IE浏览器中的这种情况下,ALT+N命令会将焦点转移到页面底部弹出的警告。因此,您可以使用Robot类并发送ALT+N键将焦点移至警报弹出,然后您可以传递TAB键并选择所需的选项(即允许一次或选择其他选项)。

示例示例:

    Robot robo=new Robot();
    robo.keyPress(KeyEvent.VK_ALT);
    robo.keyPress(KeyEvent.VK_N); //this will move the focus to alert pop up
    //play around with other keys once the foucs moves to the alert pop up
    //ensure to release all the keys

注意:检查ALT+N命令是否将焦点移至手动弹出警报,然后尝试使用selenium

© www.soinside.com 2019 - 2024. All rights reserved.