简体   繁体   English

使用 selenium 启动 Microsoft Edge Chromium 浏览器

[英]Launch Microsoft Edge Chromium browser using selenium

I am trying to launch Microsoft Edge Chromium browser using selenium.我正在尝试使用 selenium 启动 Microsoft Edge Chromium 浏览器。 Microsoft Edge chromium Version: Version 79.0.309.65 (Official Build) (64-bit) Downloading driver file from https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/ Microsoft Edge 铬版本:版本 79.0.309.65(官方版本)(64 位)从https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/下载驱动程序文件

Using this code to for the same but it is giving unreachable browser Exception and not working.使用此代码进行相同的操作,但它给出了无法访问的浏览器异常并且无法正常工作。

1.System.setProperty("webdriver.edge.driver", "C:\\Program Files (x86)\\Microsoft\\Edge Beta\\Application\\msedgedriver.exe");
EdgeOptions options = new EdgeOptions();
BROWSER=properties.getProperty("BrowserName");
options.setCapability(BROWSER, false);
//DesiredCapabilities  m_capability = DesiredCapabilities.edge();
driver= new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), options);
2.DesiredCapabilities  m_capability = DesiredCapabilities.chrome();
BROWSER=properties.getProperty("BrowserName");`enter code here`
m_capability.setCapability( BROWSER, "chrome" );
driver = new ChromeDriver();
System.setProperty("webdriver.chrome.driver",
                   "C:\\edgedriver_win64-1\\msedgedriver.exe");

It is looking like compatibility issue.它看起来像兼容性问题。 You can upgrade or downgrade your msedgedriver driver version to make it work.您可以升级或降级msedgedriver驱动程序版本以使其正常工作。

I will recommend you to use WebDriverManager我会推荐你​​使用WebDriverManager

WebDriverManager allows to automate the management of the binary drivers (eg chromedriver, geckodriver, etc.) required by Selenium WebDriver. WebDriverManager 允许自动管理 Selenium WebDriver 所需的二进制驱动程序(例如 chromedriver、geckodriver 等)。

maven dependency Maven 依赖

<dependency>
    <groupId>io.github.bonigarcia</groupId>
    <artifactId>webdrivermanager</artifactId>
    <version>3.8.0</version>
    <scope>test</scope>
</dependency>

Once we have included this dependency, you can let WebDriverManager to manage the WebDriver binaries for you.一旦我们包含了这个依赖项,您就可以让 WebDriverManager 为您管理 WebDriver 二进制文件。 Now you can set driver instance for Edge.现在您可以为 Edge 设置驱动程序实例。

public class EdgeDevTest {

    private WebDriver driver;

    @BeforeClass
    public static void setupClass() {
        WebDriverManager.edgedriver().setup();
    }

    @Before
    public void setupTest() {
        ChromeOptions chromeOptions = new ChromeOptions();
        chromeOptions.setBinary(
                "C:\\Program Files (x86)\\Microsoft\\Edge Dev\\Application\\msedge.exe");
        EdgeOptions edgeOptions = new EdgeOptions().merge(chromeOptions);
        driver = new EdgeDriver(edgeOptions);
    }

    @After
    public void teardown() {
        if (driver != null) {
            driver.quit();
        }
    }
public void testservice(){  
    EdgeOptions opt= new EdgeOptions();
    opt.setHeadless();
    WebDriver driver= new EdgeDriver(opt);

}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法在 Selenium 3 中启动 Microsoft Edge 浏览器 - Not able to launch Microsoft Edge Browser in Selenium 3 Selenium WebDriver Java 启动带有解压扩展的 Edge Chromium - Selenium WebDriver Java launch Edge Chromium with an unpacked extension 边缘铬无头模式使用 java 和 selenium 3 - Edge chromium headless mode using java and selenium 3 使用“new EdgeOptions()”优于“DesiredCapabilities.edge()”错误通过Jenkins和Selenium启动远程Microsoft Edge浏览器 - Using `new EdgeOptions()` is preferred to `DesiredCapabilities.edge()` error launching Remote Microsoft Edge browser through Jenkins and Selenium 如何使用 Selenium WebDriver 和 Java 在 InPrivate 中启动 Microsoft Edge - How to launch Microsoft Edge in InPrivate with Selenium WebDriver and Java 尝试在 Java App-V 的新进程中启动 Microsoft Edge Chromium - Trying to launch Microsoft Edge Chromium in a new process for Java App-V Selenium 和 Edge Dev(基于 Chromium) - Selenium and Edge Dev (Chromium based) 无法在 Selenium 中启动多个边缘浏览器/实例? Selenium 只允许单个实例作为边缘? - Not able launch multiple edge browser/instance in Selenium? Selenium allows only single instance for edge? Selenium - Java:Microsoft Edge 自动化浏览器(Windows 10) - Selenium - Java : Microsoft Edge automation browser (Windows 10) 如何使用 Selenium 修复 Edge 浏览器中的 ElementNotVisibleException? - How to fix the ElementNotVisibleException in Edge browser using Selenium?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM