itms_automation 2.6.7 → 2.7.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/doc/installation.md +1 -1
  3. data/features-skeleton/my_first.feature +19 -10
  4. data/features-skeleton/step_definitions/input_steps.rb +3 -3
  5. data/features-skeleton/step_definitions/my_first_steps.rb +14 -0
  6. data/features-skeleton/step_definitions/repositories/project_object.yml +1 -1
  7. data/features-skeleton/support/env.rb +17 -88
  8. data/lib/itms_automation/input_steps.rb +1 -1
  9. data/lib/itms_automation/methods/assertion_methods.rb +159 -174
  10. data/lib/itms_automation/methods/click_elements_methods.rb +13 -6
  11. data/lib/itms_automation/methods/condition_methods.rb +13 -0
  12. data/lib/itms_automation/methods/configuration_methods.rb +14 -7
  13. data/lib/itms_automation/methods/input_methods.rb +58 -15
  14. data/lib/itms_automation/methods/javascript_handling_methods.rb +1 -1
  15. data/lib/itms_automation/methods/misc_methods.rb +1 -2
  16. data/lib/itms_automation/methods/navigate_methods.rb +52 -45
  17. data/lib/itms_automation/methods/progress_methods.rb +73 -6
  18. data/lib/itms_automation/methods/store_methods.rb +36 -0
  19. data/lib/itms_automation/version.rb +1 -1
  20. metadata +40 -40
  21. data/example/android/android_app/android_app_calculator.zip +0 -0
  22. data/example/android/android_app/android_app_calculator/AndroidCalculator.apk +0 -0
  23. data/example/android/android_app/android_app_calculator/features/calculator.feature +0 -36
  24. data/example/android/android_app/android_app_calculator/features/my_first.feature +0 -13
  25. data/example/android/android_app/android_app_calculator/features/screenshots/test.png +0 -0
  26. data/example/android/android_app/android_app_calculator/features/step_definitions/custom_steps.rb +0 -5
  27. data/example/android/android_app/android_app_calculator/features/support/env.rb +0 -52
  28. data/example/android/android_app/android_app_calculator/features/support/hooks.rb +0 -26
  29. data/example/android/android_web/android_web_gmail_login.zip +0 -0
  30. data/example/android/android_web/android_web_gmail_login/features/gmail_login.feature +0 -12
  31. data/example/android/android_web/android_web_gmail_login/features/my_first.feature +0 -1
  32. data/example/android/android_web/android_web_gmail_login/features/screenshots/test.png +0 -0
  33. data/example/android/android_web/android_web_gmail_login/features/step_definitions/custom_steps.rb +0 -5
  34. data/example/android/android_web/android_web_gmail_login/features/support/env.rb +0 -51
  35. data/example/android/android_web/android_web_gmail_login/features/support/hooks.rb +0 -27
  36. data/example/desktop web/desktop_web_gmail_login.zip +0 -0
  37. data/example/desktop web/desktop_web_gmail_login/features/gmail_login.feature +0 -9
  38. data/example/desktop web/desktop_web_gmail_login/features/gmail_multi_login.feature +0 -21
  39. data/example/desktop web/desktop_web_gmail_login/features/my_first.feature +0 -1
  40. data/example/desktop web/desktop_web_gmail_login/features/screenshots/test.png +0 -0
  41. data/example/desktop web/desktop_web_gmail_login/features/step_definitions/custom_steps.rb +0 -5
  42. data/example/desktop web/desktop_web_gmail_login/features/support/env.rb +0 -106
  43. data/example/desktop web/desktop_web_gmail_login/features/support/hooks.rb +0 -38
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d444bed9e0cfd7a8c172326b6fb3ec89e6c7b1e35caa8937dbb08d5e2c642bbc
4
- data.tar.gz: 0c744a217e2790acf13691eaf2d219172863e110b2a81877feb59b8b17903714
3
+ metadata.gz: 8113d92ae42388d312d06addf7983729e8c339394101e42e5bf7696b157159ba
4
+ data.tar.gz: 99c7336da205831dad925b554d538992031423b5d712c10722482708ad96075b
5
5
  SHA512:
