Reputation: 91
I use Capybara as a driver in my auto tests. I defined a driver as: Capybara.default_driver = :selenium But it is impossible to use Selenium methods in usual way (like: @driver.find_element(:xpath, ::Login_button).send_keys("MY_login")). I saw on some resources that it is possible to call Selenium methods using construction: page.driver.browser For instance: element = page.driver.browser.find_element(:id, ell). But error occurs that says that "page" is not defined method.
The question is how to use Selenium methods with defined Capybara driver?
May be it is necessary to define Capybara driver in another way in order to successfully use "page.driver.browser" construction? Please provide little instance to see full picture.
Upvotes: 1
Views: 704
Reputation: 49890
page
is just a convenience method in the Capybara DSL for Capybara.current_session
. You can use 'page' if you've included Capybara::DSL into the scope of your tests - see https://github.com/jnicklas/capybara#using-capybara-with-testunit
If you don't want to include the Capybara DSL into your tests you can also just use
Capybara.current_session.driver.browser ....
although accessing selenium methods directly should only be done when absolutely necessary and there isn't a cross driver way to do what you want provided by Capybara
Upvotes: 3