webentwicklung-frage-antwort-db.com.de

So deaktivieren Sie w3c in chromedriver, um den unbekannten Fehlerbefehl zu beheben: In W3C kann kein Nicht-W3C-Standardbefehl aufgerufen werden

Mit der gerade veröffentlichten Version 75 von Chrome] werden unsere Tests nicht mehr ordnungsgemäß ausgeführt. Sie geben den unten eingefügten Stacktrace an. Wir verwenden Ruby on Rails v. 5.1.6.2 mit rspec, Selenium-Webdriver 3.8.0.

Stacktrace:

Selenium::WebDriver::Error::UnknownCommandError:
            unknown command: Cannot call non W3C standard command while in W3C mode
          # 0   chromedriver                        0x000000010c46e8e9 chromedriver + 3594473
          # 1   chromedriver                        0x000000010c3fe543 chromedriver + 3134787
          # 2   chromedriver                        0x000000010c1aa29f chromedriver + 692895
          # 3   chromedriver                        0x000000010c11a691 chromedriver + 104081
          # 4   chromedriver                        0x000000010c11b7d5 chromedriver + 108501
          # 5   chromedriver                        0x000000010c42d555 chromedriver + 3327317
          # 6   chromedriver                        0x000000010c438e60 chromedriver + 3374688
          # 7   chromedriver                        0x000000010c438bf8 chromedriver + 3374072
          # 8   chromedriver                        0x000000010c40cd39 chromedriver + 3194169
          # 9   chromedriver                        0x000000010c4396d8 chromedriver + 3376856
          # 10  chromedriver                        0x000000010c420f27 chromedriver + 3276583
          # 11  chromedriver                        0x000000010c456064 chromedriver + 3493988
          # 12  chromedriver                        0x000000010c474617 chromedriver + 3618327
          # 13  libsystem_pthread.dylib             0x00007fff7744c2eb _pthread_body + 126
          # 14  libsystem_pthread.dylib             0x00007fff7744f249 _pthread_start + 66
          # 15  libsystem_pthread.dylib             0x00007fff7744b40d thread_start + 13
          # /Users/julie/.rvm/gems/Ruby-2.5.1/gems/Selenium-webdriver-3.8.0/lib/Selenium/webdriver/remote/response.rb:69:in `assert_ok'
          # /Users/julie/.rvm/gems/Ruby-2.5.1/gems/Selenium-webdriver-3.8.0/lib/Selenium/webdriver/remote/response.rb:32:in `initialize'
          # /Users/julie/.rvm/gems/Ruby-2.5.1/gems/Selenium-webdriver-3.8.0/lib/Selenium/webdriver/remote/http/common.rb:81:in `new'
          # /Users/julie/.rvm/gems/Ruby-2.5.1/gems/Selenium-webdriver-3.8.0/lib/Selenium/webdriver/remote/http/common.rb:81:in `create_response'
          # /Users/julie/.rvm/gems/Ruby-2.5.1/gems/Selenium-webdriver-3.8.0/lib/Selenium/webdriver/remote/http/default.rb:104:in `request'
          # /Users/julie/.rvm/gems/Ruby-2.5.1/gems/Selenium-webdriver-3.8.0/lib/Selenium/webdriver/remote/http/common.rb:59:in `call'
          # /Users/julie/.rvm/gems/Ruby-2.5.1/gems/Selenium-webdriver-3.8.0/lib/Selenium/webdriver/remote/bridge.rb:166:in `execute'
          # /Users/julie/.rvm/gems/Ruby-2.5.1/gems/Selenium-webdriver-3.8.0/lib/Selenium/webdriver/remote/oss/bridge.rb:579:in `execute'
          # /Users/julie/.rvm/gems/Ruby-2.5.1/gems/Selenium-webdriver-3.8.0/lib/Selenium/webdriver/remote/oss/bridge.rb:526:in `element_displayed?'
          # /Users/julie/.rvm/gems/Ruby-2.5.1/gems/Selenium-webdriver-3.8.0/lib/Selenium/webdriver/common/element.rb:199:in `displayed?'
          # /Users/julie/.rvm/gems/Ruby-2.5.1/gems/capybara-2.17.0/lib/capybara/Selenium/node.rb:148:in `visible?'
          # /Users/julie/.rvm/gems/Ruby-2.5.1/gems/capybara-2.17.0/lib/capybara/node/element.rb:269:in `block in visible?'
          # /Users/julie/.rvm/gems/Ruby-2.5.1/gems/capybara-2.17.0/lib/capybara/node/base.rb:81:in `synchronize'
          # /Users/julie/.rvm/gems/Ruby-2.5.1/gems/capybara-2.17.0/lib/capybara/node/element.rb:269:in `visible?'
          # /Users/julie/.rvm/gems/Ruby-2.5.1/gems/capybara-2.17.0/lib/capybara/queries/selector_query.rb:84:in `matches_filters?'
          # /Users/julie/.rvm/gems/Ruby-2.5.1/gems/capybara-2.17.0/lib/capybara/result.rb:29:in `block in initialize'