6
- metadata.gz: a6620750cdedf9b304e4ea53ebda419b5ac383f6999261b9c7acee0d44921d50a3e1ddc31b841aa4b54abf2860b1bbdb3bfb2aa5b6d39ec989bfd2eee8024cbc
7
- data.tar.gz: c7673be15169b7371e41bcb15572f042b2a70a4aa1732fdd776fd1f49c7ff1aa8608fd18cce5eb74b654f2a152580e06913625165170fbdc93906a994f269c73
6
+ metadata.gz: f5705b378186e404e89587da1b64d5b05dedbd3289120b73a209daef2598c2b5d4ce6055b007654be5fa38255ea098a6f145fa7bc4703c8846bd4cd3cbbf2099
7
+ data.tar.gz: 6d8065f8be72393b605c9135c923a259fcbbdeab9e1fec1b71bd0a4137a9cdca846cbfa63b81526679bd9349e5cffb26b28e57c79125e0ac47c5cae5ee836f7f
data/doc/installation.md CHANGED
@@ -2,7 +2,7 @@ Installation
2
2
  ============
3
3
  ### Prerequisites
4
4
  You need to have Ruby installed.
5
- Verify your installation by running ruby -v in a terminal - it should print "ruby 1.9.3" (or higher).
5
+ Verify your installation by running ruby -v in a terminal - it should print "ruby 2.0.0" (or higher).
6
6
 
7
7
  You need to have DevKit installed.
8
8
 
@@ -1,10 +1,19 @@
1
- # Feature: Addition
2
- # As a math idiot
3
- # In order to not feel silly
4
- # I add two numbers
5
-
6
- # Scenario: Adding a and b
7
- # Given I have variable a
8
- # And I have variable b
9
- # When I add a and b
10
- # Then I display the sum
1
+ # Feature: Login Functionality
2
+ # In order to ensure login functionality works,
3
+ # I want to run the cucumber test to verify it is working
4
+
5
+ # Background:
6
+ # Given the login page is opened successfully
7
+
8
+ # Scenario: Login Valid
9
+ # When user input username "tomsmith" and password "SuperSecretPassword!"
10
+ # Then the message "You logged into a secure area!×" should be displayed
11
+
12
+ # Scenario Outline: Login Invalid
13
+ # When user input username "<username>" and password "<password>"
14
+ # Then the message "<messsage>" should be displayed
15
+
16
+ # Examples:
17
+ # | username | password | messsage |
18
+ # | anhpham | SuperSecretPassword! | Your username is invalid!× |
19
+ # | tomsmith | wrong_password | Your password is invalid!× |
@@ -4,12 +4,12 @@
4
4
 
5
5
  # # enter text into input field steps
6
6
  # Then(/^I enter "([^\"]*)" into element "(.*?)"$/) do |text, element|
7
- # enter_text(type, element)
7
+ # enter_text(element, text)
8
8
  # end
9
9
 
10
10
  # # clear input field steps
11
- # Then(/^I clear input element "(.*?)"$/) do |type, element|
12
- # clear_text(type, element)
11
+ # Then(/^I clear input element "(.*?)"$/) do |element|
12
+ # clear_text(element)
13
13
  # end
14
14
 
15
15
  # # select option by text/value from dropdown/multiselect
@@ -0,0 +1,14 @@
1
+ # Given('the login page is opened successfully') do
2
+ # $driver.get("http://the-internet.herokuapp.com/login")
3
+ # end
4
+
5
+ # When('user input username {string} and password {string}') do |string, string2|
6
+ # $driver.find_element(:id, 'username').send_keys(string)
7
+ # $driver.find_element(:id, 'password').send_keys(string2)
8
+ # $driver.find_element(:css, '[class="fa fa-2x fa-sign-in"]').click
9
+ # end
10
+
11
+ # Then('the message {string} should be displayed') do |string|
12
+ # message = $driver.find_element(:css, '#flash').text.delete("\n")
13
+ # expect(message).to eql(string)
14
+ # end
@@ -1 +1 @@
1
- button: { id: 'submit' }
1
+ test_object: {id: 'username'}
@@ -1,78 +1,14 @@
1
1
  require "rubygems"
