简体   繁体   中英

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.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. So question is how to access Selenium methods if I defined Capybara Poltergeist driver as follow:

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. 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. What selenium specific methods are you trying to use?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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