class SiteContext
class Configuration
# attr_accessor :stage, :prod, :ignored, :DESKTOP def initialize @stage = "https://rialto-stage.equiem.com.au" @prod = "https://atrialto.com" @ignored = ["ignore_me", "not_important_url_prefix",".css", ".pdf", ".js", ".jpg", ".png", "video/pop", "user/logout", "?", "=", "#"] @SCREEN_RESOLUTION = {:desktop => [1400,800], :mobile => [300,150]} @IMAGE_THRESHOLD = 0 @LOGIN = true @LOGIN_URI = 'login' # http://example.com/login @USER_DOM_ID = 'edit-name' @USER_VALUE = 'melchisalins' @PASS_DOM_ID = 'edit-pass' @PASS_VALUE = 'secret_password' @LOGIN_CONFIRM = true @LOGIN_CONFIRM_CHECK = 'homepage-onsite-team' end
end
Constants
- LOGGED_IN
Attributes
driver[RW]
Public Class Methods
new()
click to toggle source
# File lib/site_context.rb, line 34 def initialize puts "SiteContext initializes!" end
Public Instance Methods
login_to_as(site, driver)
click to toggle source
# File lib/site_context.rb, line 44 def login_to_as(site, driver) $config.LOGGED_IN = true driver.get(site + $config.LOGIN_URI) username = driver.find_element(:id, $config.USER_DOM_ID) username.clear username.send_keys($config.USER_VALUE) password = driver.find_element(:id, $config.PASS_DOM_ID) password.clear password.send_keys($config.PASS_VALUE+"\n") if "Terms and Conditions".include?(driver.title) driver.find_element(:id, "edit-legal-accept").click driver.find_element(:id, "edit-save").click end if driver.find_element(:class, $config.LOGIN_CONFIRM_CHECK) != nil return true else return false end end
set_driver(browser = :chrome, remote = "http://192.168.15.43:4444/wd/hub/")
click to toggle source
# File lib/site_context.rb, line 38 def set_driver(browser = :chrome, remote = "http://192.168.15.43:4444/wd/hub/") # driver = Selenium::WebDriver.for(:remote, :url => remote, :desired_capabilities => browser) driver = Selenium::WebDriver.for :firefox return driver end