2
2
  require "itms_automation"
3
3
  require "httparty"
4
- require "cucumber"
5
4
  require "report_builder"
6
- require "selenium-webdriver"
5
+ require "webdrivers"
7
6
 
8
7
  $browser_type = ENV["BROWSER"] || "firefox"
9
- $platform = ENV["PLATFORM"] || "desktop"
10
- $os_version = ENV["OS_VERSION"]
11
- $device_name = ENV["DEVICE_NAME"]
12
- $udid = ENV["UDID"]
13
- $app_path = ENV["APP_PATH"]
14
8
 
15
- # check for valid parameters
16
- validate_parameters $platform, $browser_type, $app_path
17
-
18
- # If platform is android or ios create driver instance for mobile browser
19
- if $platform == "android" or $platform == "iOS"
20
- if $browser_type == "native"
21
- $browser_type = "Browser"
22
- end
23
-
24
- if $platform == "android"
25
- $device_name, $os_version = get_device_info
26
- end
27
-
28
- # desired_caps = {
29
- # caps: {
30
- # platformName: $platform,
31
- # browserName: $browser_type,
32
- # versionNumber: $os_version,
33
- # deviceName: $device_name,
34
- # udid: $udid,
35
- # app: ".//#{$app_path}"
36
- # }
37
- # }
38
- # appium_url = 'http://localhost:4723/wd/hub'
39
- # opts = {
40
- # desired_capabilities: { # or { caps: {....} }
41
- # platformName: :android,
42
- # deviceName: 'Android Simulator',
43
- # app: "WikipediaSample.apk"
44
- # },
45
- # appium_lib: {
46
- # wait: 30
47
- # }
48
- # }
49
-
50
- opts = {
51
- desired_capabilities: { # or { caps: {....} }
52
- platformName: $platform,
53
- browserName: $browser_type,
54
- deviceName: $device_name,
55
- versionNumber: $os_version,
56
- app: "WikipediaSample.apk",
57
- },
58
- appium_lib: {
59
- wait: 30,
60
- },
61
- }
62
-
63
- begin
64
- # $driver = Appium::Driver.new(desired_caps, url: appium_url).start_driver
65
-
66
- # $driver = Selenium::WebDriver.for(:remote, :url => appium_url, :desired_capabilities => desired_caps)
67
- @core = Appium::Core.for(opts) # create a core driver with `opts`
68
- $driver = @core.start_driver
69
- rescue Exception => e
70
- puts e.message
71
- Process.exit(0)
72
- end
73
- else # else create driver instance for desktop browser
74
- begin
75
- $driver = case $browser_type
9
+ begin
10
+ $vars = {}
11
+ $driver = case $browser_type
76
12
  when "chrome"
77
13
  Selenium::WebDriver.for(:chrome)
78
14
  when "safari"
@@ -82,29 +18,22 @@ else # else create driver instance for desktop browser
82
18
  when "chrome_headless"
83
19
  Selenium::WebDriver.for(:chrome, :desired_capabilities => Selenium::WebDriver::Remote::Capabilities.chrome(chromeOptions: { args: %w(headless) }))
84
20
  when "remote"
85
- if ENV["SERVER_URL"].nil? || ENV["REMOTE_BROWSER"].nil?
86
- puts "\nMissing SERVER_URL : SERVER_URL=http://SERVER_URL:4444/wd/hub"
21
+ if ENV['SERVER_URL'].nil? || ENV['REMOTE_BROWSER'].nil?
22
+ puts "\nMissing SERVER_URL : SERVER_URL=http//SERVER_URL:4444/wd/hub"
87
23
  puts "\nMissing REMOTE_BROWSER: REMOTE_BROWSER=browser_name"
88
24
  Process.exit(0)
89
25
  else
