testcentricity 2.4.1 → 2.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/lib/testcentricity/app_core/appium_connect_helper.rb +78 -66
- data/lib/testcentricity/app_core/screen_objects_helper.rb +23 -102
- data/lib/testcentricity/app_core/screen_sections_helper.rb +20 -96
- data/lib/testcentricity/version.rb +1 -1
- data/lib/testcentricity/web_core/page_objects_helper.rb +28 -62
- data/lib/testcentricity/web_core/page_sections_helper.rb +25 -62
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ba8bb419286dffb3e7f9cf89b8dc5aa6744870d4
|
4
|
+
data.tar.gz: 3b5886e903439cb5755a211a6aa75f799b267c9e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 79d250c941affcdbf496fe2c646fe9f963a911c5e7c49f43f84f0135a67421e739ac36a5168d5a0a7e2e90d31d9d2a5ee4711bc5e11447c1905d3086beccbae5
|
7
|
+
data.tar.gz: 484ff58e76a7a0a549a5f4ad2695915f0a3598aa16df7bfbe5a667471a4a118fdb4639d05ff7bcd0609bbd8e360a85da9b7298926397f3fec82b56c4905ce0da
|
data/README.md
CHANGED
@@ -925,6 +925,7 @@ the `WEB_BROWSER` Environment Variable must be set to one of the values from the
|
|
925
925
|
`ipad_pro_10_5` |`chrome` |1112 x 834 |landscape |iOS 11
|
926
926
|
`ipad_chrome` |`chrome` |1024 x 768 |landscape |iOS 10 - Mobile Chrome browser for iOS
|
927
927
|
`ipad_firefox` |`chrome` |1024 x 768 |landscape |iOS 10 - Mobile Firefox browser for iOS
|
928
|
+
`ipad_edge` |`chrome` |1024 x 768 |landscape |iOS 10 - Mobile Edge browser for iOS
|
928
929
|
`android_tablet` |`chrome` |1024 x 768 |landscape |Android 3.0
|
929
930
|
`kindle_fire` |`chrome` |1024 x 600 |landscape |
|
930
931
|
`kindle_firehd7` |`chrome` |800 x 480 |landscape |Fire OS 3
|
@@ -1226,6 +1227,7 @@ service(s) that you intend to connect with.
|
|
1226
1227
|
ipad_pro_10_5: WEB_BROWSER=ipad_pro_10_5 HOST_BROWSER=chrome <%= mobile %>
|
1227
1228
|
ipad_chrome: WEB_BROWSER=ipad_chrome HOST_BROWSER=chrome <%= mobile %>
|
1228
1229
|
ipad_firefox: WEB_BROWSER=ipad_firefox HOST_BROWSER=chrome <%= mobile %>
|
1230
|
+
ipad_edge: WEB_BROWSER=ipad_edge HOST_BROWSER=chrome <%= mobile %>
|
1229
1231
|
iphone: WEB_BROWSER=iphone HOST_BROWSER=chrome <%= mobile %>
|
1230
1232
|
iphone4: WEB_BROWSER=iphone4 HOST_BROWSER=chrome <%= mobile %>
|
1231
1233
|
iphone5: WEB_BROWSER=iphone5 HOST_BROWSER=chrome <%= mobile %>
|
@@ -36,73 +36,9 @@ module TestCentricity
|
|
36
36
|
browser = ENV['WEB_BROWSER']
|
37
37
|
case browser.downcase.to_sym
|
38
38
|
when :appium
|
39
|
-
desired_capabilities =
|
40
|
-
caps: {
|
41
|
-
platformName: ENV['APP_PLATFORM_NAME'],
|
42
|
-
platformVersion: ENV['APP_VERSION'],
|
43
|
-
deviceName: ENV['APP_DEVICE'],
|
44
|
-
automationName: ENV['AUTOMATION_ENGINE']
|
45
|
-
}
|
46
|
-
}
|
47
|
-
capabilities = desired_capabilities[:caps]
|
48
|
-
capabilities[:avd] = ENV['APP_DEVICE'] if ENV['APP_PLATFORM_NAME'].downcase.to_sym == :android
|
49
|
-
capabilities[:orientation] = ENV['ORIENTATION'].upcase if ENV['ORIENTATION']
|
50
|
-
capabilities[:language] = ENV['LANGUAGE'] if ENV['LANGUAGE']
|
51
|
-
capabilities[:locale] = ENV['LOCALE'].gsub('-', '_') if ENV['LOCALE']
|
52
|
-
capabilities[:newCommandTimeout] = ENV['NEW_COMMAND_TIMEOUT'] if ENV['NEW_COMMAND_TIMEOUT']
|
53
|
-
capabilities[:noReset] = ENV['APP_NO_RESET'] if ENV['APP_NO_RESET']
|
54
|
-
capabilities[:fullReset] = ENV['APP_FULL_RESET'] if ENV['APP_FULL_RESET']
|
55
|
-
capabilities[:webkitDebugProxyPort] = ENV['WEBKIT_DEBUG_PROXY_PORT'] if ENV['WEBKIT_DEBUG_PROXY_PORT']
|
56
|
-
capabilities[:webDriverAgentUrl] = ENV['WEBDRIVER_AGENT_URL'] if ENV['WEBDRIVER_AGENT_URL']
|
57
|
-
capabilities[:wdaLocalPort] = ENV['WDA_LOCAL_PORT'] if ENV['WDA_LOCAL_PORT']
|
58
|
-
capabilities[:usePrebuiltWDA] = ENV['USE_PREBUILT_WDA'] if ENV['USE_PREBUILT_WDA']
|
59
|
-
capabilities[:useNewWDA] = ENV['USE_NEW_WDA'] if ENV['USE_NEW_WDA']
|
60
|
-
capabilities[:startIWDP] = ENV['START_IWDP'] if ENV['START_IWDP']
|
61
|
-
capabilities[:autoWebview] = ENV['AUTO_WEBVIEW'] if ENV['AUTO_WEBVIEW']
|
62
|
-
capabilities[:chromedriverExecutable] = ENV['CHROMEDRIVER_EXECUTABLE'] if ENV['CHROMEDRIVER_EXECUTABLE']
|
63
|
-
capabilities[:autoWebviewTimeout] = ENV['AUTO_WEBVIEW_TIMEOUT'] if ENV['AUTO_WEBVIEW_TIMEOUT']
|
64
|
-
|
65
|
-
if ENV['UDID']
|
66
|
-
capabilities[:udid] = ENV['UDID']
|
67
|
-
capabilities[:bundleId] = ENV['BUNDLE_ID'] if ENV['BUNDLE_ID']
|
68
|
-
capabilities[:xcodeOrgId] = ENV['TEAM_ID'] if ENV['TEAM_ID']
|
69
|
-
capabilities[:xcodeSigningId] = ENV['TEAM_NAME'] if ENV['TEAM_NAME']
|
70
|
-
capabilities[:appActivity] = ENV['APP_ACTIVITY'] if ENV['APP_ACTIVITY']
|
71
|
-
capabilities[:appPackage] = ENV['APP_PACKAGE'] if ENV['APP_PACKAGE']
|
72
|
-
end
|
73
|
-
|
74
|
-
if ENV['APP']
|
75
|
-
capabilities[:app] = ENV['APP']
|
76
|
-
else
|
77
|
-
if Environ.is_android?
|
78
|
-
capabilities[:app] = Environ.current.android_apk_path
|
79
|
-
elsif Environ.is_ios?
|
80
|
-
Environ.is_device? ?
|
81
|
-
capabilities[:app] = Environ.current.ios_ipa_path :
|
82
|
-
capabilities[:app] = Environ.current.ios_app_path
|
83
|
-
end
|
84
|
-
end
|
39
|
+
desired_capabilities = appium_local_capabilities
|
85
40
|
when :browserstack
|
86
|
-
|
87
|
-
|
88
|
-
capabilities = {}
|
89
|
-
capabilities['device'] = ENV['BS_DEVICE']
|
90
|
-
capabilities['os_version'] = ENV['BS_OS_VERSION']
|
91
|
-
capabilities['app'] = "bs://#{ENV['APP_URL']}" if ENV['APP_URL']
|
92
|
-
capabilities['app'] = ENV['APP_ID'] if ENV['APP_ID']
|
93
|
-
capabilities['realMobile'] = true
|
94
|
-
capabilities['project'] = ENV['AUTOMATE_PROJECT'] if ENV['AUTOMATE_PROJECT']
|
95
|
-
capabilities['build'] = ENV['AUTOMATE_BUILD'] if ENV['AUTOMATE_BUILD']
|
96
|
-
capabilities['deviceOrientation'] = ENV['ORIENTATION'] if ENV['ORIENTATION']
|
97
|
-
capabilities['browserstack.debug'] = true
|
98
|
-
capabilities['browserstack.video'] = ENV['RECORD_VIDEO'] if ENV['RECORD_VIDEO']
|
99
|
-
capabilities['browserstack.debug'] = 'true'
|
100
|
-
|
101
|
-
appium_lib_options = { server_url: endpoint }
|
102
|
-
desired_capabilities = {
|
103
|
-
appium_lib: appium_lib_options,
|
104
|
-
caps: capabilities
|
105
|
-
}
|
41
|
+
desired_capabilities = browserstack_capabilities
|
106
42
|
end
|
107
43
|
else
|
108
44
|
base_path = 'config'
|
@@ -215,6 +151,82 @@ module TestCentricity
|
|
215
151
|
set_context(contexts.last)
|
216
152
|
puts "Current context = #{$driver.current_context}" if ENV['DEBUG']
|
217
153
|
end
|
154
|
+
|
155
|
+
private
|
156
|
+
|
157
|
+
def self.appium_local_capabilities
|
158
|
+
desired_capabilities = {
|
159
|
+
caps: {
|
160
|
+
platformName: ENV['APP_PLATFORM_NAME'],
|
161
|
+
platformVersion: ENV['APP_VERSION'],
|
162
|
+
deviceName: ENV['APP_DEVICE'],
|
163
|
+
automationName: ENV['AUTOMATION_ENGINE']
|
164
|
+
}
|
165
|
+
}
|
166
|
+
capabilities = desired_capabilities[:caps]
|
167
|
+
capabilities[:avd] = ENV['APP_DEVICE'] if ENV['APP_PLATFORM_NAME'].downcase.to_sym == :android
|
168
|
+
capabilities[:orientation] = ENV['ORIENTATION'].upcase if ENV['ORIENTATION']
|
169
|
+
capabilities[:language] = ENV['LANGUAGE'] if ENV['LANGUAGE']
|
170
|
+
capabilities[:locale] = ENV['LOCALE'].gsub('-', '_') if ENV['LOCALE']
|
171
|
+
capabilities[:newCommandTimeout] = ENV['NEW_COMMAND_TIMEOUT'] if ENV['NEW_COMMAND_TIMEOUT']
|
172
|
+
capabilities[:noReset] = ENV['APP_NO_RESET'] if ENV['APP_NO_RESET']
|
173
|
+
capabilities[:fullReset] = ENV['APP_FULL_RESET'] if ENV['APP_FULL_RESET']
|
174
|
+
capabilities[:webkitDebugProxyPort] = ENV['WEBKIT_DEBUG_PROXY_PORT'] if ENV['WEBKIT_DEBUG_PROXY_PORT']
|
175
|
+
capabilities[:webDriverAgentUrl] = ENV['WEBDRIVER_AGENT_URL'] if ENV['WEBDRIVER_AGENT_URL']
|
176
|
+
capabilities[:wdaLocalPort] = ENV['WDA_LOCAL_PORT'] if ENV['WDA_LOCAL_PORT']
|
177
|
+
capabilities[:usePrebuiltWDA] = ENV['USE_PREBUILT_WDA'] if ENV['USE_PREBUILT_WDA']
|
178
|
+
capabilities[:useNewWDA] = ENV['USE_NEW_WDA'] if ENV['USE_NEW_WDA']
|
179
|
+
capabilities[:startIWDP] = ENV['START_IWDP'] if ENV['START_IWDP']
|
180
|
+
capabilities[:autoWebview] = ENV['AUTO_WEBVIEW'] if ENV['AUTO_WEBVIEW']
|
181
|
+
capabilities[:chromedriverExecutable] = ENV['CHROMEDRIVER_EXECUTABLE'] if ENV['CHROMEDRIVER_EXECUTABLE']
|
182
|
+
capabilities[:autoWebviewTimeout] = ENV['AUTO_WEBVIEW_TIMEOUT'] if ENV['AUTO_WEBVIEW_TIMEOUT']
|
183
|
+
|
184
|
+
if ENV['UDID']
|
185
|
+
capabilities[:udid] = ENV['UDID']
|
186
|
+
capabilities[:bundleId] = ENV['BUNDLE_ID'] if ENV['BUNDLE_ID']
|
187
|
+
capabilities[:xcodeOrgId] = ENV['TEAM_ID'] if ENV['TEAM_ID']
|
188
|
+
capabilities[:xcodeSigningId] = ENV['TEAM_NAME'] if ENV['TEAM_NAME']
|
189
|
+
capabilities[:appActivity] = ENV['APP_ACTIVITY'] if ENV['APP_ACTIVITY']
|
190
|
+
capabilities[:appPackage] = ENV['APP_PACKAGE'] if ENV['APP_PACKAGE']
|
191
|
+
end
|
192
|
+
|
193
|
+
if ENV['APP']
|
194
|
+
capabilities[:app] = ENV['APP']
|
195
|
+
else
|
196
|
+
if Environ.is_android?
|
197
|
+
capabilities[:app] = Environ.current.android_apk_path
|
198
|
+
elsif Environ.is_ios?
|
199
|
+
Environ.is_device? ?
|
200
|
+
capabilities[:app] = Environ.current.ios_ipa_path :
|
201
|
+
capabilities[:app] = Environ.current.ios_app_path
|
202
|
+
end
|
203
|
+
end
|
204
|
+
desired_capabilities
|
205
|
+
end
|
206
|
+
|
207
|
+
def self.browserstack_capabilities
|
208
|
+
endpoint = "http://#{ENV['BS_USERNAME']}:#{ENV['BS_AUTHKEY']}@hub-cloud.browserstack.com/wd/hub"
|
209
|
+
|
210
|
+
capabilities = {}
|
211
|
+
capabilities['device'] = ENV['BS_DEVICE']
|
212
|
+
capabilities['os_version'] = ENV['BS_OS_VERSION']
|
213
|
+
capabilities['app'] = "bs://#{ENV['APP_URL']}" if ENV['APP_URL']
|
214
|
+
capabilities['app'] = ENV['APP_ID'] if ENV['APP_ID']
|
215
|
+
capabilities['realMobile'] = true
|
216
|
+
capabilities['project'] = ENV['AUTOMATE_PROJECT'] if ENV['AUTOMATE_PROJECT']
|
217
|
+
capabilities['build'] = ENV['AUTOMATE_BUILD'] if ENV['AUTOMATE_BUILD']
|
218
|
+
capabilities['deviceOrientation'] = ENV['ORIENTATION'] if ENV['ORIENTATION']
|
219
|
+
capabilities['browserstack.debug'] = true
|
220
|
+
capabilities['browserstack.video'] = ENV['RECORD_VIDEO'] if ENV['RECORD_VIDEO']
|
221
|
+
capabilities['browserstack.debug'] = 'true'
|
222
|
+
|
223
|
+
appium_lib_options = { server_url: endpoint }
|
224
|
+
desired_capabilities = {
|
225
|
+
appium_lib: appium_lib_options,
|
226
|
+
caps: capabilities
|
227
|
+
}
|
228
|
+
desired_capabilities
|
229
|
+
end
|
218
230
|
end
|
219
231
|
end
|
220
232
|
|
@@ -15,17 +15,8 @@ module TestCentricity
|
|
15
15
|
define_method(trait_name.to_s, &block)
|
16
16
|
end
|
17
17
|
|
18
|
-
# def self.element(element_name, locator)
|
19
|
-
# class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::AppUIElement.new("#{element_name}", self, #{locator}, :page);end))
|
20
|
-
# end
|
21
|
-
|
22
18
|
def self.element(element_name, locator)
|
23
|
-
|
24
|
-
ivar_name = "@#{element_name}"
|
25
|
-
ivar = instance_variable_get(ivar_name)
|
26
|
-
return ivar if ivar
|
27
|
-
instance_variable_set(ivar_name, TestCentricity::AppUIElement.new(element_name, self, locator, :page))
|
28
|
-
end
|
19
|
+
define_page_element(element_name, TestCentricity::AppUIElement, locator)
|
29
20
|
end
|
30
21
|
|
31
22
|
def self.elements(element_hash)
|
@@ -34,17 +25,8 @@ module TestCentricity
|
|
34
25
|
end
|
35
26
|
end
|
36
27
|
|
37
|
-
# def self.button(element_name, locator)
|
38
|
-
# class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::AppButton.new("#{element_name}", self, #{locator}, :page);end))
|
39
|
-
# end
|
40
|
-
|
41
28
|
def self.button(element_name, locator)
|
42
|
-
|
43
|
-
ivar_name = "@#{element_name}"
|
44
|
-
ivar = instance_variable_get(ivar_name)
|
45
|
-
return ivar if ivar
|
46
|
-
instance_variable_set(ivar_name, TestCentricity::AppButton.new(element_name, self, locator, :page))
|
47
|
-
end
|
29
|
+
define_page_element(element_name, TestCentricity::AppButton, locator)
|
48
30
|
end
|
49
31
|
|
50
32
|
def self.buttons(element_hash)
|
@@ -53,17 +35,8 @@ module TestCentricity
|
|
53
35
|
end
|
54
36
|
end
|
55
37
|
|
56
|
-
# def self.textfield(element_name, locator)
|
57
|
-
# class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::AppTextField.new("#{element_name}", self, #{locator}, :page);end))
|
58
|
-
# end
|
59
|
-
|
60
38
|
def self.textfield(element_name, locator)
|
61
|
-
|
62
|
-
ivar_name = "@#{element_name}"
|
63
|
-
ivar = instance_variable_get(ivar_name)
|
64
|
-
return ivar if ivar
|
65
|
-
instance_variable_set(ivar_name, TestCentricity::AppTextField.new(element_name, self, locator, :page))
|
66
|
-
end
|
39
|
+
define_page_element(element_name, TestCentricity::AppTextField, locator)
|
67
40
|
end
|
68
41
|
|
69
42
|
def self.textfields(element_hash)
|
@@ -72,17 +45,8 @@ module TestCentricity
|
|
72
45
|
end
|
73
46
|
end
|
74
47
|
|
75
|
-
# def self.switch(element_name, locator)
|
76
|
-
# class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::AppSwitch.new("#{element_name}", self, #{locator}, :page);end))
|
77
|
-
# end
|
78
|
-
|
79
48
|
def self.switch(element_name, locator)
|
80
|
-
|
81
|
-
ivar_name = "@#{element_name}"
|
82
|
-
ivar = instance_variable_get(ivar_name)
|
83
|
-
return ivar if ivar
|
84
|
-
instance_variable_set(ivar_name, TestCentricity::AppSwitch.new(element_name, self, locator, :page))
|
85
|
-
end
|
49
|
+
define_page_element(element_name, TestCentricity::AppSwitch, locator)
|
86
50
|
end
|
87
51
|
|
88
52
|
def self.switches(element_hash)
|
@@ -91,17 +55,8 @@ module TestCentricity
|
|
91
55
|
end
|
92
56
|
end
|
93
57
|
|
94
|
-
# def self.checkbox(element_name, locator)
|
95
|
-
# class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::AppCheckBox.new("#{element_name}", self, #{locator}, :page);end))
|
96
|
-
# end
|
97
|
-
|
98
58
|
def self.checkbox(element_name, locator)
|
99
|
-
|
100
|
-
ivar_name = "@#{element_name}"
|
101
|
-
ivar = instance_variable_get(ivar_name)
|
102
|
-
return ivar if ivar
|
103
|
-
instance_variable_set(ivar_name, TestCentricity::AppCheckBox.new(element_name, self, locator, :page))
|
104
|
-
end
|
59
|
+
define_page_element(element_name, TestCentricity::AppCheckBox, locator)
|
105
60
|
end
|
106
61
|
|
107
62
|
def self.checkboxes(element_hash)
|
@@ -110,17 +65,8 @@ module TestCentricity
|
|
110
65
|
end
|
111
66
|
end
|
112
67
|
|
113
|
-
# def self.label(element_name, locator)
|
114
|
-
# class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::AppLabel.new("#{element_name}", self, #{locator}, :page);end))
|
115
|
-
# end
|
116
|
-
|
117
68
|
def self.label(element_name, locator)
|
118
|
-
|
119
|
-
ivar_name = "@#{element_name}"
|
120
|
-
ivar = instance_variable_get(ivar_name)
|
121
|
-
return ivar if ivar
|
122
|
-
instance_variable_set(ivar_name, TestCentricity::AppLabel.new(element_name, self, locator, :page))
|
123
|
-
end
|
69
|
+
define_page_element(element_name, TestCentricity::AppLabel, locator)
|
124
70
|
end
|
125
71
|
|
126
72
|
def self.labels(element_hash)
|
@@ -129,17 +75,8 @@ module TestCentricity
|
|
129
75
|
end
|
130
76
|
end
|
131
77
|
|
132
|
-
# def self.list(element_name, locator)
|
133
|
-
# class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::AppList.new("#{element_name}", self, #{locator}, :page);end))
|
134
|
-
# end
|
135
|
-
|
136
78
|
def self.list(element_name, locator)
|
137
|
-
|
138
|
-
ivar_name = "@#{element_name}"
|
139
|
-
ivar = instance_variable_get(ivar_name)
|
140
|
-
return ivar if ivar
|
141
|
-
instance_variable_set(ivar_name, TestCentricity::AppList.new(element_name, self, locator, :page))
|
142
|
-
end
|
79
|
+
define_page_element(element_name, TestCentricity::AppList, locator)
|
143
80
|
end
|
144
81
|
|
145
82
|
def self.lists(element_hash)
|
@@ -148,17 +85,8 @@ module TestCentricity
|
|
148
85
|
end
|
149
86
|
end
|
150
87
|
|
151
|
-
# def self.selectlist(element_name, locator)
|
152
|
-
# class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::AppSelectList.new("#{element_name}", self, #{locator}, :page);end))
|
153
|
-
# end
|
154
|
-
|
155
88
|
def self.selectlist(element_name, locator)
|
156
|
-
|
157
|
-
ivar_name = "@#{element_name}"
|
158
|
-
ivar = instance_variable_get(ivar_name)
|
159
|
-
return ivar if ivar
|
160
|
-
instance_variable_set(ivar_name, TestCentricity::AppSelectList.new(element_name, self, locator, :page))
|
161
|
-
end
|
89
|
+
define_page_element(element_name, TestCentricity::AppSelectList, locator)
|
162
90
|
end
|
163
91
|
|
164
92
|
def self.selectlists(element_hash)
|
@@ -167,17 +95,8 @@ module TestCentricity
|
|
167
95
|
end
|
168
96
|
end
|
169
97
|
|
170
|
-
# def self.image(element_name, locator)
|
171
|
-
# class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::AppImage.new("#{element_name}", self, #{locator}, :page);end))
|
172
|
-
# end
|
173
|
-
|
174
98
|
def self.image(element_name, locator)
|
175
|
-
|
176
|
-
ivar_name = "@#{element_name}"
|
177
|
-
ivar = instance_variable_get(ivar_name)
|
178
|
-
return ivar if ivar
|
179
|
-
instance_variable_set(ivar_name, TestCentricity::AppImage.new(element_name, self, locator, :page))
|
180
|
-
end
|
99
|
+
define_page_element(element_name, TestCentricity::AppImage, locator)
|
181
100
|
end
|
182
101
|
|
183
102
|
def self.images(element_hash)
|
@@ -186,21 +105,12 @@ module TestCentricity
|
|
186
105
|
end
|
187
106
|
end
|
188
107
|
|
189
|
-
# def self.alert(element_name, locator)
|
190
|
-
# class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::AppAlert.new("#{element_name}", self, #{locator}, :page);end))
|
191
|
-
# end
|
192
|
-
|
193
108
|
def self.alert(element_name, locator)
|
194
|
-
|
195
|
-
ivar_name = "@#{element_name}"
|
196
|
-
ivar = instance_variable_get(ivar_name)
|
197
|
-
return ivar if ivar
|
198
|
-
instance_variable_set(ivar_name, TestCentricity::AppAlert.new(element_name, self, locator, :page))
|
199
|
-
end
|
109
|
+
define_page_element(element_name, TestCentricity::AppAlert, locator)
|
200
110
|
end
|
201
111
|
|
202
|
-
def self.section(section_name,
|
203
|
-
|
112
|
+
def self.section(section_name, obj, locator = 0)
|
113
|
+
define_page_element(section_name, obj, locator)
|
204
114
|
end
|
205
115
|
|
206
116
|
def self.sections(section_hash)
|
@@ -344,5 +254,16 @@ module TestCentricity
|
|
344
254
|
end
|
345
255
|
end
|
346
256
|
end
|
257
|
+
|
258
|
+
private
|
259
|
+
|
260
|
+
def self.define_page_element(element_name, obj, locator)
|
261
|
+
define_method(element_name) do
|
262
|
+
ivar_name = "@#{element_name}"
|
263
|
+
ivar = instance_variable_get(ivar_name)
|
264
|
+
return ivar if ivar
|
265
|
+
instance_variable_set(ivar_name, obj.new(element_name, self, locator, :page))
|
266
|
+
end
|
267
|
+
end
|
347
268
|
end
|
348
269
|
end
|
@@ -80,17 +80,8 @@ module TestCentricity
|
|
80
80
|
define_method(trait_name.to_s, &block)
|
81
81
|
end
|
82
82
|
|
83
|
-
# def self.element(element_name, locator)
|
84
|
-
# class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::AppUIElement.new("#{element_name}", self, #{locator}, :section);end))
|
85
|
-
# end
|
86
|
-
|
87
83
|
def self.element(element_name, locator)
|
88
|
-
|
89
|
-
ivar_name = "@#{element_name}"
|
90
|
-
ivar = instance_variable_get(ivar_name)
|
91
|
-
return ivar if ivar
|
92
|
-
instance_variable_set(ivar_name, TestCentricity::AppUIElement.new(element_name, self, locator, :section))
|
93
|
-
end
|
84
|
+
define_element(element_name, TestCentricity::AppUIElement, locator)
|
94
85
|
end
|
95
86
|
|
96
87
|
def self.elements(element_hash)
|
@@ -99,17 +90,8 @@ module TestCentricity
|
|
99
90
|
end
|
100
91
|
end
|
101
92
|
|
102
|
-
# def self.button(element_name, locator)
|
103
|
-
# class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::AppButton.new("#{element_name}", self, #{locator}, :section);end))
|
104
|
-
# end
|
105
|
-
|
106
93
|
def self.button(element_name, locator)
|
107
|
-
|
108
|
-
ivar_name = "@#{element_name}"
|
109
|
-
ivar = instance_variable_get(ivar_name)
|
110
|
-
return ivar if ivar
|
111
|
-
instance_variable_set(ivar_name, TestCentricity::AppButton.new(element_name, self, locator, :section))
|
112
|
-
end
|
94
|
+
define_element(element_name, TestCentricity::AppButton, locator)
|
113
95
|
end
|
114
96
|
|
115
97
|
def self.buttons(element_hash)
|
@@ -118,17 +100,8 @@ module TestCentricity
|
|
118
100
|
end
|
119
101
|
end
|
120
102
|
|
121
|
-
# def self.textfield(element_name, locator)
|
122
|
-
# class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::AppTextField.new("#{element_name}", self, #{locator}, :section);end))
|
123
|
-
# end
|
124
|
-
|
125
103
|
def self.textfield(element_name, locator)
|
126
|
-
|
127
|
-
ivar_name = "@#{element_name}"
|
128
|
-
ivar = instance_variable_get(ivar_name)
|
129
|
-
return ivar if ivar
|
130
|
-
instance_variable_set(ivar_name, TestCentricity::AppTextField.new(element_name, self, locator, :section))
|
131
|
-
end
|
104
|
+
define_element(element_name, TestCentricity::AppTextField, locator)
|
132
105
|
end
|
133
106
|
|
134
107
|
def self.textfields(element_hash)
|
@@ -137,17 +110,8 @@ module TestCentricity
|
|
137
110
|
end
|
138
111
|
end
|
139
112
|
|
140
|
-
# def self.switch(element_name, locator)
|
141
|
-
# class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::AppSwitch.new("#{element_name}", self, #{locator}, :section);end))
|
142
|
-
# end
|
143
|
-
|
144
113
|
def self.switch(element_name, locator)
|
145
|
-
|
146
|
-
ivar_name = "@#{element_name}"
|
147
|
-
ivar = instance_variable_get(ivar_name)
|
148
|
-
return ivar if ivar
|
149
|
-
instance_variable_set(ivar_name, TestCentricity::AppSwitch.new(element_name, self, locator, :section))
|
150
|
-
end
|
114
|
+
define_element(element_name, TestCentricity::AppSwitch, locator)
|
151
115
|
end
|
152
116
|
|
153
117
|
def self.switches(element_hash)
|
@@ -156,17 +120,8 @@ module TestCentricity
|
|
156
120
|
end
|
157
121
|
end
|
158
122
|
|
159
|
-
# def self.checkbox(element_name, locator)
|
160
|
-
# class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::AppCheckBox.new("#{element_name}", self, #{locator}, :section);end))
|
161
|
-
# end
|
162
|
-
|
163
123
|
def self.checkbox(element_name, locator)
|
164
|
-
|
165
|
-
ivar_name = "@#{element_name}"
|
166
|
-
ivar = instance_variable_get(ivar_name)
|
167
|
-
return ivar if ivar
|
168
|
-
instance_variable_set(ivar_name, TestCentricity::AppCheckBox.new(element_name, self, locator, :section))
|
169
|
-
end
|
124
|
+
define_element(element_name, TestCentricity::AppCheckBox, locator)
|
170
125
|
end
|
171
126
|
|
172
127
|
def self.checkboxes(element_hash)
|
@@ -175,17 +130,8 @@ module TestCentricity
|
|
175
130
|
end
|
176
131
|
end
|
177
132
|
|
178
|
-
# def self.label(element_name, locator)
|
179
|
-
# class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::AppLabel.new("#{element_name}", self, #{locator}, :section);end))
|
180
|
-
# end
|
181
|
-
|
182
133
|
def self.label(element_name, locator)
|
183
|
-
|
184
|
-
ivar_name = "@#{element_name}"
|
185
|
-
ivar = instance_variable_get(ivar_name)
|
186
|
-
return ivar if ivar
|
187
|
-
instance_variable_set(ivar_name, TestCentricity::AppLabel.new(element_name, self, locator, :section))
|
188
|
-
end
|
134
|
+
define_element(element_name, TestCentricity::AppLabel, locator)
|
189
135
|
end
|
190
136
|
|
191
137
|
def self.labels(element_hash)
|
@@ -194,17 +140,8 @@ module TestCentricity
|
|
194
140
|
end
|
195
141
|
end
|
196
142
|
|
197
|
-
# def self.list(element_name, locator)
|
198
|
-
# class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::AppList.new("#{element_name}", self, #{locator}, :section);end))
|
199
|
-
# end
|
200
|
-
|
201
143
|
def self.list(element_name, locator)
|
202
|
-
|
203
|
-
ivar_name = "@#{element_name}"
|
204
|
-
ivar = instance_variable_get(ivar_name)
|
205
|
-
return ivar if ivar
|
206
|
-
instance_variable_set(ivar_name, TestCentricity::AppList.new(element_name, self, locator, :section))
|
207
|
-
end
|
144
|
+
define_element(element_name, TestCentricity::AppList, locator)
|
208
145
|
end
|
209
146
|
|
210
147
|
def self.lists(element_hash)
|
@@ -213,17 +150,8 @@ module TestCentricity
|
|
213
150
|
end
|
214
151
|
end
|
215
152
|
|
216
|
-
# def self.selectlist(element_name, locator)
|
217
|
-
# class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::AppSelectList.new("#{element_name}", self, #{locator}, :section);end))
|
218
|
-
# end
|
219
|
-
|
220
153
|
def self.selectlist(element_name, locator)
|
221
|
-
|
222
|
-
ivar_name = "@#{element_name}"
|
223
|
-
ivar = instance_variable_get(ivar_name)
|
224
|
-
return ivar if ivar
|
225
|
-
instance_variable_set(ivar_name, TestCentricity::AppSelectList.new(element_name, self, locator, :section))
|
226
|
-
end
|
154
|
+
define_element(element_name, TestCentricity::AppSelectList, locator)
|
227
155
|
end
|
228
156
|
|
229
157
|
def self.selectlists(element_hash)
|
@@ -232,17 +160,8 @@ module TestCentricity
|
|
232
160
|
end
|
233
161
|
end
|
234
162
|
|
235
|
-
# def self.image(element_name, locator)
|
236
|
-
# class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::AppImage.new("#{element_name}", self, #{locator}, :section);end))
|
237
|
-
# end
|
238
|
-
|
239
163
|
def self.image(element_name, locator)
|
240
|
-
|
241
|
-
ivar_name = "@#{element_name}"
|
242
|
-
ivar = instance_variable_get(ivar_name)
|
243
|
-
return ivar if ivar
|
244
|
-
instance_variable_set(ivar_name, TestCentricity::AppImage.new(element_name, self, locator, :section))
|
245
|
-
end
|
164
|
+
define_element(element_name, TestCentricity::AppImage, locator)
|
246
165
|
end
|
247
166
|
|
248
167
|
def self.images(element_hash)
|
@@ -251,10 +170,6 @@ module TestCentricity
|
|
251
170
|
end
|
252
171
|
end
|
253
172
|
|
254
|
-
# def self.alert(element_name, locator)
|
255
|
-
# class_eval(%(def #{element_name};@#{element_name} ||= TestCentricity::AppAlert.new("#{element_name}", self, #{locator}, :page);end))
|
256
|
-
# end
|
257
|
-
|
258
173
|
def self.alert(element_name, locator)
|
259
174
|
define_method(element_name) do
|
260
175
|
ivar_name = "@#{element_name}"
|
@@ -264,8 +179,8 @@ module TestCentricity
|
|
264
179
|
end
|
265
180
|
end
|
266
181
|
|
267
|
-
def self.section(section_name,
|
268
|
-
|
182
|
+
def self.section(section_name, obj, locator = 0)
|
183
|
+
define_element(section_name, obj, locator)
|
269
184
|
end
|
270
185
|
|
271
186
|
def self.sections(section_hash)
|
@@ -487,5 +402,14 @@ module TestCentricity
|
|
487
402
|
def section_not_found_exception(obj)
|
488
403
|
raise ObjectNotFoundError.new("Section object '#{get_name}' (#{get_locator}) not found") unless obj
|
489
404
|
end
|
405
|
+
|
406
|
+
def self.define_element(element_name, obj, locator)
|
407
|
+
define_method(element_name) do
|
408
|
+
ivar_name = "@#{element_name}"
|
409
|
+
ivar = instance_variable_get(ivar_name)
|
410
|
+
return ivar if ivar
|
411
|
+
instance_variable_set(ivar_name, obj.new(element_name, self, locator, :section))
|
412
|
+
end
|
413
|
+
end
|
490
414
|
end
|
491
415
|
end
|
@@ -28,12 +28,7 @@ module TestCentricity
|
|
28
28
|
# element :siebel_busy, "//html[contains(@class, 'siebui-busy')]"
|
29
29
|
#
|
30
30
|
def self.element(element_name, locator)
|
31
|
-
|
32
|
-
ivar_name = "@#{element_name}"
|
33
|
-
ivar = instance_variable_get(ivar_name)
|
34
|
-
return ivar if ivar
|
35
|
-
instance_variable_set(ivar_name, TestCentricity::UIElement.new(element_name, self, locator, :page))
|
36
|
-
end
|
31
|
+
define_page_element(element_name, TestCentricity::UIElement, locator)
|
37
32
|
end
|
38
33
|
|
39
34
|
# Declare and instantiate a collection of generic UI Elements for this page object.
|
@@ -59,12 +54,7 @@ module TestCentricity
|
|
59
54
|
# button :login_button, "//input[@id='submit_button']"
|
60
55
|
#
|
61
56
|
def self.button(element_name, locator)
|
62
|
-
|
63
|
-
ivar_name = "@#{element_name}"
|
64
|
-
ivar = instance_variable_get(ivar_name)
|
65
|
-
return ivar if ivar
|
66
|
-
instance_variable_set(ivar_name, TestCentricity::Button.new(element_name, self, locator, :page))
|
67
|
-
end
|
57
|
+
define_page_element(element_name, TestCentricity::Button, locator)
|
68
58
|
end
|
69
59
|
|
70
60
|
# Declare and instantiate a collection of buttons for this page object.
|
@@ -90,12 +80,7 @@ module TestCentricity
|
|
90
80
|
# textfield :password_field, 'consumer_password'
|
91
81
|
#
|
92
82
|
def self.textfield(element_name, locator)
|
93
|
-
|
94
|
-
ivar_name = "@#{element_name}"
|
95
|
-
ivar = instance_variable_get(ivar_name)
|
96
|
-
return ivar if ivar
|
97
|
-
instance_variable_set(ivar_name, TestCentricity::TextField.new(element_name, self, locator, :page))
|
98
|
-
end
|
83
|
+
define_page_element(element_name, TestCentricity::TextField, locator)
|
99
84
|
end
|
100
85
|
|
101
86
|
# Declare and instantiate a collection of text fields for this page object.
|
@@ -179,12 +164,7 @@ module TestCentricity
|
|
179
164
|
# label :rollup_price_label, "//div[contains(@id, 'Rollup Item Price')]"
|
180
165
|
#
|
181
166
|
def self.label(element_name, locator)
|
182
|
-
|
183
|
-
ivar_name = "@#{element_name}"
|
184
|
-
ivar = instance_variable_get(ivar_name)
|
185
|
-
return ivar if ivar
|
186
|
-
instance_variable_set(ivar_name, TestCentricity::Label.new(element_name, self, locator, :page))
|
187
|
-
end
|
167
|
+
define_page_element(element_name, TestCentricity::Label, locator)
|
188
168
|
end
|
189
169
|
|
190
170
|
def self.labels(element_hash)
|
@@ -202,12 +182,7 @@ module TestCentricity
|
|
202
182
|
# link :shopping_basket_link, "//a[@href='shopping_basket']"
|
203
183
|
#
|
204
184
|
def self.link(element_name, locator)
|
205
|
-
|
206
|
-
ivar_name = "@#{element_name}"
|
207
|
-
ivar = instance_variable_get(ivar_name)
|
208
|
-
return ivar if ivar
|
209
|
-
instance_variable_set(ivar_name, TestCentricity::Link.new(element_name, self, locator, :page))
|
210
|
-
end
|
185
|
+
define_page_element(element_name, TestCentricity::Link, locator)
|
211
186
|
end
|
212
187
|
|
213
188
|
def self.links(element_hash)
|
@@ -224,12 +199,7 @@ module TestCentricity
|
|
224
199
|
# table :payments_table, "//table[@class='payments_table']"
|
225
200
|
#
|
226
201
|
def self.table(element_name, locator)
|
227
|
-
|
228
|
-
ivar_name = "@#{element_name}"
|
229
|
-
ivar = instance_variable_get(ivar_name)
|
230
|
-
return ivar if ivar
|
231
|
-
instance_variable_set(ivar_name, TestCentricity::Table.new(element_name, self, locator, :page))
|
232
|
-
end
|
202
|
+
define_page_element(element_name, TestCentricity::Table, locator)
|
233
203
|
end
|
234
204
|
|
235
205
|
def self.tables(element_hash)
|
@@ -247,12 +217,7 @@ module TestCentricity
|
|
247
217
|
# selectlist :gender_select, "//select[@id='customer_gender']"
|
248
218
|
#
|
249
219
|
def self.selectlist(element_name, locator)
|
250
|
-
|
251
|
-
ivar_name = "@#{element_name}"
|
252
|
-
ivar = instance_variable_get(ivar_name)
|
253
|
-
return ivar if ivar
|
254
|
-
instance_variable_set(ivar_name, TestCentricity::SelectList.new(element_name, self, locator, :page))
|
255
|
-
end
|
220
|
+
define_page_element(element_name, TestCentricity::SelectList, locator)
|
256
221
|
end
|
257
222
|
|
258
223
|
def self.selectlists(element_hash)
|
@@ -269,12 +234,7 @@ module TestCentricity
|
|
269
234
|
# list :x_axis_list, 'g.x-axis'
|
270
235
|
#
|
271
236
|
def self.list(element_name, locator)
|
272
|
-
|
273
|
-
ivar_name = "@#{element_name}"
|
274
|
-
ivar = instance_variable_get(ivar_name)
|
275
|
-
return ivar if ivar
|
276
|
-
instance_variable_set(ivar_name, TestCentricity::List.new(element_name, self, locator, :page))
|
277
|
-
end
|
237
|
+
define_page_element(element_name, TestCentricity::List, locator)
|
278
238
|
end
|
279
239
|
|
280
240
|
def self.lists(element_hash)
|
@@ -292,12 +252,7 @@ module TestCentricity
|
|
292
252
|
# image :corporate_logo_image, "//img[@alt='MyCompany_logo']"
|
293
253
|
#
|
294
254
|
def self.image(element_name, locator)
|
295
|
-
|
296
|
-
ivar_name = "@#{element_name}"
|
297
|
-
ivar = instance_variable_get(ivar_name)
|
298
|
-
return ivar if ivar
|
299
|
-
instance_variable_set(ivar_name, TestCentricity::Image.new(element_name, self, locator, :page))
|
300
|
-
end
|
255
|
+
define_page_element(element_name, TestCentricity::Image, locator)
|
301
256
|
end
|
302
257
|
|
303
258
|
def self.images(element_hash)
|
@@ -314,12 +269,7 @@ module TestCentricity
|
|
314
269
|
# filefield :attach_file, 's_SweFileName'
|
315
270
|
#
|
316
271
|
def self.filefield(element_name, locator)
|
317
|
-
|
318
|
-
ivar_name = "@#{element_name}"
|
319
|
-
ivar = instance_variable_get(ivar_name)
|
320
|
-
return ivar if ivar
|
321
|
-
instance_variable_set(ivar_name, TestCentricity::FileField.new(element_name, self, locator, :page))
|
322
|
-
end
|
272
|
+
define_page_element(element_name, TestCentricity::FileField, locator)
|
323
273
|
end
|
324
274
|
|
325
275
|
def self.filefields(element_hash)
|
@@ -426,8 +376,13 @@ module TestCentricity
|
|
426
376
|
# @example
|
427
377
|
# section :search_form, SearchForm
|
428
378
|
#
|
429
|
-
def self.section(section_name,
|
430
|
-
|
379
|
+
def self.section(section_name, obj, locator = nil)
|
380
|
+
define_method(section_name) do
|
381
|
+
ivar_name = "@#{section_name}"
|
382
|
+
ivar = instance_variable_get(ivar_name)
|
383
|
+
return ivar if ivar
|
384
|
+
instance_variable_set(ivar_name, obj.new(section_name, self, "#{locator}", :page))
|
385
|
+
end
|
431
386
|
end
|
432
387
|
|
433
388
|
def self.sections(section_hash)
|
@@ -707,5 +662,16 @@ module TestCentricity
|
|
707
662
|
end
|
708
663
|
end
|
709
664
|
end
|
665
|
+
|
666
|
+
private
|
667
|
+
|
668
|
+
def self.define_page_element(element_name, obj, locator)
|
669
|
+
define_method(element_name) do
|
670
|
+
ivar_name = "@#{element_name}"
|
671
|
+
ivar = instance_variable_get(ivar_name)
|
672
|
+
return ivar if ivar
|
673
|
+
instance_variable_set(ivar_name, obj.new(element_name, self, locator, :page))
|
674
|
+
end
|
675
|
+
end
|
710
676
|
end
|
711
677
|
end
|
@@ -140,12 +140,7 @@ module TestCentricity
|
|
140
140
|
# element :basket_header, 'div.basket_header'
|
141
141
|
#
|
142
142
|
def self.element(element_name, locator)
|
143
|
-
|
144
|
-
ivar_name = "@#{element_name}"
|
145
|
-
ivar = instance_variable_get(ivar_name)
|
146
|
-
return ivar if ivar
|
147
|
-
instance_variable_set(ivar_name, TestCentricity::UIElement.new(element_name, self, locator, :section))
|
148
|
-
end
|
143
|
+
define_element(element_name, TestCentricity::UIElement, locator)
|
149
144
|
end
|
150
145
|
|
151
146
|
# Declare and instantiate a collection of generic UI Elements for this page section.
|
@@ -171,12 +166,7 @@ module TestCentricity
|
|
171
166
|
# button :login_button, "//input[@id='submit_button']"
|
172
167
|
#
|
173
168
|
def self.button(element_name, locator)
|
174
|
-
|
175
|
-
ivar_name = "@#{element_name}"
|
176
|
-
ivar = instance_variable_get(ivar_name)
|
177
|
-
return ivar if ivar
|
178
|
-
instance_variable_set(ivar_name, TestCentricity::Button.new(element_name, self, locator, :section))
|
179
|
-
end
|
169
|
+
define_element(element_name, TestCentricity::Button, locator)
|
180
170
|
end
|
181
171
|
|
182
172
|
# Declare and instantiate a collection of buttons for this page section.
|
@@ -202,12 +192,7 @@ module TestCentricity
|
|
202
192
|
# textfield :password_field, 'input#consumer_password'
|
203
193
|
#
|
204
194
|
def self.textfield(element_name, locator)
|
205
|
-
|
206
|
-
ivar_name = "@#{element_name}"
|
207
|
-
ivar = instance_variable_get(ivar_name)
|
208
|
-
return ivar if ivar
|
209
|
-
instance_variable_set(ivar_name, TestCentricity::TextField.new(element_name, self, locator, :section))
|
210
|
-
end
|
195
|
+
define_element(element_name, TestCentricity::TextField, locator)
|
211
196
|
end
|
212
197
|
|
213
198
|
# Declare and instantiate a collection of text fields for this page section.
|
@@ -291,12 +276,7 @@ module TestCentricity
|
|
291
276
|
# label :rollup_price_label, "//div[contains(@id, 'Rollup Item Price')]"
|
292
277
|
#
|
293
278
|
def self.label(element_name, locator)
|
294
|
-
|
295
|
-
ivar_name = "@#{element_name}"
|
296
|
-
ivar = instance_variable_get(ivar_name)
|
297
|
-
return ivar if ivar
|
298
|
-
instance_variable_set(ivar_name, TestCentricity::Label.new(element_name, self, locator, :section))
|
299
|
-
end
|
279
|
+
define_element(element_name, TestCentricity::Label, locator)
|
300
280
|
end
|
301
281
|
|
302
282
|
def self.labels(element_hash)
|
@@ -314,12 +294,7 @@ module TestCentricity
|
|
314
294
|
# link :shopping_basket_link, "//a[@href='shopping_basket']"
|
315
295
|
#
|
316
296
|
def self.link(element_name, locator)
|
317
|
-
|
318
|
-
ivar_name = "@#{element_name}"
|
319
|
-
ivar = instance_variable_get(ivar_name)
|
320
|
-
return ivar if ivar
|
321
|
-
instance_variable_set(ivar_name, TestCentricity::Link.new(element_name, self, locator, :section))
|
322
|
-
end
|
297
|
+
define_element(element_name, TestCentricity::Link, locator)
|
323
298
|
end
|
324
299
|
|
325
300
|
def self.links(element_hash)
|
@@ -336,12 +311,7 @@ module TestCentricity
|
|
336
311
|
# table :payments_table, "//table[@class='payments_table']"
|
337
312
|
#
|
338
313
|
def self.table(element_name, locator)
|
339
|
-
|
340
|
-
ivar_name = "@#{element_name}"
|
341
|
-
ivar = instance_variable_get(ivar_name)
|
342
|
-
return ivar if ivar
|
343
|
-
instance_variable_set(ivar_name, TestCentricity::Table.new(element_name, self, locator, :section))
|
344
|
-
end
|
314
|
+
define_element(element_name, TestCentricity::Table, locator)
|
345
315
|
end
|
346
316
|
|
347
317
|
def self.tables(element_hash)
|
@@ -359,12 +329,7 @@ module TestCentricity
|
|
359
329
|
# selectlist :gender_select, "//select[@id='customer_gender']"
|
360
330
|
#
|
361
331
|
def self.selectlist(element_name, locator)
|
362
|
-
|
363
|
-
ivar_name = "@#{element_name}"
|
364
|
-
ivar = instance_variable_get(ivar_name)
|
365
|
-
return ivar if ivar
|
366
|
-
instance_variable_set(ivar_name, TestCentricity::SelectList.new(element_name, self, locator, :section))
|
367
|
-
end
|
332
|
+
define_element(element_name, TestCentricity::SelectList, locator)
|
368
333
|
end
|
369
334
|
|
370
335
|
def self.selectlists(element_hash)
|
@@ -381,12 +346,7 @@ module TestCentricity
|
|
381
346
|
# list :y_axis_list, 'g.y_axis'
|
382
347
|
#
|
383
348
|
def self.list(element_name, locator)
|
384
|
-
|
385
|
-
ivar_name = "@#{element_name}"
|
386
|
-
ivar = instance_variable_get(ivar_name)
|
387
|
-
return ivar if ivar
|
388
|
-
instance_variable_set(ivar_name, TestCentricity::List.new(element_name, self, locator, :section))
|
389
|
-
end
|
349
|
+
define_element(element_name, TestCentricity::List, locator)
|
390
350
|
end
|
391
351
|
|
392
352
|
def self.lists(element_hash)
|
@@ -404,12 +364,7 @@ module TestCentricity
|
|
404
364
|
# image :corporate_logo_image, "//img[@alt='MyCompany_logo']"
|
405
365
|
#
|
406
366
|
def self.image(element_name, locator)
|
407
|
-
|
408
|
-
ivar_name = "@#{element_name}"
|
409
|
-
ivar = instance_variable_get(ivar_name)
|
410
|
-
return ivar if ivar
|
411
|
-
instance_variable_set(ivar_name, TestCentricity::Image.new(element_name, self, locator, :section))
|
412
|
-
end
|
367
|
+
define_element(element_name, TestCentricity::Image, locator)
|
413
368
|
end
|
414
369
|
|
415
370
|
def self.images(element_hash)
|
@@ -426,12 +381,7 @@ module TestCentricity
|
|
426
381
|
# filefield :attach_file, 's_SweFileName'
|
427
382
|
#
|
428
383
|
def self.filefield(element_name, locator)
|
429
|
-
|
430
|
-
ivar_name = "@#{element_name}"
|
431
|
-
ivar = instance_variable_get(ivar_name)
|
432
|
-
return ivar if ivar
|
433
|
-
instance_variable_set(ivar_name, TestCentricity::FileField.new(element_name, self, locator, :section))
|
434
|
-
end
|
384
|
+
define_element(element_name, TestCentricity::FileField, locator)
|
435
385
|
end
|
436
386
|
|
437
387
|
def self.filefields(element_hash)
|
@@ -538,8 +488,13 @@ module TestCentricity
|
|
538
488
|
# @example
|
539
489
|
# section :search_form, SearchForm
|
540
490
|
#
|
541
|
-
def self.section(section_name,
|
542
|
-
|
491
|
+
def self.section(section_name, obj, locator = nil)
|
492
|
+
define_method(section_name) do
|
493
|
+
ivar_name = "@#{section_name}"
|
494
|
+
ivar = instance_variable_get(ivar_name)
|
495
|
+
return ivar if ivar
|
496
|
+
instance_variable_set(ivar_name, obj.new(section_name, self, "#{locator}", :section))
|
497
|
+
end
|
543
498
|
end
|
544
499
|
|
545
500
|
def self.sections(section_hash)
|
@@ -928,5 +883,13 @@ module TestCentricity
|
|
928
883
|
raise ObjectNotFoundError.new("Section object '#{get_name}' (#{get_locator}) not found") unless section
|
929
884
|
end
|
930
885
|
|
886
|
+
def self.define_element(element_name, obj, locator)
|
887
|
+
define_method(element_name) do
|
888
|
+
ivar_name = "@#{element_name}"
|
889
|
+
ivar = instance_variable_get(ivar_name)
|
890
|
+
return ivar if ivar
|
891
|
+
instance_variable_set(ivar_name, obj.new(element_name, self, locator, :section))
|
892
|
+
end
|
893
|
+
end
|
931
894
|
end
|
932
895
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: testcentricity
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.4.
|
4
|
+
version: 2.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- A.J. Mrozinski
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-03-
|
11
|
+
date: 2018-03-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|