parent
c8706af307
commit
941c04e760
|
|
@ -0,0 +1,5 @@
|
|||
require 'selenium-cucumber'
|
||||
|
||||
# Do Not Remove This File
|
||||
# Add your custom steps here
|
||||
# $driver is instance of webdriver use this instance to write your custom code
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
require 'rubygems'
|
||||
require 'selenium-cucumber'
|
||||
|
||||
# Store command line arguments
|
||||
$browser_type = ENV['BROWSER'] || 'ff'
|
||||
$platform = ENV['PLATFORM'] || 'desktop'
|
||||
$os_version = ENV['OS_VERSION']
|
||||
$device_name = ENV['DEVICE_NAME']
|
||||
$udid = ENV['UDID']
|
||||
$app_path = ENV['APP_PATH']
|
||||
|
||||
# check for valid parameters
|
||||
validate_parameters $platform, $browser_type, $app_path
|
||||
|
||||
# If platform is android or ios create driver instance for mobile browser
|
||||
if $platform == 'android' or $platform == 'iOS'
|
||||
|
||||
if $browser_type == 'native'
|
||||
$browser_type = "Browser"
|
||||
end
|
||||
|
||||
if $platform == 'android'
|
||||
$device_name, $os_version = get_device_info
|
||||
end
|
||||
|
||||
desired_caps = {
|
||||
caps: {
|
||||
platformName: $platform,
|
||||
browserName: $browser_type,
|
||||
versionNumber: $os_version,
|
||||
deviceName: $device_name,
|
||||
udid: $udid,
|
||||
app: ".//#{$app_path}"
|
||||
},
|
||||
}
|
||||
|
||||
begin
|
||||
$driver = Appium::Driver.new(desired_caps).start_driver
|
||||
rescue Exception => e
|
||||
puts e.message
|
||||
Process.exit(0)
|
||||
end
|
||||
else # else create driver instance for desktop browser
|
||||
begin
|
||||
$driver = Selenium::WebDriver.for(:"#{$browser_type}")
|
||||
$driver.manage().window().maximize()
|
||||
rescue Exception => e
|
||||
puts e.message
|
||||
Process.exit(0)
|
||||
end
|
||||
end
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
#Cucumber provides a number of hooks which allow us to run blocks at various points in the Cucumber test cycle
|
||||
|
||||
Before do
|
||||
# Do something before each scenario.
|
||||
end
|
||||
|
||||
Before do |scenario|
|
||||
# The +scenario+ argument is optional, but if you use it, you can get the title,
|
||||
# description, or name (title + description) of the scenario that is about to be
|
||||
# executed.
|
||||
end
|
||||
|
||||
After do |scenario|
|
||||
# Do something after each scenario.
|
||||
# The +scenario+ argument is optional, but
|
||||
# if you use it, you can inspect status with
|
||||
# the #failed?, #passed? and #exception methods.
|
||||
|
||||
if(scenario.failed?)
|
||||
#Do something if scenario fails.
|
||||
end
|
||||
end
|
||||
|
||||
#Tagged hooks
|
||||
|
||||
Before('@Ex_tag1, @Ex_tag2') do
|
||||
# This will only run before scenarios tagged
|
||||
# with @Ex_tag1 OR @Ex_tag2.
|
||||
end
|
||||
|
||||
AfterStep('@Ex_tag1, @Ex_tag2') do |scenario|
|
||||
# This will only run after steps within scenarios tagged
|
||||
# with @Ex_tag1 AND @Ex_tag2.
|
||||
end
|
||||
|
||||
Around('@Ex_tag1') do |scenario, block|
|
||||
# Will round around a scenario
|
||||
end
|
||||
|
||||
AfterConfiguration do |config|
|
||||
# Will run after cucumber has been configured
|
||||
end
|
||||
|
||||
# Quit the selenium driver from the example tests.
|
||||
at_exit do
|
||||
|
||||
end
|
||||
Loading…
Reference in New Issue