90
- if ENV['SERVER_URL'].nil? || ENV['REMOTE_BROWSER'].nil?
91
- puts "\nMissing SERVER_URL : SERVER_URL=http//SERVER_URL:4444/wd/hub"
92
- puts "\nMissing REMOTE_BROWSER: REMOTE_BROWSER=browser_name"
93
- Process.exit(0)
94
- else
95
- caps = Selenium::WebDriver::Remote::Capabilities.new
96
- caps["browserName"] = ENV["REMOTE_BROWSER"]
97
- caps["enableVNC"] = true
98
- caps["enableVideo"] = true
99
- caps["resolution"] = ENV["resolution"] unless ENV["resolution"]
100
- Selenium::WebDriver.for(:remote, :url => ENV["SERVER_URL"], :desired_capabilities => caps)
26
+ caps = Selenium::WebDriver::Remote::Capabilities.new
27
+ caps["browserName"] = ENV["REMOTE_BROWSER"]
28
+ caps["enableVNC"] = false
29
+ caps["enableVideo"] = false
30
+ caps["resolution"] = ENV["resolution"] unless ENV["resolution"]
31
+ Selenium::WebDriver.for(:remote, :url => ENV["SERVER_URL"], :desired_capabilities => caps)
101
32
  end
102
- else
103
- Selenium::WebDriver.for(:firefox)
104
- end
105
- $driver.manage().window().maximize()
106
- rescue Exception => e
107
- puts e.message
108
- Process.exit(0)
33
+ else
34
+ Selenium::WebDriver.for(:firefox)
109
35
  end
36
+ rescue Exception => e
37
+ puts e.message
38
+ Process.exit(0)
110
39
  end
@@ -3,7 +3,7 @@
3
3
 
4
4
  # # enter text into input field steps
5
5
  # Then(/^I enter "([^\"]*)" into element "(.*?)"$/) do |text, element|
6
- # enter_text(type, element)
6
+ # enter_text(element, text)
7
7
  # end
8
8
 
9
9
  # # clear input field steps
@@ -1,228 +1,208 @@
1
1
  require 'net/https'
2
2
  require_relative 'required_files'
3
+ require 'rspec'
3
4
 
4
5
  # This file contains assertion methods which are called from assertion_steps.rb
5
6
 
6
- # Method to return page title
7
- def get_page_title
8
- $driver.title
7
+ # Method to verify title
8
+ # param 1: String : expected title
9
+ def assert_title(title)
10
+ expect($driver.title).to eq(title)
9
11
  end
10
12
 
11
- # Method to verify title
12
- # param 1 : String : expected title
13
- # param 2 : Boolean : test case [true or flase]
14
- def check_title(title, test_case)
15
- page_title = get_page_title
16
- if test_case
17
- if page_title != "#{title}"
18
- raise TestCaseFailed, "Page Title Not Matched, Actual Page Title : #{page_title}"
19
- end
20
- else
21
- if page_title == "#{title}"
22
- raise TestCaseFailed, "Page Title Matched, Actual Page Title:#{page_title}"
23
- end
24
- end
13
+ # Method to check element text
14
+ # param 1 : String : Element
15
+ # param 2 : String : Expected element text
16
+ def assert_text(element, expected_value)
17
+ found_element = find_object(element)
18
+ element_text = found_element.text
19
+ expect(element_text).to eq(expected_value)
25
20
  end
26
21
 
27
- # Method to verify partial title
28
- # param 1 : String : partial title string
29
- # param 2 : Boolean : test case [true or flase]
30
- def check_partial_title(partial_text_title, test_case)
31
- page_title = get_page_title
32
- if test_case
33
- if not page_title.include? "#{partial_text_title}"
34
- raise TestCaseFailed, 'Partial Page Title Not Present'
35
- end
36
- else
37
- if page_title.include? "#{partial_text_title}"
38
- raise TestCaseFailed, 'Page Title Matched'
39
- end
40
- end
22
+ # method to check element presence
23
+ # param 1: String: Element
24
+ def assert_element_present(element)
25
+ found_element = find_object(element)
26
+ expect(found_element.length).to be > 0
41
27
  end
42
28
 
43
- # Method to get element text
44
- # param : String
45
- def get_element_text(element)
46
- WAIT.until { find_object(element) }.text
29
+ # method to check element not presence
30
+ # param 1: String: Element
31
+ def assert_element_not_present(element)
32
+ found_element = find_object(element)
33
+ expect(found_element.length).to eq(0)
47
34
  end
