Automation of tests with selenium cucumber and capybara

2

I'm starting to learn how to use a means for automating testing in web applications. However, I came across a problem that I can not solve and found nowhere (questions or documentation) that would explain a method that would solve my problem.

Well, firstly I'm using selenium + cucumber + capybara (in ruby) and basically I'd like to be able to perform tests on the chrome browser with mobile emulation and what keeps me from this is that with my settings inside env .rb when I run the cucumber is opened a chrome window with the url "data;" and then another window is created where my script runs normally (I noticed that this does not only happen with the chrome webdriver but with selenium and the IE driver too).

So, when the chrome capabilities to run on mobile these conditions only apply to the first window so running my script only in the secondary that remains normal.

Basically, my configuration looks like this:

require 'rubygems'
require 'capybara/cucumber'
require 'selenium/webdriver'

#Retirando esse register e o default driver eu recebo erro de "rack test requires a rack application"
  Capybara.register_driver :chrome do |app|
    Capybara::Selenium::Driver.new(app, :browser => :chrome)
  end

  Capybara.default_driver = :chrome

  mobile_emulation = { "deviceName" => "Google Nexus 5" }
  caps = Selenium::WebDriver::Remote::Capabilities.chrome("chromeOptions" => { "mobileEmulation" => mobile_emulation })
  driver = Selenium::WebDriver.for :chrome,  :url => "http://localhost:4444/wd/hub", :desired_capabilities => caps

Running with this code inside env.rb will probably duplicate the windows. I also noticed that without the line " driver = Selenium::WebDriver.for :chrome ... " the browser does not duplicate, but does not set the mobile settings that I would need. Thanks in advance.

    
asked by anonymous 18.09.2016 / 06:17

0 answers