简体   繁体   English

如果定义了Capybara Poltergeist驱动程序(对于Ruby),如何访问Selenium方法

[英]How to access Selenium methods if I defined Capybara Poltergeist driver (for Ruby)

I use " Capybara.current_session.driver " to access Selenium methods when I defined driver as follow: 当我如下定义驱动程序时,我使用“ Capybara.current_session.driver ”来访问Selenium方法:

Capybara.default_driver = :selenium

But when I run my TC (Capybara + Selenium) in headless mode I see that TC are failed due to undefined Selenium methods. 但是,当我以无头模式运行TC(水豚+硒)时,我发现TC因未定义的Selenium方法而失败。 So question is how to access Selenium methods if I defined Capybara Poltergeist driver as follow: 因此,如果我按如下方式定义Capybara Poltergeist驱动程序,那么问题是如何访问Selenium方法:

require 'capybara/poltergeist'
    Capybara.default_driver = :poltergeist
    Capybara.javascript_driver = :poltergeist
    Capybara.current_driver = :poltergeist

    Capybara.register_driver :poltergeist do |app|
      Capybara::Poltergeist::Driver.new(app,
      :js_errors => false,
      :phantomjs_options => ['--ignore-ssl-errors=yes'],
      :phantomjs_logger => File.open("F:/Programming/VLoop/Project/28.05.2016/webapp/log/test_phantomjs.log", 'w+')
      )
    end

You can't use selenium methods when you're using the poltergeist driver, they are only available when your session is using the selenium driver. 使用poltergeist驱动程序时,不能使用selenium方法,它们仅在会话使用selenium驱动程序时可用。 Thats why it's not recommended to call specific methods directly on the drivers, and instead use the API provided by Capybara so that your tests remain compatible with multiple drivers. 这就是为什么不建议直接在驱动程序上调用特定方法,而是使用Capybara提供的API来使您的测试与多个驱动程序兼容的原因。 What selenium specific methods are you trying to use? 您尝试使用哪些特定于硒的方法?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM