rutl 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/.rubocop_todo.yml +13 -6
- data/lib/rutl/browser.rb +2 -2
- data/lib/rutl/camera.rb +1 -1
- data/lib/rutl/element/element.rb +2 -2
- data/lib/rutl/element/element_context.rb +32 -30
- data/lib/rutl/interface/base.rb +93 -0
- data/lib/rutl/interface/chrome.rb +36 -0
- data/lib/rutl/interface/firefox.rb +29 -0
- data/lib/rutl/interface/null.rb +35 -0
- data/lib/rutl/null_driver/null_element.rb +1 -2
- data/lib/rutl/page.rb +2 -2
- data/lib/rutl/version.rb +1 -1
- metadata +5 -5
- data/lib/rutl/interface/base_interface.rb +0 -90
- data/lib/rutl/interface/chrome_interface.rb +0 -34
- data/lib/rutl/interface/firefox_interface.rb +0 -27
- data/lib/rutl/interface/null_interface.rb +0 -33
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 21fa6d406b33dee3134e1cf6da770e4f51434664d55d109b19858290ec5f0776
|
4
|
+
data.tar.gz: ab14d6f097caa9bbdc888ca8409c711fed65da87129bbcb03f96fa265aa5df34
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c81506c59bc5224d50928351455241d83123cfb7d2ff3a8383b0aad7e0914ede6f20128e5dbe34d87743c0575ac33972b517a2506f51292a32dad64b29abc03
|
7
|
+
data.tar.gz: 2e99c3d93ae8cd9af232ffc26d214866f649cd2d295a553818e835e6e7b0ee3abd4f805741fefbfd85a910251451358309435fe3c6bd4bdc4419868cc667203c
|
data/.rubocop.yml
CHANGED
@@ -40,7 +40,7 @@ Style/BracesAroundHashParameters:
|
|
40
40
|
# And BasePage does @@loaded_pages.
|
41
41
|
Style/ClassVars:
|
42
42
|
Exclude:
|
43
|
-
- 'lib/rutl/
|
43
|
+
- 'lib/rutl/null_driver/null_element.rb'
|
44
44
|
- 'lib/rutl/base_page.rb'
|
45
45
|
|
46
46
|
# Rubocop flags lots of things as useless assignment when they're actually
|
data/.rubocop_todo.yml
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on 2018-06-07
|
3
|
+
# on 2018-06-07 20:55:18 -0700 using RuboCop version 0.56.0.
|
4
4
|
# The point is for the user to remove these configuration records
|
5
5
|
# one by one as the offenses are removed from the code base.
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
@@ -11,19 +11,26 @@
|
|
11
11
|
Metrics/MethodLength:
|
12
12
|
Max: 11
|
13
13
|
|
14
|
+
# Offense count: 2
|
15
|
+
Style/ClassVars:
|
16
|
+
Exclude:
|
17
|
+
- 'lib/rutl/driver/null_driver_page_element.rb'
|
18
|
+
- 'lib/rutl/base_page.rb'
|
19
|
+
- 'lib/rutl/null_driver/null_element.rb'
|
20
|
+
|
14
21
|
# Offense count: 4
|
15
22
|
# Configuration parameters: AllowedVariables.
|
16
23
|
Style/GlobalVars:
|
17
24
|
Exclude:
|
18
25
|
- 'lib/rutl/browser.rb'
|
19
|
-
- 'lib/rutl/
|
20
|
-
- 'lib/rutl/
|
21
|
-
- 'lib/rutl/interface/
|
26
|
+
- 'lib/rutl/element/element.rb'
|
27
|
+
- 'lib/rutl/element/element_context.rb'
|
28
|
+
- 'lib/rutl/interface/null.rb'
|
22
29
|
|
23
30
|
# Offense count: 4
|
24
31
|
Style/MethodMissingSuper:
|
25
32
|
Exclude:
|
26
33
|
- 'lib/rutl/browser.rb'
|
27
|
-
- 'lib/rutl/
|
28
|
-
- 'lib/rutl/interface/
|
34
|
+
- 'lib/rutl/element/element.rb'
|
35
|
+
- 'lib/rutl/interface/base.rb'
|
29
36
|
- 'lib/rutl/page.rb'
|
data/lib/rutl/browser.rb
CHANGED
@@ -38,8 +38,8 @@ module RUTL
|
|
38
38
|
private
|
39
39
|
|
40
40
|
def load_interface(type)
|
41
|
-
require "rutl/interface/#{type}
|
42
|
-
klass = "RUTL::#{type.to_s.capitalize}
|
41
|
+
require "rutl/interface/#{type}"
|
42
|
+
klass = "RUTL::Interface::#{type.to_s.capitalize}"
|
43
43
|
Object.const_get(klass).new
|
44
44
|
end
|
45
45
|
|
data/lib/rutl/camera.rb
CHANGED
data/lib/rutl/element/element.rb
CHANGED
@@ -13,8 +13,8 @@ module RUTL
|
|
13
13
|
# passed in isn't the same as the browser's interface.
|
14
14
|
# This only happens with click test cases, before the click, and
|
15
15
|
# only if that case isn't run first.
|
16
|
-
# The context we're passed is also an instance from as
|
17
|
-
# but a different instance.
|
16
|
+
# The context we're passed is also an instance from as
|
17
|
+
# RUTL::Interface::Chrome, but a different instance.
|
18
18
|
#
|
19
19
|
# Here's the kludge workaround line:
|
20
20
|
@context.interface = $browser.interface
|
@@ -1,38 +1,40 @@
|
|
1
1
|
module RUTL
|
2
2
|
module Element
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
3
|
+
#
|
4
|
+
# The context passed around to all elements.
|
5
|
+
# What they need to know outside of themselves to function.
|
6
|
+
#
|
7
|
+
class ElementContext
|
8
|
+
# Nil. Or an Array. One would hope an Array of states.
|
9
|
+
# But I'm not checking.
|
10
|
+
attr_accessor :destinations
|
11
|
+
# Nil. Or a RUTL::Interface::Base.
|
12
|
+
attr_accessor :interface
|
13
|
+
# An Arrray, maybe empty and maybe an array of selectors.
|
14
|
+
# TODO: This should be a hash.
|
15
|
+
attr_accessor :selectors
|
15
16
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
17
|
+
def initialize(destinations: nil, interface: nil, selectors: [])
|
18
|
+
unless destinations.nil? || destinations.class == Array
|
19
|
+
# Should check each destination to make sure it's a
|
20
|
+
# Page or a _____, too.
|
21
|
+
raise 'destination must be an Array of destinations or nil.'
|
22
|
+
end
|
23
|
+
@destinations = destinations || []
|
24
|
+
unless interface.nil? || interface.is_a?(RUTL::Interface::Base)
|
25
|
+
raise "#{interface.class}: #{interface} " \
|
26
|
+
'must be an Interface::* class.'
|
27
|
+
end
|
28
|
+
@interface = interface
|
29
|
+
@selectors = selectors
|
21
30
|
end
|
22
|
-
@destinations = destinations || []
|
23
|
-
unless interface.nil? || interface.is_a?(RUTL::BaseInterface)
|
24
|
-
raise "#{interface.class}: #{interface} must be a *Interface class."
|
25
|
-
end
|
26
|
-
@interface = interface
|
27
|
-
@selectors = selectors
|
28
|
-
end
|
29
31
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
32
|
+
def find_element(type)
|
33
|
+
# @interface.driver.find_element(type, @selectors[type])
|
34
|
+
# Should be this, but apparently @interface.driver is being overwritten
|
35
|
+
# (or not written to) and it doesn't work. Using $browser does. :-(
|
36
|
+
$browser.interface.driver.find_element(type, @selectors[type])
|
37
|
+
end
|
35
38
|
end
|
36
39
|
end
|
37
40
|
end
|
38
|
-
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
require 'utilities'
|
2
|
+
require 'rutl/camera'
|
3
|
+
|
4
|
+
module RUTL
|
5
|
+
module Interface
|
6
|
+
#
|
7
|
+
# I might need to consider renaming these.
|
8
|
+
# The *interface classes lie between Browser
|
9
|
+
# and the webdriver-level classes.
|
10
|
+
#
|
11
|
+
class Base
|
12
|
+
include Utilities
|
13
|
+
|
14
|
+
# RUTL::Driver
|
15
|
+
attr_accessor :driver
|
16
|
+
|
17
|
+
# RUTL::Camera
|
18
|
+
attr_accessor :camera
|
19
|
+
|
20
|
+
# Array of all RUTL::Page classes
|
21
|
+
attr_accessor :pages
|
22
|
+
|
23
|
+
def initialize
|
24
|
+
raise 'Child interface class must set @driver.' if @driver.nil?
|
25
|
+
# base_name avoids collisions when unning the same tests with
|
26
|
+
# different browsers.
|
27
|
+
name = self.class.to_s.sub('RUTL::Interface', '')
|
28
|
+
@camera = Camera.new(@driver, base_name: name)
|
29
|
+
end
|
30
|
+
|
31
|
+
# Attempts to navigate to the page.
|
32
|
+
# Takes screenshot if successful.
|
33
|
+
def goto(page)
|
34
|
+
raise 'expect Page class' unless page?(page)
|
35
|
+
find_page(page).go_to_here
|
36
|
+
@camera.screenshot
|
37
|
+
end
|
38
|
+
|
39
|
+
# Should define in children; raises here.
|
40
|
+
# Should return the current page class.
|
41
|
+
def current_page
|
42
|
+
raise 'define in child classes'
|
43
|
+
end
|
44
|
+
|
45
|
+
def method_missing(method, *args, &block)
|
46
|
+
if args.empty?
|
47
|
+
current_page.send(method)
|
48
|
+
else
|
49
|
+
current_page.send(method, *args, &block)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
# TODO: Is this needed? I not only find the page but also make sure the
|
54
|
+
# urls match. Even though that's what finding pages means?
|
55
|
+
def find_state(target_states)
|
56
|
+
target_states.each do |state|
|
57
|
+
next unless state.url == current_page.url
|
58
|
+
page = find_page(state)
|
59
|
+
return page if page.loaded?
|
60
|
+
end
|
61
|
+
false
|
62
|
+
end
|
63
|
+
|
64
|
+
# Attempts to find page by class or url.
|
65
|
+
def find_page(page)
|
66
|
+
@pages.each do |p|
|
67
|
+
return p if page?(page) && p.class == page
|
68
|
+
return p if String == page.class && page == p.url
|
69
|
+
end
|
70
|
+
raise "Page \"#{page}\" not found in pages #{@pages}"
|
71
|
+
end
|
72
|
+
|
73
|
+
# Calls the polling utility mathod await() with a lambda trying to
|
74
|
+
# find the next state, probably a Page class.
|
75
|
+
def wait_for_transition(target_states)
|
76
|
+
#
|
77
|
+
# TODO: Should also see if there are other things to wait for.
|
78
|
+
# I don't think this is doing page load time.
|
79
|
+
#
|
80
|
+
await -> { find_state target_states }
|
81
|
+
end
|
82
|
+
|
83
|
+
def respond_to_missing?(*args)
|
84
|
+
# This can't be right. Figure it out later.
|
85
|
+
current_page.respond_to?(*args)
|
86
|
+
end
|
87
|
+
|
88
|
+
def quit
|
89
|
+
@driver.quit
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'selenium-webdriver'
|
2
|
+
require 'rutl/interface/base'
|
3
|
+
|
4
|
+
module RUTL
|
5
|
+
module Interface
|
6
|
+
#
|
7
|
+
# Small interface for Chrome browser.
|
8
|
+
#
|
9
|
+
class Chrome < Base
|
10
|
+
# rubocop:disable Metrics/MethodLength
|
11
|
+
def initialize
|
12
|
+
@logged_in = true
|
13
|
+
options = Selenium::WebDriver::Chrome::Options.new
|
14
|
+
options.add_argument('--ignore-certificate-errors')
|
15
|
+
options.add_argument('--disable-popup-blocking')
|
16
|
+
options.add_argument('--disable-translate')
|
17
|
+
# Run headless on TravisCI
|
18
|
+
if ENV['TRAVIS'] == 'true'
|
19
|
+
options.add_argument('--disable-gpu')
|
20
|
+
options.add_argument('--headless ')
|
21
|
+
options.add_argument('--no-sandbox')
|
22
|
+
end
|
23
|
+
@driver = Selenium::WebDriver.for :chrome, options: options
|
24
|
+
super
|
25
|
+
end
|
26
|
+
# rubocop:enable Metrics/MethodLength
|
27
|
+
|
28
|
+
def current_page
|
29
|
+
url = @driver.current_url
|
30
|
+
page = find_page(url)
|
31
|
+
raise "PAGE NOT FOUND: #{url}, PAGES: #{@pages}" unless page
|
32
|
+
page
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'selenium-webdriver'
|
2
|
+
require 'rutl/interface/base'
|
3
|
+
|
4
|
+
module RUTL
|
5
|
+
module Interface
|
6
|
+
#
|
7
|
+
# Small interface for Chrome browser.
|
8
|
+
#
|
9
|
+
class Firefox < Base
|
10
|
+
def initialize
|
11
|
+
@logged_in = true
|
12
|
+
options = Selenium::WebDriver::Firefox::Options.new
|
13
|
+
options.add_argument('--ignore-certificate-errors')
|
14
|
+
options.add_argument('--disable-popup-blocking')
|
15
|
+
options.add_argument('--disable-translate')
|
16
|
+
options.add_argument('--headless') if ENV['TRAVIS'] == 'true'
|
17
|
+
@driver = Selenium::WebDriver.for :firefox, options: options
|
18
|
+
super
|
19
|
+
end
|
20
|
+
|
21
|
+
def current_page
|
22
|
+
url = @driver.current_url
|
23
|
+
page = find_page(url)
|
24
|
+
raise "PAGE NOT FOUND: #{url}, PAGES: #{@pages}" unless page
|
25
|
+
page
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'rutl/interface/base'
|
2
|
+
|
3
|
+
module RUTL
|
4
|
+
module Interface
|
5
|
+
#
|
6
|
+
# Interface-level code for fake browser.
|
7
|
+
#
|
8
|
+
class Null < Base
|
9
|
+
def initialize
|
10
|
+
context = RUTL::Element::ElementContext.new(destinations: nil,
|
11
|
+
interface: self,
|
12
|
+
selectors: [])
|
13
|
+
@driver = NullDriver.new(context)
|
14
|
+
super
|
15
|
+
end
|
16
|
+
|
17
|
+
# The null driver needs to talk to the null interface.
|
18
|
+
# Other driver/interface relations are not like this.
|
19
|
+
attr_writer :current_page
|
20
|
+
|
21
|
+
def current_page
|
22
|
+
# Default to @pages.first if not set?
|
23
|
+
# A browser can always check its current URL but the null driver can't.
|
24
|
+
@current_page ||= @pages.first
|
25
|
+
end
|
26
|
+
|
27
|
+
def wait_for_transition(destinations)
|
28
|
+
# TODO: Setting @current page didn't do it beacause that set
|
29
|
+
# context.interface.current_page and we wanted this in the browser.
|
30
|
+
@current_page = destinations.first.new(self)
|
31
|
+
$browser.current_page = @current_page
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/lib/rutl/page.rb
CHANGED
@@ -84,8 +84,8 @@ module RUTL
|
|
84
84
|
def method_missing(element, *args, &_block)
|
85
85
|
name, selectors, rest = args
|
86
86
|
context = RUTL::Element::ElementContext.new(destinations: rest,
|
87
|
-
|
88
|
-
|
87
|
+
interface: @interface,
|
88
|
+
selectors: selectors)
|
89
89
|
case element
|
90
90
|
when /button/, /checkbox/, /element/, /link/
|
91
91
|
add_method(name: name, context: context, klass: element)
|
data/lib/rutl/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rutl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Drew Cooper
|
@@ -198,10 +198,10 @@ files:
|
|
198
198
|
- lib/rutl/element/link.rb
|
199
199
|
- lib/rutl/element/string_reader_writer_mixin.rb
|
200
200
|
- lib/rutl/element/text.rb
|
201
|
-
- lib/rutl/interface/
|
202
|
-
- lib/rutl/interface/
|
203
|
-
- lib/rutl/interface/
|
204
|
-
- lib/rutl/interface/
|
201
|
+
- lib/rutl/interface/base.rb
|
202
|
+
- lib/rutl/interface/chrome.rb
|
203
|
+
- lib/rutl/interface/firefox.rb
|
204
|
+
- lib/rutl/interface/null.rb
|
205
205
|
- lib/rutl/null_driver/null_driver.rb
|
206
206
|
- lib/rutl/null_driver/null_element.rb
|
207
207
|
- lib/rutl/page.rb
|
@@ -1,90 +0,0 @@
|
|
1
|
-
require 'utilities'
|
2
|
-
require 'rutl/camera'
|
3
|
-
|
4
|
-
module RUTL
|
5
|
-
#
|
6
|
-
# I might need to consider renaming these.
|
7
|
-
# The *interface classes lie between Browser and the webdriver-level classes.
|
8
|
-
#
|
9
|
-
class BaseInterface
|
10
|
-
include Utilities
|
11
|
-
|
12
|
-
# RUTL::Driver
|
13
|
-
attr_accessor :driver
|
14
|
-
|
15
|
-
# RUTL::Camera
|
16
|
-
attr_accessor :camera
|
17
|
-
|
18
|
-
# Array of all RUTL::Page classes
|
19
|
-
attr_accessor :pages
|
20
|
-
|
21
|
-
def initialize
|
22
|
-
raise 'Child interface class must set @driver.' if @driver.nil?
|
23
|
-
# base_name avoids collisions when unning the same tests with
|
24
|
-
# different browsers.
|
25
|
-
name = self.class.to_s.sub('RUTL::Interface', '')
|
26
|
-
@camera = Camera.new(@driver, base_name: name)
|
27
|
-
end
|
28
|
-
|
29
|
-
# Attempts to navigate to the page.
|
30
|
-
# Takes screenshot if successful.
|
31
|
-
def goto(page)
|
32
|
-
raise 'expect Page class' unless page?(page)
|
33
|
-
find_page(page).go_to_here
|
34
|
-
@camera.screenshot
|
35
|
-
end
|
36
|
-
|
37
|
-
# Should define in children; raises here.
|
38
|
-
# Should return the current page class.
|
39
|
-
def current_page
|
40
|
-
raise 'define in child classes'
|
41
|
-
end
|
42
|
-
|
43
|
-
def method_missing(method, *args, &block)
|
44
|
-
if args.empty?
|
45
|
-
current_page.send(method)
|
46
|
-
else
|
47
|
-
current_page.send(method, *args, &block)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
# TODO: Is this needed? I not only find the page but also make sure the
|
52
|
-
# urls match. Even though that's what finding pages means?
|
53
|
-
def find_state(target_states)
|
54
|
-
target_states.each do |state|
|
55
|
-
next unless state.url == current_page.url
|
56
|
-
page = find_page(state)
|
57
|
-
return page if page.loaded?
|
58
|
-
end
|
59
|
-
false
|
60
|
-
end
|
61
|
-
|
62
|
-
# Attempts to find page by class or url.
|
63
|
-
def find_page(page)
|
64
|
-
@pages.each do |p|
|
65
|
-
return p if page?(page) && p.class == page
|
66
|
-
return p if String == page.class && page == p.url
|
67
|
-
end
|
68
|
-
raise "Page \"#{page}\" not found in pages #{@pages}"
|
69
|
-
end
|
70
|
-
|
71
|
-
# Calls the polling utility mathod await() with a lambda trying to
|
72
|
-
# find the next state, probably a Page class.
|
73
|
-
def wait_for_transition(target_states)
|
74
|
-
#
|
75
|
-
# TODO: Should also see if there are other things to wait for.
|
76
|
-
# I don't think this is doing page load time.
|
77
|
-
#
|
78
|
-
await -> { find_state target_states }
|
79
|
-
end
|
80
|
-
|
81
|
-
def respond_to_missing?(*args)
|
82
|
-
# This can't be right. Figure it out later.
|
83
|
-
current_page.respond_to?(*args)
|
84
|
-
end
|
85
|
-
|
86
|
-
def quit
|
87
|
-
@driver.quit
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
require 'selenium-webdriver'
|
2
|
-
require 'rutl/interface/base_interface'
|
3
|
-
|
4
|
-
module RUTL
|
5
|
-
#
|
6
|
-
# Small interface for Chrome browser.
|
7
|
-
#
|
8
|
-
class ChromeInterface < BaseInterface
|
9
|
-
# rubocop:disable Metrics/MethodLength
|
10
|
-
def initialize
|
11
|
-
@logged_in = true
|
12
|
-
options = Selenium::WebDriver::Chrome::Options.new
|
13
|
-
options.add_argument('--ignore-certificate-errors')
|
14
|
-
options.add_argument('--disable-popup-blocking')
|
15
|
-
options.add_argument('--disable-translate')
|
16
|
-
# Run headless on TravisCI
|
17
|
-
if ENV['TRAVIS'] == 'true'
|
18
|
-
options.add_argument('--disable-gpu')
|
19
|
-
options.add_argument('--headless ')
|
20
|
-
options.add_argument('--no-sandbox')
|
21
|
-
end
|
22
|
-
@driver = Selenium::WebDriver.for :chrome, options: options
|
23
|
-
super
|
24
|
-
end
|
25
|
-
# rubocop:enable Metrics/MethodLength
|
26
|
-
|
27
|
-
def current_page
|
28
|
-
url = @driver.current_url
|
29
|
-
page = find_page(url)
|
30
|
-
raise "PAGE NOT FOUND: #{url}, PAGES: #{@pages}" unless page
|
31
|
-
page
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'selenium-webdriver'
|
2
|
-
require 'rutl/interface/base_interface'
|
3
|
-
|
4
|
-
module RUTL
|
5
|
-
#
|
6
|
-
# Small interface for Chrome browser.
|
7
|
-
#
|
8
|
-
class FirefoxInterface < BaseInterface
|
9
|
-
def initialize
|
10
|
-
@logged_in = true
|
11
|
-
options = Selenium::WebDriver::Firefox::Options.new
|
12
|
-
options.add_argument('--ignore-certificate-errors')
|
13
|
-
options.add_argument('--disable-popup-blocking')
|
14
|
-
options.add_argument('--disable-translate')
|
15
|
-
options.add_argument('--headless') if ENV['TRAVIS'] == 'true'
|
16
|
-
@driver = Selenium::WebDriver.for :firefox, options: options
|
17
|
-
super
|
18
|
-
end
|
19
|
-
|
20
|
-
def current_page
|
21
|
-
url = @driver.current_url
|
22
|
-
page = find_page(url)
|
23
|
-
raise "PAGE NOT FOUND: #{url}, PAGES: #{@pages}" unless page
|
24
|
-
page
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
require 'rutl/interface/base_interface'
|
2
|
-
|
3
|
-
module RUTL
|
4
|
-
#
|
5
|
-
# Interface-level code for fake browser.
|
6
|
-
#
|
7
|
-
class NullInterface < BaseInterface
|
8
|
-
def initialize
|
9
|
-
context = RUTL::Element::ElementContext.new(destinations: nil,
|
10
|
-
interface: self,
|
11
|
-
selectors: [])
|
12
|
-
@driver = NullDriver.new(context)
|
13
|
-
super
|
14
|
-
end
|
15
|
-
|
16
|
-
# The null driver needs to talk to the null interface.
|
17
|
-
# Other driver/interface relations are not like this.
|
18
|
-
attr_writer :current_page
|
19
|
-
|
20
|
-
def current_page
|
21
|
-
# Default to @pages.first if not set?
|
22
|
-
# A browser can always check its current URL but the null driver can't.
|
23
|
-
@current_page ||= @pages.first
|
24
|
-
end
|
25
|
-
|
26
|
-
def wait_for_transition(destinations)
|
27
|
-
# TODO: Setting @current page didn't do it beacause that set
|
28
|
-
# context.interface.current_page and we wanted this in the browser.
|
29
|
-
@current_page = destinations.first.new(self)
|
30
|
-
$browser.current_page = @current_page
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|