简体   繁体   English

如何使用Ruby,Rspec,Capybara和Selenium在无头(Poltergeist)模式下运行TC?

[英]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.

相关问题 如果定义了Capybara Poltergeist驱动程序(对于Ruby),如何访问Selenium方法 - How to access Selenium methods if I defined Capybara Poltergeist driver (for Ruby) 无法以无头模式使用Firefox,Capybara和Docker运行Selenium - Not able to run selenium with firefox, Capybara and Docker in headless mode Poltergeist和RSpec的Capybara错误 - Capybara error with Poltergeist and RSpec 水豚Poltergeist和硒不同 - Capybara Poltergeist and Selenium different 如何使用Ruby + Rspec实时获取TC失败的原因(错误) - How to get the reason (error) of TC failure on fly using Ruby + Rspec 黄瓜水豚红宝石自动化中的无头模式 - Headless mode in cucumber capybara ruby automation 如何使用Poltergeist / Capybara / Rspec记录JavaScript错误? - How can I log javascript errors with Poltergeist/Capybara/Rspec? 如何在数字海洋飞沫上以无头模式运行用Ruby编写的selenium-webdriver脚本? - How can I run selenium-webdriver script written in Ruby in headless mode on digital-ocean droplet? 如何使用水豚和恶作剧检索innertext? - How to retrieve innertext using capybara and poltergeist? Capybara + Rspec:如何设置运行的多浏览器TC - Capybara + Rspec: How to set up multi browser TC running
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM