I'm newbie on ruby language... Currently I am using POM (page objects model) with Selenium webdriver.

This is my throuble:

  • As I'm using selenium with POM, I have 3 classes (register.br, login.br and log_out.br) and in my main class im calling the objects and methods for execute the Test (test.br)

  • How each class has @driver=Selenium::WebDriver.for :firefox the problem is when I execute my main class (test.br), every class called with these @driver open a new browser...

My question is: How can I do for instantiate each class my selenium webdriver, realizing all the process just in one browser (the process is register, login and logout).

Currently the process is completed but in three firefox browsers and I need just all the process in the same browser..

PD: I used $driver=Selenium::WebDriver.for :firefox with the $ in the test.br class and called in every class with the require relativebut doesn't work

  • It's hard to know exactly what you're doing without seeing more of the code, but you shouldn't be creating a new driver in your page objects. That should be handled as part of your test logic, and then the driver is passed to or accessible to your page objects. While there is an argument for keeping selenium dependencies out of the test scripts, if that's your concern the solution would not be to create a new driver in all of your page objects. – mrfreester Sep 18 '17 at 16:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.