Java Windows 10 Edge 浏览器上的 Selenium
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31991309/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Selenium on Windows 10 Edge Browser
提问by divya r
I have to run automation on Windows 10 'Edge' browser. Please let me know how to launch Edge browser in windows 10 using Java Selenium Web Driver.
我必须在 Windows 10 'Edge' 浏览器上运行自动化。请让我知道如何使用 Java Selenium Web Driver 在 Windows 10 中启动 Edge 浏览器。
回答by vdmytsyk
It's for IE:
它适用于 IE:
System.setProperty("webdriver.ie.driver", "driver/IEDriverServer.exe");
Go to: https://www.microsoft.com/en-us/download/details.aspx?id=48212
转到:https: //www.microsoft.com/en-us/download/details.aspx?id=48212
Download MicrosoftWebDriver.exe
下载MicrosoftWebDriver.exe
And now your code for Edge has to be:
现在你的 Edge 代码必须是:
System.setProperty("webdriver.edge.driver", "driver/MicrosoftWebDriver.exe");
WebDriver driver = new EdgeDriver();
driver.get("www.site.com");
回答by william
File file = new File("C:\Program Files (x86)\Microsoft Web Driver\MicrosoftWebDriver.exe");
System.setProperty("webdriver.edge.driver", file.getAbsolutePath());
DesiredCapabilities capabilities = DesiredCapabilities.edge();
driver = new EdgeDriver(capabilities);
回答by Boni García
You can use webdrivermanager. Simply add this line to your Java program:
您可以使用webdrivermanager。只需将此行添加到您的 Java 程序中:
WebDriverManager.edgedriver().setup();
... and webdrivermanager downloads automatically the Edge driverand export the variable webdriver.edge.driverfor you.
... 并且 webdrivermanager 会自动下载Edge 驱动程序并为您导出变量webdriver.edge.driver。
The webdrivermanager Maven dependency is:
webdrivermanager Maven 依赖项是:
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>4.0.0</version>
</dependency>
回答by Anish Pillai
To use Edge with Selenium, one would need to -
要将 Edge 与 Selenium 结合使用,您需要 -
- have Windows 10
- download the correct version of MicrosoftWebDriver based on your OS build number
- 有 Windows 10
- 根据您的操作系统版本号下载正确版本的 MicrosoftWebDriver
Use the steps given below -
使用下面给出的步骤 -
Go to Start > Settings > System > Aboutand note down the OS Build number
Download the proper version of the driver from this link - https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/
If the file that's downloaded is .msi, then install it to get the .exe driver. For one of the release, direct .exe can be downloaded.
Once the MicrosoftWebDriver.exe is downloaded, we can use it in our test script using either System.setProperty("webdriver.edge.driver", "driver location") or using environment variable
转到“开始”>“设置”>“系统”>“关于”并记下操作系统版本号
从此链接下载正确版本的驱动程序 - https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/
如果下载的文件是 .msi,则安装它以获取 .exe 驱动程序。对于其中一个发行版,可以直接下载.exe。
下载 MicrosoftWebDriver.exe 后,我们可以使用 System.setProperty("webdriver.edge.driver", "driver location") 或使用环境变量在我们的测试脚本中使用它
Sample script would look like this -
示例脚本如下所示 -
System.setProperty("webdriver.edge.driver","C:\Program Files (x86)\Microsoft Web Driver\MicrosoftWebDriver.exe"); //put actual location
WebDriver driver = new EdgeDriver();
driver.get("your link");
Refer this article for detailed information: http://automationtestinghub.com/selenium-3-launch-microsoft-edge-with-microsoftwebdriver/
有关详细信息,请参阅本文:http: //automationtestinghub.com/selenium-3-launch-microsoft-edge-with-microsoftwebdriver/