applenium 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/applenium/methods/error_handling_methods.rb +87 -0
- data/lib/applenium/methods/misc_methods.rb +33 -0
- data/lib/applenium/methods/required_files.rb +2 -1
- data/lib/applenium/methods/web_methods.rb +35 -0
- data/lib/applenium/version.rb +1 -1
- metadata +3 -2
- data/lib/applenium/methods/error.rb +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2069cc18508e87fdf6cd4383d2774f3256c62795
|
4
|
+
data.tar.gz: bc2e8bae206aeb8c2ce6c29a41078d16752fd208
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e4a957b0a77bb6c109675a45d05ed521bda58b8aeb3e736b9640432dfb456d8de60338e423ce0ac2638241697ab830af3b0f3c2e4fb45a8f1fdd2638d2a0b8c
|
7
|
+
data.tar.gz: c3e1deaa1aa4d740fa74b76877edafa9cf2720370fa23de92d7653a534055204c3154a46f6f6ada55dc10ef980ac0de87a1682efaf0c5d23da7d1d92c64a125a
|
@@ -0,0 +1,87 @@
|
|
1
|
+
# Error handling methods
|
2
|
+
|
3
|
+
# Method to check browser type
|
4
|
+
def validate_parameters(platform, browser_type, app_path)
|
5
|
+
if platform == 'desktop'
|
6
|
+
if !%w(ff ie chrome safari opera).include? browser_type
|
7
|
+
print_error_desktop
|
8
|
+
end
|
9
|
+
elsif platform == 'android'
|
10
|
+
print_error_android browser_type, app_path
|
11
|
+
elsif platform == 'iOS'
|
12
|
+
puts "Not Implemented..."
|
13
|
+
# print_error_ios browser_type, app_path
|
14
|
+
else
|
15
|
+
print_invalid_platform
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
# print error for desktop
|
20
|
+
def print_error_desktop
|
21
|
+
puts "\nInappropraite desktop browser : \"#{ENV['BROWSER']}\""
|
22
|
+
puts "\nUsage : cucumber BROWSER=browser_name"
|
23
|
+
puts "\nBrowser Supported :\n"
|
24
|
+
puts "\n1.ie\n2.chrome\n3.ff\n4.safari\n5.opera"
|
25
|
+
Process.exit(0)
|
26
|
+
end
|
27
|
+
|
28
|
+
# print error for android
|
29
|
+
def print_error_android(browser_type, app_path)
|
30
|
+
if browser_type=='ff' and app_path==nil
|
31
|
+
puts "\nOops... not mentioned \"Browser\" or \"App path\""
|
32
|
+
print_error_android_app
|
33
|
+
print_error_android_web
|
34
|
+
Process.exit(0)
|
35
|
+
elsif browser_type!='ff' and !%w(native chrome).include? browser_type
|
36
|
+
puts "\nOops... not supported browser"
|
37
|
+
print_error_android_web
|
38
|
+
Process.exit(0)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
# print error for android app
|
43
|
+
def print_error_android_app
|
44
|
+
puts "\nTo run test on android app"
|
45
|
+
puts "\n Usage : cucumber PLATFORM=android APP_PATH=path/to/app"
|
46
|
+
end
|
47
|
+
|
48
|
+
# print error for android web
|
49
|
+
def print_error_android_web
|
50
|
+
puts "\nTo run test on android mobile web"
|
51
|
+
puts "\n Usage : cucumber PLATFORM=android BROWSER=browser_name"
|
52
|
+
puts "\n Supported browsers are \"chrome\" and \"native\""
|
53
|
+
end
|
54
|
+
|
55
|
+
# print error for ios
|
56
|
+
def print_error_ios
|
57
|
+
if browser_type=='ff' and app_path==nil
|
58
|
+
puts "\nOops... not mentioned \"Browser\" or \"App path\""
|
59
|
+
print_error_ios_app
|
60
|
+
print_error_ios_web
|
61
|
+
Process.exit(0)
|
62
|
+
elsif browser_type!='safari'
|
63
|
+
puts "\nOops... not supported browser"
|
64
|
+
print_error_ios_app_web
|
65
|
+
Process.exit(0)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
# print error for ios app
|
70
|
+
def print_error_ios_app
|
71
|
+
puts "\nTo run test on iOS App"
|
72
|
+
puts "\n Usage : cucumber PLATFORM=iOS APP_PATH=path/to/app"
|
73
|
+
end
|
74
|
+
|
75
|
+
# print error for ios web
|
76
|
+
def print_error_ios_web
|
77
|
+
puts "\nTo run test on iOS mobile web"
|
78
|
+
puts "\n Usage : cucumber PLATFORM=iOS BROWSER=safari"
|
79
|
+
end
|
80
|
+
|
81
|
+
# print error if invalid platform
|
82
|
+
def print_invalid_platform
|
83
|
+
puts "\nOops... Invalid Platform"
|
84
|
+
puts "\nSupported platform are \"android\" and \"iOS\"."
|
85
|
+
puts "\nTo run on Desktop no need to mention platform."
|
86
|
+
Process.exit(0)
|
87
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# custome exception class
|
2
|
+
class TestCaseFailed < Exception
|
3
|
+
end
|
4
|
+
|
5
|
+
# WAIT instance for explicit wait
|
6
|
+
WAIT = Selenium::WebDriver::Wait.new(:timeout => 30)
|
7
|
+
|
8
|
+
# method to validate locator
|
9
|
+
def valid_locator_type? type
|
10
|
+
%w(id class css name xpath).include? type
|
11
|
+
end
|
12
|
+
|
13
|
+
def validate_locator type
|
14
|
+
raise "Invalid locator type - #{type}" unless valid_locator_type? type
|
15
|
+
end
|
16
|
+
|
17
|
+
# method to validate dropdown selector
|
18
|
+
def valid_option_by? option_by
|
19
|
+
%w(text value index).include? option_by
|
20
|
+
end
|
21
|
+
|
22
|
+
def validate_option_by option_by
|
23
|
+
raise "Invalid option by - #{option_by}" unless valid_option_by? option_by
|
24
|
+
end
|
25
|
+
|
26
|
+
# Return android device name and android version using adb command
|
27
|
+
def get_device_info
|
28
|
+
IO.popen('adb shell getprop ro.product.brand') { |f| $device = f.gets.chomp.upcase}
|
29
|
+
$device += ' '
|
30
|
+
IO.popen('adb shell getprop ro.product.model') { |f| $device += f.gets.chomp.upcase}
|
31
|
+
IO.popen('adb shell getprop ro.build.version.release') { |f| $os_version = f.gets.chomp.upcase}
|
32
|
+
return $device, $os_version
|
33
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'net/https'
|
2
|
+
require_relative 'required_files'
|
3
|
+
|
4
|
+
|
5
|
+
def visit(page)
|
6
|
+
$driver.get(page)
|
7
|
+
end
|
8
|
+
|
9
|
+
def click(locator_type, locator_name)
|
10
|
+
WAIT.until { $driver.find_element(:"#{locator_type}" => "#{locator_name}") }.click
|
11
|
+
end
|
12
|
+
|
13
|
+
def displayed(locator_type, locator_name)
|
14
|
+
WAIT.until{ $driver.find_element(:"#{locator_type}" => "#{locator_name}") }.displayed?
|
15
|
+
end
|
16
|
+
|
17
|
+
# method to validate dropdown selector
|
18
|
+
|
19
|
+
def check_element_on_page(locator_type, locator_name, scenario)
|
20
|
+
if scenario
|
21
|
+
if !displayed(locator_type, locator_name)
|
22
|
+
raise Failure, 'Element Not Present'
|
23
|
+
end
|
24
|
+
else
|
25
|
+
begin
|
26
|
+
if displayed(locator_type, locator_name)
|
27
|
+
raise 'Present'
|
28
|
+
end
|
29
|
+
rescue Exception => e
|
30
|
+
if e.message == 'Present'
|
31
|
+
raise Failure, 'Element Present'
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/lib/applenium/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: applenium
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shashikant86
|
@@ -82,7 +82,8 @@ files:
|
|
82
82
|
- bin/helper.rb
|
83
83
|
- lib/applenium.rb
|
84
84
|
- lib/applenium/applenium_steps.rb
|
85
|
-
- lib/applenium/methods/
|
85
|
+
- lib/applenium/methods/error_handling_methods.rb
|
86
|
+
- lib/applenium/methods/misc_methods.rb
|
86
87
|
- lib/applenium/methods/required_files.rb
|
87
88
|
- lib/applenium/methods/web_methods.rb
|
88
89
|
- lib/applenium/version.rb
|
File without changes
|