[英]How to run TC in headless (Poltergeist) mode using Ruby, Rspec, Capybara and Selenium?
The problem is that I've tried a lot of variants to declare Capybara Poltergeist driver. 问题是我尝试了很多变体来声明Capybara Poltergeist驱动程序。 But alway get some problems. 但是总会遇到一些问题。
For instance, when I declare driver as following: 例如,当我声明驱动程序如下:
Capybara::Poltergeist::Driver.new({
js_errors: true,
inspector: true,
phantomjs_options: ['--load-images=no', '--ignore-ssl-errors=yes'],
timeout: 120
})
TC are ran in FF browser instead of poltergeist((( TC在FF浏览器中运行,而不是poltergeist(((
or, if I declare driver as following: 或者,如果我声明驱动程序如下:
Capybara.default_driver = :poltergeist
Capybara.current_driver = :poltergeist
Capybara.javascript_driver = :poltergeist
I see such error: C:/Ruby22-x64/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:121:in `require': cannot load such file -- support/controllers_helpers (LoadError). 我看到这样的错误:C:/Ruby22-x64/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:121:在'require'中:无法加载这样的文件-support / controllers_helpers(LoadError)。
Also I need to use Selenium and Capybara methods, therefore I declared following variable to be able to use selenium methods: @driver = Capybara.current_session.driver.browser 另外,我需要使用Selenium和Capybara方法,因此我声明了以下变量才能使用selenium方法:@driver = Capybara.current_session.driver.browser
So, the question is how to declare Capybara headless driver (with debugging opportunity if possible) with the opportunity to use Selenium methods (my @driver variable)? 那么,问题是如何声明有机会使用Selenium方法(我的@driver变量)的Capybara无头驱动程序(如果可能,则有调试机会)? enter code here
You can't use the poltergeist driver and use selenium methods -- The selenium specific methods are only available when using the selenium driver. 您不能使用poltergeist驱动程序并使用硒方法-特定于硒的方法仅在使用硒驱动程序时可用。
For your issue of declaring a driver: Declaring/Configuring a driver (using Capybara.register_driver) just names the driver - then you still have to specify to use it (via the name you specified in register_driver) with Capybara.default_driver, current_driver, or javascript_driver - depending on exactly what you're setting up. 对于声明驱动程序的问题:声明/配置驱动程序(使用Capybara.register_driver)只是命名驱动程序-然后,您仍然必须指定(通过register_driver中指定的名称)将其与Capybara.default_driver,current_driver或javascript_driver-取决于您要进行的设置。
I think you really need to think through what you're trying to do and then explain it to us in more detail. 我认为您确实需要仔细考虑您要做什么,然后再向我们详细说明。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.