bucky-core 0.9.12 → 0.9.13
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/Gemfile.lock +1 -1
- data/lib/bucky/test_equipment/pageobject/base_pageobject.rb +6 -2
- data/lib/bucky/test_equipment/selenium_handler/wait_handler.rb +21 -0
- data/lib/bucky/test_equipment/user_operation/user_operation_helper.rb +11 -13
- data/lib/bucky/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b9ddfb233321416ab533a5e156cd947f0d5e44b
|
4
|
+
data.tar.gz: d2eb7b14ed2c76e537312f701fe93ae45bfb4b43
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 13028e8366556af56000d2f0a96b3b4c523a7b6ff4e62e98fd6147d33bee5100f35742e6f232d5394435e3a0e446fd434cc36b73bd56796619ed0c94c53d17da
|
7
|
+
data.tar.gz: f0350162e227a603748e2371f69656bb3be679e07bdaba669843613f9b7925a6a260a3aed39d07b65f4c7c9f13c562b750ee1e4dfdcae42989d231468686dede
|
data/Gemfile.lock
CHANGED
@@ -2,11 +2,14 @@
|
|
2
2
|
|
3
3
|
require_relative '../../utils/yaml_load'
|
4
4
|
require_relative '../../core/exception/bucky_exception'
|
5
|
+
require_relative '../selenium_handler/wait_handler'
|
6
|
+
|
5
7
|
module Bucky
|
6
8
|
module TestEquipment
|
7
9
|
module PageObject
|
8
10
|
class BasePageObject
|
9
11
|
include Bucky::Utils::YamlLoad
|
12
|
+
include Bucky::TestEquipment::SeleniumHandler::WaitHandler
|
10
13
|
|
11
14
|
# https://seleniumhq.github.io/selenium/docs/api/rb/Selenium/WebDriver/SearchContext.html#find_element-instance_method
|
12
15
|
FINDERS = {
|
@@ -52,7 +55,8 @@ module Bucky
|
|
52
55
|
method_name = method.downcase.to_sym
|
53
56
|
raise StandardError, "Invalid finder. #{method_name}" unless FINDERS.key? method_name
|
54
57
|
|
55
|
-
|
58
|
+
# wait until driver find element
|
59
|
+
elements = wait_until_helper(3, 0.1, Selenium::WebDriver::Error::NoSuchElementError) { @driver.find_elements(method_name, value) }
|
56
60
|
raise_if_elements_empty(elements, method_name, value)
|
57
61
|
|
58
62
|
get_element_or_attribute = lambda do |elems, arg|
|
@@ -67,7 +71,7 @@ module Bucky
|
|
67
71
|
|
68
72
|
elements.first.instance_eval do
|
69
73
|
define_singleton_method('[]') { |arg| get_element_or_attribute.call(elements, arg) }
|
70
|
-
%w[each length].each { |m| define_singleton_method(m) { elements.send(m) } }
|
74
|
+
%w[each length].each { |m| define_singleton_method(m) { |&block| elements.send(m, &block) } }
|
71
75
|
end
|
72
76
|
|
73
77
|
elements.first
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'selenium-webdriver'
|
4
|
+
require 'English'
|
5
|
+
|
6
|
+
module Bucky
|
7
|
+
module TestEquipment
|
8
|
+
module SeleniumHandler
|
9
|
+
module WaitHandler
|
10
|
+
module_function
|
11
|
+
|
12
|
+
def wait_until_helper(timeout, interval, ignore, &block)
|
13
|
+
wait = Selenium::WebDriver::Wait.new(timeout: timeout, interval: interval, ignore: [ignore])
|
14
|
+
wait.until { block.call }
|
15
|
+
rescue Selenium::WebDriver::Error::TimeoutError
|
16
|
+
raise ignore, "Wait until the limit times for #{caller[1][/`([^']*)'/, 1]}\n #{$ERROR_INFO.message}"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -1,9 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative '../selenium_handler/wait_handler'
|
4
|
+
|
3
5
|
module Bucky
|
4
6
|
module TestEquipment
|
5
7
|
module UserOperation
|
6
8
|
class UserOperationHelper
|
9
|
+
include Bucky::TestEquipment::SeleniumHandler::WaitHandler
|
10
|
+
|
7
11
|
def initialize(args)
|
8
12
|
@app = args[:app]
|
9
13
|
@device = args[:device]
|
@@ -33,8 +37,8 @@ module Bucky
|
|
33
37
|
def click(args)
|
34
38
|
elem = @pages.get_part(args)
|
35
39
|
elem.location_once_scrolled_into_view
|
36
|
-
|
37
|
-
elem.click
|
40
|
+
# when click successfully, return of click is nil.
|
41
|
+
wait_until_helper(5, 0.1, Selenium::WebDriver::Error::WebDriverError) { elem.click.nil? }
|
38
42
|
end
|
39
43
|
|
40
44
|
def refresh(_)
|
@@ -50,14 +54,8 @@ module Bucky
|
|
50
54
|
end
|
51
55
|
|
52
56
|
def switch_to_the_window(args)
|
53
|
-
#
|
54
|
-
|
55
|
-
begin
|
56
|
-
# when the window successfully switched, return of switch_to.window is nil.
|
57
|
-
wait.until{ @driver.switch_to.window(args[:window_name]).nil? }
|
58
|
-
rescue Selenium::WebDriver::Error::TimeoutError
|
59
|
-
raise Selenium::WebDriver::Error::TimeoutError, "Exceeded the limit for trying switch_to_the_window.\n #{$ERROR_INFO.message}"
|
60
|
-
end
|
57
|
+
# when the window successfully switched, return of switch_to.window is nil.
|
58
|
+
wait_until_helper(5, 0.1, Selenium::WebDriver::Error::NoSuchWindowError) { @driver.switch_to.window(args[:window_name]).nil? }
|
61
59
|
end
|
62
60
|
|
63
61
|
# Close window
|
@@ -71,7 +69,7 @@ module Bucky
|
|
71
69
|
end
|
72
70
|
|
73
71
|
def choose(args)
|
74
|
-
option = Selenium::WebDriver::Support::Select.new(@pages.get_part(args))
|
72
|
+
option = wait_until_helper(5, 0.1, Selenium::WebDriver::Error::StaleElementReferenceError) { Selenium::WebDriver::Support::Select.new(@pages.get_part(args)) }
|
75
73
|
if args.key?(:text)
|
76
74
|
type = :text
|
77
75
|
selected = args[type].to_s
|
@@ -89,8 +87,8 @@ module Bucky
|
|
89
87
|
|
90
88
|
# Alert accept
|
91
89
|
def accept_alert(_)
|
92
|
-
|
93
|
-
|
90
|
+
alert = wait_until_helper(5, 0.1, Selenium::WebDriver::Error::NoAlertPresentError) { @driver.switch_to.alert }
|
91
|
+
alert.accept
|
94
92
|
end
|
95
93
|
|
96
94
|
def wait(args)
|
data/lib/bucky/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bucky-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- NaotoKishino
|
@@ -13,7 +13,7 @@ authors:
|
|
13
13
|
autorequire:
|
14
14
|
bindir: exe
|
15
15
|
cert_chain: []
|
16
|
-
date: 2019-07-
|
16
|
+
date: 2019-07-12 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: awesome_print
|
@@ -364,6 +364,7 @@ files:
|
|
364
364
|
- lib/bucky/test_equipment/evidence/evidence_generator.rb
|
365
365
|
- lib/bucky/test_equipment/pageobject/base_pageobject.rb
|
366
366
|
- lib/bucky/test_equipment/pageobject/pages.rb
|
367
|
+
- lib/bucky/test_equipment/selenium_handler/wait_handler.rb
|
367
368
|
- lib/bucky/test_equipment/selenium_handler/webdriver_handler.rb
|
368
369
|
- lib/bucky/test_equipment/test_case/abst_test_case.rb
|
369
370
|
- lib/bucky/test_equipment/test_case/e2e_test_case.rb
|