vendredi 9 mars 2018

Ruby Watir - How do I call Page Objects in Test scripts?

I am wondering how I call page objects from the page object class into my test class from a different directory? New to ruby! In java I would just import the class at the top of the class file and that would allow me to access the methods and objects from that class file in a different folder/package. My Directory structure is like so below:

enter image description here

I want to be able to access the page objects in the page object class to use in my A_Test class. How do I achieve this?

page_object.rb code:

require 'rubygems'
require 'cucumber'
require 'watir'
require 'page-object'
require 'test/unit/assertions'
include Test::Unit::Assertions

class screen
    include PageObject
    radio_button(:yes, id: '')
    radio_button(:no, id: '')
    button(:next_button, id: '')
    link(:back, :text => "")
end 

A_test.rb code:

require 'rubygems'
require 'cucumber'
require 'page-object'
require 'watir'
require 'date'

Given(/^$/) do |no|

   screen.next_button.click

end 

Aucun commentaire:

Enregistrer un commentaire