48
35
 
49
- # Method to check element text
36
+ # method to assert checkbox check
50
37
  # param 1 : String : Element
51
- # param 2 : String : Expected element text
52
- # param 3 : Boolean : test case [true or flase]
53
- def check_element_text(element, expected_value, test_case)
54
- element_text = get_element_text(element)
38
+ def assert_checked(element)
39
+ checkbox = find_object(element)
40
+ expect(checkbox.selected?).to be_truthy
41
+ end
55
42
 
56
- if test_case
57
- if element_text != expected_value
58
- raise TestCaseFailed, "Text Not Matched. Actual Value :#{expected_value}"
59
- end
60
- else
61
- if element_text == expected_value
62
- raise TestCaseFailed, "Text Matched. Actual Value :#{expected_value}"
63
- end
64
- end
43
+ def assert_not_checked(element)
44
+ checkbox = find_object(element)
45
+ expect(checkbox.selected?).to be_falsey
65
46
  end
66
47
 
67
- # Method to check partial element text
68
- # param 1 : String : Element
69
- # param 2 : String : Expected element partial text
70
- # param 3 : Boolean : test case [true or flase]
71
- def check_element_partial_text(element, expected_value, test_case)
72
- element_text = get_element_text(element)
73
-
74
- if test_case
75
- if not element_text.include? "#{expected_value}"
76
- raise TestCaseFailed, "Text Not Matched. Actual Value :#{expected_value}"
77
- end
78
- else
79
- if element_text.include? "#{expected_value}"
80
- raise TestCaseFailed, "Text Matched. Actual Value :#{expected_value}"
81
- end
82
- end
48
+ # method to check javascript pop-up alert text
49
+ def assert_alert(text)
50
+ alert_text = $driver.switch_to.alert.text
51
+ expect(alert_text).to eq(text)
83
52
  end
84
53
 
85
- # method to return element status - enabled?
86
- # param : String : Element
87
- def is_element_enabled(element)
88
- WAIT.until{ find_object(element) }.enabled?
54
+ # method to check javascript pop-up alert text
55
+ def assert_confirmation(text)
56
+ alert_text = $driver.switch_to.alert.text
57
+ expect(alert_text).to eq(text)
89
58
  end
90
59
 
91
- # method to check element status - enabled?
92
- # param 1 : String : Element
93
- # param 2 : Boolean : test case [true or flase]
94
- def check_element_enable(element, test_case)
95
- result = is_element_enabled(element)
60
+ def assert_editable(element)
61
+ found_element = find_object(element)
62
+ expect(found_element.enabled?).to be_truthy
63
+ end
96
64
 
97
- if test_case
98
- raise TestCaseFailed, 'Element Not Enabled' unless result
99
- else
100
- raise TestCaseFailed, 'Element Enabled' unless !result
101
- end
65
+ def assert_not_editable
66
+ found_element = find_object(element)
67
+ expect(found_element.enabled?).to be_falsey
102
68
  end
103
69
 
104
- # method to get attribute value
105
- # param 1 : String : Element
106
- # param 2 : String : atrribute name
107
- def get_element_attribute(element, attribute_name)
108
- WAIT.until{ find_object(element) }.attribute("#{attribute_name}")
70
+ def assert_not_selected_value(element, text)
71
+ found_element = find_object(element)
72
+ value = found_element.attribute("value")
73
+ expect(value).not_to eq(text)
109
74
  end
110
75
 
111
- # method to check attribute value
112
- # param 1 : String : Element
113
- # param 2 : String : atrribute name
114
- # param 3 : String : atrribute value
115
- # param 4 : Boolean : test case [true or flase]
116
- def check_element_attribute(element, attribute_name, attribute_value, test_case)
76
+ def assert_not_text(element, text)
77
+ found_element = find_object(element)
78
+ expect(found_element.text).not_to eq(text)
79
+ end
117
80
 
118
- attr_val = get_element_attribute(element, attribute_name)
81
+ def assert_prompt(text)
82
+ alert_text = $driver.switch_to.alert.text
83
+ expect(alert_text).to eq(text)
84
+ end
119
85
 