Unsere Treiberkonfiguration:

File.write(LOG_FILE_PATH, '')
Selenium::WebDriver.logger.level = :debug
Selenium::WebDriver.logger.output = LOG_FILE_PATH
Capybara.register_driver :Selenium do |app|
  # from https://github.com/SeleniumHQ/Selenium/issues/3738
  capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(loggingPrefs: {browser: 'ALL'})
  options = Selenium::WebDriver::Chrome::Options.new
  options.add_argument '--disable-infobars' # hide info bar about chrome automating test
  # if we don't use this flag, every Selenium test will die with the error:
  # "unknown error: Chrome failed to start: exited abnormally"
  options.add_argument '--no-sandbox'
  options.add_argument '--headless' if ENV.fetch("HEADLESS", nil).present?
  options.add_argument '--window-size=1600,2400'
  options.add_argument '-–allow-file-access-from-files' # TODO Julie - may help with file specs?
  options.add_preference('homepage', 'about:blank') # TODO is this working?
  options.add_preference('profile.default_content_settings.popups', 0)
  options.add_preference('download.default_directory', DownloadHelpers::PATH.to_s)
  Capybara::Selenium::Driver.new(
    app,
    clear_local_storage: true,
    clear_session_storage: true,
    browser: :chrome,
    options: options,
    desired_capabilities: capabilities,
  )
end

PDATE :

Mit capabilities = { "chromeOptions" => {'w3c' => false} } Konnte ich unsere Tests vorübergehend zum Laufen bringen.

Nach der Aktualisierung von chromedriver wurde der Fehler "Unbekannter Fehler: DevToolsActivePort-Datei existiert nicht" angezeigt. Um dieses Problem zu beheben, haben wir unser Selenium-Webdriver-Juwel auf 3.142.3 aktualisiert. Dadurch wurde das Problem behoben, sodass wir w3c ohne zusätzliche Parameter verwenden konnten.

19
Julie

So geht das in Behat with Mink: # behat #mink

  Behat\MinkExtension:
    base_url: "your_site_url"
    browser_name: 'chrome'
    goutte: ~
    javascript_session: Selenium2
    Selenium2:
      wd_Host: http://127.0.0.1:4444/wd/hub
      capabilities:
        browser: chrome
        extra_capabilities:
          chromeOptions:
            args: ['--headless', '--disable-gpu']
            w3c: false
0
Shweta Sharma

Benutzer von PHP Behat-Mink-Selenium finden diesen Beitrag zur Information: https://medium.com/@alex.designworks/chromedriver-75-enforces-w3c-standard-breaking-behat-tests-460cad435545 und GitHub-Problem https://github.com/minkphp/MinkSelenium2Driver/issues/29

Ab diesem Beitrag besteht die "Problemumgehung" darin, auf Chrome 74 für Benutzer von Behat-Mink-Selenium zurückzugreifen).

0
Phil Davis