Are you an expert in Gauge, the BDD framework? ( See a Brief Overview of Gauge ).
I was planning on working towards what Dave Haeffner has in ElementalSelenium.com creating a library of:
- Using Base Page Objects to wrap Selenium Ruby calls with proper waits.
- Using Page Objects, so that when locators inevitably change, I know where exactly to fix them.
- Making the tests data-driven
- Adding Rescue exceptions to avoid weeding through Stack traces.
- Maybe JQuery Growl for better logging, and Wrapped Selenium Tests
It looks like Gauge strongly advocates against page objects calling them an Anti-Pattern. Er... Um... burying a page's locators in code, as they do in the blog makes me worried. I am looking for other solutions.
I created a little project that I called: gauge-selenium-ruby-first-draft. (View it on GitHub!). It contains:
- default properties: Points to where the reports and logs are, chooses Chrome to be the default browser, and chooses whether or not you should overwrite reports, capture screenshots on failure, enable multithreading. You can also choose when you want the objects to be cleatred... after execution of suite, spec, or scenario.
- user properties: Points to the APP_URL, and chooses if you want the tests to be headless or not.
- UserAction.spec: Heavily ripped off of the Gauge sample project, ruby-selenium, this is the "executable specification file. This file follows markdown syntax. Every heading in this file denotes a scenario. Every bulleted point denotes a step". Contains "Login as username and ", "Check if the user is logged in" and "Log out". Also contains a data table for username and passwords.
- concepts/Authentication.cpt: Specs can refer to these concepts, "Check if the user is logged in" and "Log out", breaking them down.
- authentication.rb: Contains the selenium-ruby code that acts out the steps "Give an option to Log Out", 'Give an option to Log In' and a logout method.
- user_login: Contains the step "Login as username and ", which uses selenium-ruby to send text to the username and password textbox, and presses the Login button.
- driver.rb: Contains the setup and teardown methods, creating the driver and quitting the driver. Also sets up the driver with:
options = Selenium::WebDriver::Chrome::Options.new
@@driver = Selenium::WebDriver.for :chrome, options: options
- find_message: Any messages that you need to check for? There is this method that Gauge's ruby-selenium has, "Show a message ".
- screengrabber.rb: Provides a wrapper for driver.save_screenshot('/tmp/screenshot.png')
- site_launcher: Contains the step "Navigate to the login page", which then does:
Examine the code I hacked together at https://github.com/tjmaher/gauge-selenium-ruby-first-draft, based on the ruby-selenium sample project.
assert_equal 'The Internet', driver.title
Sr. QA Engineer, Software Engineer in Test
Meetup Organizer, Ministry of Testing - Boston
Twitter | YouTube | LinkedIn | Articles