Behat + Mink - Selenium2问题:'requiredCapabilities'参数不是对象

时间:2017-09-15 09:12:08

标签: selenium behat

我正在使用Behat,Mink和Selenium2进行测试 我正在运行示例search-with-autocompletion测试,该测试在场景中使用@javascript标记 这是我得到的例外:

Behat\MinkExtension\Context\MinkContext::visit()
      'requiredCapabilities' parameter is not an object
      Build info: version: '3.5.3', revision: 'a88d25fe6b', time: '2017-08-29T12:54:15.039Z'
      System info: host: '73b4ecff4d3d', ip: '172.17.0.2', os.name: 'Linux', os.arch: 'amd64', os.version: '3.19.0-32-generic', java.version: '1.8.0_131'
      Driver info: driver.version: unknown
      remote stacktrace: stack backtrace:
         0:           0x5787ed - backtrace::backtrace::trace::h59229d13f6a8837d
         1:           0x578942 - backtrace::capture::Backtrace::new::h23089c033eded8f0
         2:           0x5068af - <webdriver::capabilities::LegacyNewSessionParameters as webdriver::command::Parameters>::from_json::hd98a6246b0731ef9
         3:           0x506e44 - <webdriver::command::NewSessionParameters as webdriver::command::Parameters>::from_json::ha19e8e984af08954
         4:           0x41f249 - <webdriver::command::WebDriverMessage<U>>::from_http::h239258e4ad67ac76
         5:           0x43a64e - <webdriver::server::HttpHandler<U> as hyper::server::Handler>::handle::hd20f6e9e0a69e2b4
         6:           0x42c9af - hyper::server::listener::spawn_with::{{closure}}::h8fa3cf343f537777
         7:           0x4092d7 - std::panicking::try::do_call::h649be53a713433eb
         8:           0x5dc20a - panic_unwind::__rust_maybe_catch_panic
                              at /checkout/src/libpanic_unwind/lib.rs:98
         9:           0x41c43e - <F as alloc::boxed::FnBox<A>>::call_box::hf41feb3b2b67541e
        10:           0x5d48a4 - alloc::boxed::{{impl}}::call_once<(),()>
                              at /checkout/src/liballoc/boxed.rs:650
                               - std::sys_common::thread::start_thread
                              at /checkout/src/libstd/sys_common/thread.rs:21
                               - std::sys::imp::thread::{{impl}}::new::thread_start
                              at /checkout/src/libstd/sys/unix/thread.rs:84

我使用docker-selenium和geckodriver v0.18运行Selenium2独立服务器v3.5.3。

我对Behat的配置:

default:
  context:
    class:  'FeatureContext'
  extensions:
    Behat\MinkExtension\Extension:
      base_url:  '<skipped>'
      goutte:
        guzzle_parameters:
               curl.options:
                  CURLOPT_SSL_VERIFYPEER: false
                  CURLOPT_CERTINFO: false
                  CURLOPT_TIMEOUT: 120
               ssl.certificate_authority: false
      selenium2:
        wd_host: "http://127.0.0.1:4444/wd/hub"
        capabilities:
            browser: firefox
#            acceptSslCerts: true
#            marionette: true

# No context:
no_context:
  paths:
    bootstrap: 'NON_EXISTING_FOLDER'
  filters:
    tags:      '~@javascript'

# Context based on inheritance:
inheritance:
  context:
    class:      'InheritedFeatureContext'

# Context based on traits:
traits:
  paths:
    bootstrap:  'features/php54_bootstrap'
  context:
    class:      'TraitedFeatureContext'

# Context based on subcontexting:
subcontexts:
  context:
    class:      'SubcontextedFeatureContext'

如果连接到localhost:4444,我可以手动创建会话 如果使用python-selenium,我可以运行此代码:

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

driver = webdriver.Remote(
           command_executor='http://127.0.0.1:4444/wd/hub',
              desired_capabilities=DesiredCapabilities.FIREFOX
        )

#driver = webdriver.Firefox()
driver.get("http://www.python.org")
assert "Python" in driver.title
elem = driver.find_element_by_name("q")
elem.clear()
elem.send_keys("pycon")
elem.send_keys(Keys.RETURN)
assert "No results found." not in driver.page_source
driver.close()

先谢谢大家。

1 个答案:

答案 0 :(得分:0)

硒2和硒3不相同。它们不是100%兼容。硒3是朝向硒的W3C标准迈出的一步。

从例外情况来看,Mink似乎与Selenium 3不兼容。所以要么将你的Python selenium版本降级为2(这也可能不起作用,因为最新的浏览器可能只支持3个)

另请查看https://github.com/minkphp/MinkSelenium2Driver/issues/254