rudra 1.0.10 → 1.0.11
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/rudra.rb +23 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ae7539f155394408468d62875d70502f0dc97bdf7577d926a917267d5951a78
|
4
|
+
data.tar.gz: 6b3e57e84fa94e8e89b8bd53a5c6ac237845706b4758c0e48fa0205a2a4c79fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d24d67bbfc9be2fde7b6af2a2d95bf74e6a0465b14aff0bd657c0efdfd307d6cdd2271e9a22efc066fc350865c47fac50d72c91845cc9440592b26ad2e8f9cce
|
7
|
+
data.tar.gz: 96be2126fc9b70f42077aaafec4391993023e702798b5af90fe724aa8a089084748a77f0481986700ee404f11365da61f2c6ad550dddb94c4b5d035f07830d53
|
data/lib/rudra.rb
CHANGED
@@ -25,7 +25,7 @@ class Rudra
|
|
25
25
|
].freeze
|
26
26
|
|
27
27
|
attr_reader :browser, :driver, :install_dir, :locale,
|
28
|
-
:log_prefix, :timeout, :verbose
|
28
|
+
:headless, :log_prefix, :timeout, :verbose
|
29
29
|
|
30
30
|
# Initialize an instance of Rudra
|
31
31
|
# @param [Hash] options the options to initialize Rudra
|
@@ -34,6 +34,7 @@ class Rudra
|
|
34
34
|
# @option options [String] :install_dir ('./webdrivers/') the install
|
35
35
|
# directory of WebDrivers
|
36
36
|
# @option options [Symbol] :locale (:en) the browser locale
|
37
|
+
# @option options [Boolean] :headless (false) headless mode
|
37
38
|
# @option options [String] :log_prefix (' - ') log prefix
|
38
39
|
# @option options [Integer] :timeout (30) implicit_wait timeout
|
39
40
|
# @option options [Boolean] :verbose (true) verbose mode
|
@@ -41,6 +42,7 @@ class Rudra
|
|
41
42
|
self.browser = options.fetch(:browser, :chrome)
|
42
43
|
self.install_dir = options.fetch(:install_dir, './webdrivers/')
|
43
44
|
self.locale = options.fetch(:locale, :en)
|
45
|
+
self.headless = options.fetch(:headless, false)
|
44
46
|
self.log_prefix = options.fetch(:log_prefix, ' - ')
|
45
47
|
self.verbose = options.fetch(:verbose, true)
|
46
48
|
|
@@ -357,6 +359,14 @@ class Rudra
|
|
357
359
|
Selenium::WebDriver::Wait.new(timeout: seconds).until { yield }
|
358
360
|
end
|
359
361
|
|
362
|
+
# Wait until the element, identified by locator, is enabled
|
363
|
+
# @param [String, Selenium::WebDriver::Element] locator the locator to
|
364
|
+
# identify the element or Selenium::WebDriver::Element
|
365
|
+
def wait_for_enabled(locator)
|
366
|
+
log(locator)
|
367
|
+
wait_for { find_element(locator).enabled? }
|
368
|
+
end
|
369
|
+
|
360
370
|
# Wait until the title of the page including the given string
|
361
371
|
# @param [String] string the string to compare
|
362
372
|
def wait_for_title(string)
|
@@ -1176,6 +1186,10 @@ class Rudra
|
|
1176
1186
|
end
|
1177
1187
|
end
|
1178
1188
|
|
1189
|
+
def headless=(mode)
|
1190
|
+
@headless = true?(mode)
|
1191
|
+
end
|
1192
|
+
|
1179
1193
|
def log_prefix=(prefix)
|
1180
1194
|
@log_prefix = prefix.chomp
|
1181
1195
|
end
|
@@ -1188,7 +1202,11 @@ class Rudra
|
|
1188
1202
|
end
|
1189
1203
|
|
1190
1204
|
def verbose=(mode)
|
1191
|
-
@verbose =
|
1205
|
+
@verbose = true?(mode)
|
1206
|
+
end
|
1207
|
+
|
1208
|
+
def true?(mode)
|
1209
|
+
[1, true, '1', 'true'].include?(mode)
|
1192
1210
|
end
|
1193
1211
|
|
1194
1212
|
def initialize_driver
|
@@ -1203,8 +1221,8 @@ class Rudra
|
|
1203
1221
|
|
1204
1222
|
def chrome_options
|
1205
1223
|
options = Selenium::WebDriver::Chrome::Options.new
|
1206
|
-
options.add_argument('disable-
|
1207
|
-
options.add_argument('
|
1224
|
+
options.add_argument('--disable-notifications')
|
1225
|
+
options.add_argument('--headless') if headless
|
1208
1226
|
options.add_preference('intl.accept_languages', locale)
|
1209
1227
|
options
|
1210
1228
|
end
|
@@ -1212,6 +1230,7 @@ class Rudra
|
|
1212
1230
|
def firefox_options
|
1213
1231
|
options = Selenium::WebDriver::Firefox::Options.new
|
1214
1232
|
options.add_preference('intl.accept_languages', locale)
|
1233
|
+
options.add_argument('--headless') if headless
|
1215
1234
|
options
|
1216
1235
|
end
|
1217
1236
|
|