How to add arguments to edgeOptions in using edgeDriver selenium
Asked Answered
W

2

8

I have added the options for chromedriver for selenium testing in my project but i dont understand the appropriate methods for edgedriver. I have tried all the possibilities. Can someone help me out? Thankyou.

            ChromeOptions options = new ChromeOptions();
    options .addArguments("--start-maximized");
    options .addArguments("--window-size=1920,900");
    _chromeOptions.addArguments("--ignore-certificate-errors");

Its working fine for chromeOptions but I dont understand how to write for edge options.

            EdgeOptions options = new EdgeOptions();
            options.setCapability("window-size","1920*900");
    options.setCapability("ignore-certificate-errors" , true);

    DesiredCapabilities capabilities = DesiredCapabilities.edge();
            options.merge(capabilities);

For edge Options since there is no addArguments function I tried with setCapability and atlast merged with DesiredCapabilities but it is not working

Wnw answered 23/9, 2019 at 12:37 Comment(0)
R
4

If you still want to use Selenium 3.141.59 for compatibility, the way to add arguments to EdgeOptions is like this:

EdgeOptions options = new EdgeOptions();
options.setCapability(CapabilityType.ACCEPT_INSECURE_CERTS, true);
List<String> args = Arrays.asList("use-fake-ui-for-media-stream", "use-fake-device-for-media-stream");
Map<String, Object> map = new HashMap<>();
map.put("args", args);
options.setCapability("ms:edgeOptions", map);

I had to reverse engineer to figure out the exact data structures the driver was expecting inside. That works like a charm.

Refreshment answered 5/11, 2021 at 2:10 Comment(0)
G
0

I was running into this same issue and it was getting very frustrating! Luckily, in the newer alpha version (4.0.0-alpha-5) of the selenium-edge-driver they have added in the addArguments() method into EdgeOptions()

Ghat answered 27/3, 2020 at 21:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.