I have setup a project in RubyMine using Ruby with Cucumber, RSPEC, and Watir for UI automation of feature files. (I also have page objects implemented). In my step_definitions where the actual UI automation steps occur, I want to programatically run queries against SQL Developer to validate changes upon test completion (basic queries) and also run other updates, as needed. I would then add expect/asserts using values on UI and values from tables.

So far I have successfully setup database connections following the instructions here but this operates as a separate window for connecting and running sql commands outside of my Watir tests. But what I am having trouble doing is calling this connection from within my actual tests within the step_definitions (perhaps setting up the basic connections from within an env.rb file. I have also looked into oci8 but have had trouble actually implementing this, so I am wondering if anyone can help with suggestions on pulling in database connections to Ruby/Watir code as part of the end-to-end UI automation scripts.

Example test case in RubyMine:

Given(/^a user goes to the main login page$/) do

  @login_page = LoginPage.new(@browser)

  @login_page.visit_new_site # Using page object

When(/^they enter an ID and password$/) do



Then(/^New web page should allow user to click Log In$/) do


  # I want to call database connection here to validate login message from table, for example
  • 1
    You'll probably get a better answer if you update your question to show your code and whatever errors you are getting - that way the ruby experts here will have a better idea of how to help you.
    – Kate Paulk
    Oct 8, 2019 at 19:42
  • Hi Kate, the issue is that I have yet to actually implement this so there is not much to add here. I have added 'oci8' to my gemfile, in addition to 'watir','ffi','cucumber','page-object','rspec'. But my question is around how to then integrate database connectivity using oci8 or some other means. Hope this helps.
    – RGreg
    Oct 9, 2019 at 16:32


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.