120
- if test_case
121
- if attr_val != attribute_value
122
- raise TestCaseFailed, "Attribute Value Not Matched. Actual Value :#{attr_val}"
123
- end
124
- else
125
- if attr_val == attribute_value
126
- raise TestCaseFailed, "Attribute Value Matched. Actual Value :#{attr_val}"
127
- end
128
- end
86
+ def assert_selected_label(element, text)
87
+ found_element = find_object(element)
88
+ locator = "option[@value='#{found_element.attribute('value')}']"
89
+ selected_text = found_element.find_element(:xpath, locator).text
90
+ expect(selected_text).to eq(text)
129
91
  end
130
92
 
131
- # method to get element status - displayed?
132
- # param : String : Element
133
- def is_element_displayed(element)
134
- WAIT.until{ find_object(element) }.displayed?
93
+ def assert_value(element, text)
94
+ found_element = find_object(element)
95
+ value = found_element.attribute("value")
96
+ expect(value).to eq(text)
135
97
  end
136
98
 
137
- # method to check element presence
138
- # param 1 : String : Element
139
- # param 2 : Boolean : test case [true or flase]
140
- def check_element_presence(element, test_case)
141
- if test_case
142
- if !is_element_displayed(element)
143
- raise TestCaseFailed, 'Element Not Present'
144
- end
145
- else
146
- begin
147
- if is_element_displayed(element)
148
- raise 'Present' # since it is negative test and we found element
149
- end
150
- rescue Exception => e
151
- if e.message == 'Present' # only raise if it present
152
- raise TestCaseFailed, 'Element Present'
153
- end
154
- end
155
- end
99
+ def assert_selected_value
100
+ found_element = find_object(element)
101
+ value = found_element.attribute("value")
102
+ expect(value).to eq(text)
156
103
  end
157
104
 
158
- # method to assert checkbox check/uncheck
105
+ def assert(var_name, value)
106
+ if (value == "true" || value == "false") {
107
+ _value = value
108
+ } elseif (value == '0' || !!number_or_nil(value)) {
109
+ _value = value
110
+ }
111
+ result = _value
112
+ ? expect($vars[var_name]).to eq(_value)
113
+ : expect($vars[var_name]).to eq(value)
114
+ end
115
+
116
+ # Method to verify title
117
+ # param 1: String : expected title
118
+ def verify_title(title)
119
+ expect($driver.title).to eq(title)
120
+ end
121
+
122
+ # Method to check element text
159
123
  # param 1 : String : Element
160
- # param 2 : Boolean : test case [true or flase]
161
- def is_checkbox_checked(element, should_be_checked = true)
162
- checkbox = WAIT.until{ find_object(element) }
163
-
164
- if !checkbox.selected? && should_be_checked
165
- raise TestCaseFailed, 'Checkbox is not checked'
166
- elsif checkbox.selected? && !should_be_checked
167
- raise TestCaseFailed, 'Checkbox is checked'
168
- end
124
+ # param 2 : String : Expected element text
125
+ def verify_text(element, expected_value)
126
+ found_element = find_object(element)
127
+ element_text = found_element.text
128
+ expect(element_text).to eq(expected_value)
129
+ end
130
+
131
+ # method to check element presence
132
+ # param 1: String: Element
133
+ def verify_element_present(element)
134
+ found_element = find_object(element)
135
+ expect(found_element.length).to be > 0
169
136
  end
170
137
 
171
- # method to assert radio button selected/unselected
138
+ # method to check element not presence
139
+ # param 1: String: Element
140
+ def verify_element_not_present(element)
141
+ found_element = find_object(element)
142
+ expect(found_element.length).to eq(0)
143
+ end
144
+
145
+ # method to assert checkbox check
172
146
  # param 1 : String : Element
173
- # param 2 : Boolean : test case [true or flase]
174
- def is_radio_button_selected(element, should_be_selected = true)
175
- radio_button = WAIT.until{ find_object(element) }
176
-
177
- if !radio_button.selected? && should_be_selected
178
- raise TestCaseFailed, 'Radio Button not selected'
179
- elsif radio_button.selected? && !should_be_selected
180
- raise TestCaseFailed, 'Radio Button is selected'
181
- end
147
+ def verify_checked(element)
148
+ checkbox = find_object(element)
149
+ expect(checkbox.selected?).to be_truthy
182
150
  end
