0

I am trying to open a browser with the Selenium::WebDriver::Edge::Driver on Windows. I am able to open the browser but my session immediately crashes with this error:

unknown command: Cannot call non W3C standard command while in W3C mode 
(Selenium::WebDriver::Error::UnknownCommandError)

How would I turn off W3C mode in selenium ruby? I have tried to follow the docs here by doing:

webdriver_options = Selenium::WebDriver::Edge::Options.new(opts: {w3c: false})

before instantiating the webdriver. However this does not seem to make a difference - I suspect I am setting the options wrong. Has anyone seen this issue before? Thanks.

Petr Gazarov
  • 3,602
  • 2
  • 20
  • 37
  • Which version of Edge browser are you using? The Edge Legacy or the Edge Chromium browser? I'm not familar with ruby but I find some similar threads. You could refer to [this thread](https://stackoverflow.com/questions/56452798/how-to-turn-off-w3c-in-chromedriver-to-address-the-error-unknown-command-cannot). If you're using Edge Chromium, I think the options are like the Chrome's. You could try something like `capabilities = { "edgeOptions" => {'w3c' => false} }` or `options = Selenium::WebDriver::Edge::Options.new`, `options.add_option('w3c', false)`. – Yu Zhou Mar 31 '20 at 05:24
  • @YuZhou thanks! adding capabilities = { "edgeOptions" => {'w3c' => false} } and then passing it into the driver fixed my issue – sam.thacher Apr 01 '20 at 20:41
  • That's great! I want to put it as an answer and hope you can mark it as an accepted answer. It can help other community members in future in similar kind of issues. Thanks for your understanding. – Yu Zhou Apr 02 '20 at 01:28

2 Answers2

0
  1. verify if your browser is up to date
  2. Start > Settings > System > About; - and verify OS build
  3. Download last driver: https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/
  4. Unzip las version on: C:\Ruby23-x64\bin;
  5. If you are using capybara, try this:

    Capybara.register_driver :selenium do |app|

    Capybara::Selenium::Driver.new(app, :browser => :edge)

    end

Fabio Roveroto
  • 341
  • 2
  • 4
0

If you're using Edge Chromium, I think the options are like the Chrome's. You could refer to this thread and add the following code then pass it into the driver:

capabilities = { "edgeOptions" => {'w3c' => false} }
Yu Zhou
  • 11,532
  • 1
  • 8
  • 22