Running Automated Web Test On External Clouds

There are test automation vendors who provide cloud based platforms allowing automated tests to be run externally, with some handy extras such as logs, screen shots, video recordings, etc. along with flexible configurations such as the choice of different browsers (Chrome, FireFox, IE, Safari) and, for the same browser, choice on different versions. This makes cross-browser and cross-version testing a lot easier.

The following example shows how to run originally local automated web test on external clouds: Testing Bot and Sauce Labs.

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"
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
Note: Details of these functions are not included here:
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"
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
Below is the same test case to be run on Sauce Labs:
require "watir-webdriver"
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 blue-colored parts show the difference in scripts between the two clouds (which is little).

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:

Followers

About Xman

Basking Ridge, New Jersey, United States