183
151
 
184
- # method to assert option from radio button group is selected/unselected
185
- def is_option_from_radio_button_group_selected(element, by, option, should_be_selected = true)
186
- radio_button_group = WAIT.until{ find_object(element) }
152
+ def verify_not_checked(element)
153
+ checkbox = find_object(element)
154
+ expect(checkbox.selected?).to be_falsey
155
+ end
187
156
 
188
- getter = ->(rb, by) { by == 'value' ? rb.attribute('value') : rb.text }
157
+ def verify_editable(element)
158
+ found_element = find_object(element)
159
+ expect(found_element.enabled?).to be_truthy
160
+ end
189
161
 
190
- ele = radio_button_group.find { |rb| getter.call(rb, by) == option }
162
+ def verify_not_editable
163
+ found_element = find_object(element)
164
+ expect(found_element.enabled?).to be_falsey
165
+ end
191
166
 
192
- if !ele.selected? && should_be_selected
193
- raise TestCaseFailed, 'Radio button is not selected'
194
- elsif ele.selected? && !should_be_selected
195
- raise TestCaseFailed, 'Radio button is selected'
196
- end
167
+ def verify_not_selected_value(element, text)
168
+ found_element = find_object(element)
169
+ value = found_element.attribute("value")
170
+ expect(value).not_to eq(text)
197
171
  end
198
172
 
199
- # method to get javascript pop-up alert text
200
- def get_alert_text
201
- $driver.switch_to.alert.text
173
+ def verify_not_text(element, text)
174
+ found_element = find_object(element)
175
+ expect(found_element.text).not_to eq(text)
202
176
  end
203
177
 
204
- # method to check javascript pop-up alert text
205
- def check_alert_text(text)
206
- if get_alert_text != text
207
- raise TestCaseFailed, "Text on alert pop up not matched. Actual Value :#{get_alert_text}"
208
- end
178
+ def verify_selected_label(element, text)
179
+ found_element = find_object(element)
180
+ locator = "option[@value='#{found_element.attribute('value')}']"
181
+ selected_text = found_element.find_element(:xpath, locator).text
182
+ expect(selected_text).to eq(text)
209
183
  end
210
184
 
211
- def is_option_from_dropdown_selected(element, by, option, should_be_selected=true)
212
- dropdown = WAIT.until { find_object(element) }
213
- select_list = Selenium::WebDriver::Support::Select.new(dropdown)
185
+ def verify_value(element, text)
186
+ found_element = find_object(element)
187
+ value = found_element.attribute("value")
188
+ expect(value).to eq(text)
189
+ end
214
190
 
215
- if by == 'text'
216
- actual_value = select_list.first_selected_option.text
217
- else
218
- actual_value = select_list.first_selected_option.attribute('value')
219
- end
191
+ def verify_selected_value
192
+ found_element = find_object(element)
193
+ value = found_element.attribute("value")
194
+ expect(value).to eq(text)
195
+ end
220
196
 
221
- if !actual_value == option && should_be_selected
222
- raise TestCaseFailed, 'Option Not Selected From Dropwdown'
223
- elsif actual_value == option && !should_be_selected
224
- raise TestCaseFailed, 'Option Selected From Dropwdown'
225
- end
197
+ def verify(var_name, value)
198
+ if (value == "true" || value == "false") {
199
+ _value = value
200
+ } elseif (value == '0' || !!number_or_nil(value)) {
201
+ _value = value
202
+ }
203
+ result = _value
204
+ ? expect($vars[var_name]).to eq(_value)
205
+ : expect($vars[var_name]).to eq(value)
226
206
  end
227
207
 
228
208
  # Method to find difference between images
@@ -331,3 +311,8 @@ def compare_png_images(expected_img_url, actual_img_url)
331
311
  end
332
312
  true
333
313
  end
314
+
315
+ def number_or_nil(string)
316
+ num = string.to_i
317
+ num if num.to_s == string
318
+ end