Here is the Ruby script of a locally-run test case for XXX Instant Messenger. The steps are: open a Chrome browser, user logs in, then logs out:
require "watir-webdriver"Note: Details of these functions are not included here:
require 'win32ole'
require Dir.pwd + "/lib/idp_FxnLib.rb"
rpt_CreateReport
browser1 = Watir::Browser.new :chrome
idp_Login browser1, $url_idp_login, $userid1, $passwd1, 0.70, 0.70, 0, 0
sleep 1
idp_FullnameDropdown_Logout browser1, $userid1; browser1.close
rpt_CloseReport
exit
rpt_CreatReport, idp_Login, idp_FullnameDropdown_Logout, rpt_CloseReport
The red-colored line will be replaced when the case is run on external clouds (see below).
Below is the same test case to be run on Testing Bot:
require "watir-webdriver"Below is the same test case to be run on Sauce Labs:
require 'win32ole'
require Dir.pwd + "/lib/idp_FxnLib.rb"
rpt_CreateReport
#browser1 = Watir::Browser.new :chrome
caps = Selenium::WebDriver::Remote::Capabilities.new
caps[:browserName] = "chrome"
caps[:version] = "57"
caps[:platform] = :WINDOWS
caps[:name] = "IDP_LoginLogout - " + Time.now.strftime("%Y%m%d-%H%M%S")
browser1 = Watir::Browser.new(
:remote,
:url => "http://user_key:user_secret@hub.testingbot.com/wd/hub",
:desired_capabilities => caps
)
idp_Login browser1, $url_idp_login, $userid1, $passwd1, 0.70, 0.70, 0, 0
sleep 1
idp_FullnameDropdown_Logout browser1, $userid1; browser1.close
rpt_CloseReport
exit
require "watir-webdriver"The blue-colored parts show the difference in scripts between the two clouds (which is little).
require 'win32ole'
require Dir.pwd + "/lib/idp_FxnLib.rb"
rpt_CreateReport
#browser1 = Watir::Browser.new :chrome
caps = Selenium::WebDriver::Remote::Capabilities.chrome
caps[:version] = "45"
caps.platform = "Windows 7"
caps[:name] = "IDP_LoginLogout - " + Time.now.strftime("%Y%m%d-%H%M%S")
browser1 = Watir::Browser.new(
:remote,
:url => "http://user_name:access_key@ondemand.saucelabs.com:80/wd/hub",
:desired_capabilities => caps
)
idp_Login browser1, $url_idp_login, $userid1, $passwd1, 0.70, 0.70, 0, 0
sleep 1
idp_FullnameDropdown_Logout browser1, $userid1; browser1.close
rpt_CloseReport
exit
The values of parameters user_key, user_secret, user_name, access_key need to match the real ones of user setting on these clouds respectively.
The test case is executed the same way as it would locally, which is usually:
ruby <testcase_name>.rb
Nothing esle needs to be changed.
Screen shots from Testing Bot:


Screen shots from Sauce Labs:


No comments:
Post a Comment