webaccount 0.2.4 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/Thoran/Array/AllButFirst/all_but_first.rb +28 -0
- data/lib/Thoran/Array/FirstX/firstX.rb +21 -0
- data/lib/Thoran/Selenium/WebDriver/Driver/Attempt/attempt.rb +3 -3
- data/lib/Thoran/Selenium/WebDriver/Setup/setup.rb +6 -8
- data/lib/Thoran/String/ToConst/to_const.rb +47 -0
- data/lib/WebAccount/VERSION.rb +1 -1
- data/lib/WebAccount.rb +48 -11
- metadata +13 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5f2306cf382f2ebbba8b93e9746e12c92d298ead4ba4f154fc71c223d844e2e0
|
4
|
+
data.tar.gz: c1b04987b7f1812c549fd8f0203457e515aab18e716f2885c29494c07688baf8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2f488ddda68db8c4807e5ad7ada9c8f85f48219a97e24be6f1ea6d1033395993a9bf6a74de615b539bdab6c749e7a11c3c4a1d04256dd94cfba743a2aadb0f8d
|
7
|
+
data.tar.gz: 86b9e301db625c6e236da7290d916a1fa629d3cdabf74cc4cb8f61f0b25d837a8b6bd5e5cec6b357b5f3baea0ff6d4d71739ddc7ac463089ee1a4a06df5e73bc
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# Thoran/Array/AllButFirst/all_but_first.rb
|
2
|
+
# Thoran::Array::AllButFirst#all_but_first
|
3
|
+
|
4
|
+
# 20141223
|
5
|
+
# 0.1.0
|
6
|
+
|
7
|
+
# Description: This returns a copy of the receiving array with the first element removed.
|
8
|
+
|
9
|
+
# Changes:
|
10
|
+
# 1. + Thoran namespace.
|
11
|
+
|
12
|
+
require 'Thoran/Array/FirstX/firstX'
|
13
|
+
|
14
|
+
module Thoran
|
15
|
+
module Array
|
16
|
+
module AllButFirst
|
17
|
+
|
18
|
+
def all_but_first
|
19
|
+
d = self.dup
|
20
|
+
d.first!
|
21
|
+
d
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
Array.send(:include, Thoran::Array::AllButFirst)
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# Thoran/Array/FirstX/firstX.rb
|
2
|
+
# Thoran::Array::FirstX#first!
|
3
|
+
|
4
|
+
# 20141223
|
5
|
+
# 0.1.0
|
6
|
+
|
7
|
+
# Description: Sometimes it makes more sense to treat arrays this way.
|
8
|
+
|
9
|
+
module Thoran
|
10
|
+
module Array
|
11
|
+
module FirstX
|
12
|
+
|
13
|
+
def first!
|
14
|
+
shift
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
Array.send(:include, Thoran::Array::FirstX)
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# Thoran/Selenium/WebDriver/Attempt/attempt.rb
|
2
2
|
# Thoran::Selenium::WebDriver::Attempt.attempt
|
3
3
|
|
4
|
-
#
|
5
|
-
# 0.0.
|
4
|
+
# 20200419
|
5
|
+
# 0.0.1
|
6
6
|
|
7
7
|
# Examples:
|
8
8
|
# 1. driver.attempt do |driver|
|
@@ -27,7 +27,7 @@ module Thoran
|
|
27
27
|
begin
|
28
28
|
yield
|
29
29
|
break
|
30
|
-
rescue Timeout::Error, Selenium::WebDriver::Error::UnknownError, Selenium::WebDriver::Error::NoSuchElementError => e
|
30
|
+
rescue Timeout::Error, ::Selenium::WebDriver::Error::UnknownError, ::Selenium::WebDriver::Error::NoSuchElementError => e
|
31
31
|
attempts += 1
|
32
32
|
if attempts >= max_attempts
|
33
33
|
@driver.quit
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# Thoran/Selenium/WebDriver/Setup/setup.rb
|
2
2
|
# Thoran::Selenium::WebDriver.setup
|
3
3
|
|
4
|
-
#
|
5
|
-
# 0.0.
|
4
|
+
# 20200419
|
5
|
+
# 0.0.1
|
6
6
|
|
7
7
|
# Usage:
|
8
8
|
# 1. Binary is in the path:
|
@@ -24,16 +24,14 @@ module Thoran
|
|
24
24
|
module WebDriver
|
25
25
|
module Setup
|
26
26
|
|
27
|
-
module_function
|
28
|
-
|
29
27
|
def setup(path_or_browser)
|
30
28
|
if File.exist?(File.expand_path(path_or_browser.to_s))
|
31
29
|
path = path_or_browser
|
32
|
-
|
33
|
-
Selenium::WebDriver.for(selenium_browser(path))
|
30
|
+
at(path)
|
31
|
+
::Selenium::WebDriver.for(selenium_browser(path))
|
34
32
|
else
|
35
33
|
browser = path_or_browser.to_sym.downcase
|
36
|
-
Selenium::WebDriver.for(browser)
|
34
|
+
::Selenium::WebDriver.for(browser)
|
37
35
|
end
|
38
36
|
end
|
39
37
|
|
@@ -63,6 +61,6 @@ end
|
|
63
61
|
|
64
62
|
module Selenium
|
65
63
|
module WebDriver
|
66
|
-
|
64
|
+
extend Thoran::Selenium::WebDriver::Setup
|
67
65
|
end
|
68
66
|
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# Thoran/String/ToConst/to_const.rb
|
2
|
+
# Thoran::String::ToConst#to_const
|
3
|
+
|
4
|
+
# 20141223
|
5
|
+
# 0.2.0
|
6
|
+
|
7
|
+
# Description: This takes a string and returns a constant, with unlimited namespacing.
|
8
|
+
|
9
|
+
# History: Derived from Object#to_const 0.3.0, and superceding Object#to_const.
|
10
|
+
|
11
|
+
# Changes:
|
12
|
+
# 1. + Thoran namespace.
|
13
|
+
|
14
|
+
# Todo:
|
15
|
+
# 1. This only works for two levels of constants. Three and you're stuffed. So, this needs to be recursive...
|
16
|
+
# Done iteratively as of 0.1.0.
|
17
|
+
# 2. Make this work for symbols. However, this will only work if there's no namespacing. ie. :A is OK, but :A::B is not.
|
18
|
+
|
19
|
+
# Discussion:
|
20
|
+
# 1. Should this go separately into classes for which ::const_get will work and be removed from Object? Done as of 0.1.0.
|
21
|
+
|
22
|
+
require 'Thoran/Array/AllButFirst/all_but_first'
|
23
|
+
|
24
|
+
module Thoran
|
25
|
+
module String
|
26
|
+
module ToConst
|
27
|
+
|
28
|
+
def to_const
|
29
|
+
if self =~ /::/
|
30
|
+
constants = self.split('::')
|
31
|
+
constant = Object.const_get(constants.first)
|
32
|
+
constants = constants.all_but_first
|
33
|
+
until constants.empty? do
|
34
|
+
constant = constant.const_get(constants.shift)
|
35
|
+
end
|
36
|
+
else
|
37
|
+
constant = Object.const_get(self)
|
38
|
+
end
|
39
|
+
constant
|
40
|
+
end
|
41
|
+
alias_method :to_constant, :to_const
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
String.send(:include, Thoran::String::ToConst)
|
data/lib/WebAccount/VERSION.rb
CHANGED
data/lib/WebAccount.rb
CHANGED
@@ -13,16 +13,16 @@ class WebAccount
|
|
13
13
|
def initialize(
|
14
14
|
username: nil, password: nil,
|
15
15
|
login_page_url: nil,
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
login_page_username_field_selector: nil, login_page_password_field_selector: nil,
|
17
|
+
login_page_submit_button_selector: nil,
|
18
|
+
logout_button_selector: nil,
|
19
19
|
logged_out_xpath: nil
|
20
20
|
)
|
21
21
|
@username, @password = username, password
|
22
22
|
@login_page_url = login_page_url
|
23
|
-
@
|
24
|
-
@
|
25
|
-
@
|
23
|
+
@login_page_username_field_selector, @login_page_password_field_selector = login_page_username_field_selector, login_page_password_field_selector
|
24
|
+
@login_page_submit_button_selector = login_page_submit_button_selector
|
25
|
+
@logout_button_selector = logout_button_selector
|
26
26
|
@logged_out_xpath = logged_out_xpath
|
27
27
|
end
|
28
28
|
|
@@ -38,13 +38,13 @@ class WebAccount
|
|
38
38
|
login_page_submit_button.click
|
39
39
|
end
|
40
40
|
@logged_in = driver_wait.until do
|
41
|
-
driver.element_present?(
|
41
|
+
driver.element_present?(@logout_button_selector.keys.first, @logout_button_selector.values.first)
|
42
42
|
end
|
43
43
|
end
|
44
44
|
alias_method :logon, :login
|
45
45
|
|
46
46
|
def logout
|
47
|
-
|
47
|
+
logout_button.click
|
48
48
|
if logged_out?
|
49
49
|
@logged_in = false
|
50
50
|
end
|
@@ -98,8 +98,16 @@ class WebAccount
|
|
98
98
|
username_field.send_keys(username)
|
99
99
|
end
|
100
100
|
|
101
|
+
def default_username_field
|
102
|
+
{name: "username"}
|
103
|
+
end
|
104
|
+
|
101
105
|
def username_field
|
102
|
-
|
106
|
+
if @login_page_username_field_selector
|
107
|
+
driver.find_element(@login_page_username_field_selector.keys.first, @login_page_username_field_selector.values.first)
|
108
|
+
else
|
109
|
+
driver.find_element(default_username_field.keys.first, default_username_field.values.first)
|
110
|
+
end
|
103
111
|
end
|
104
112
|
|
105
113
|
def enter_password(password = nil)
|
@@ -107,12 +115,41 @@ class WebAccount
|
|
107
115
|
password_field.send_keys(password)
|
108
116
|
end
|
109
117
|
|
118
|
+
def default_password_field
|
119
|
+
{name: "password"}
|
120
|
+
end
|
121
|
+
|
110
122
|
def password_field
|
111
|
-
|
123
|
+
if @login_page_password_field_selector
|
124
|
+
driver.find_element(@login_page_password_field_selector.keys.first, @login_page_password_field_selector.values.first)
|
125
|
+
else
|
126
|
+
driver.find_element(default_password_field.keys.first, default_password_field.values.first)
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
def default_login_page_submit_button_selector
|
131
|
+
{xpath: '//input[@type="submit" and @value="Login"]'}
|
112
132
|
end
|
113
133
|
|
114
134
|
def login_page_submit_button
|
115
|
-
|
135
|
+
if @login_page_submit_button_selector
|
136
|
+
driver.find_element(@login_page_submit_button_selector.keys.first, @login_page_submit_button_selector.values.first)
|
137
|
+
else
|
138
|
+
driver.find_element(default_login_page_submit_button_selector.keys.first, default_login_page_submit_button_selector.values.first)
|
139
|
+
end
|
116
140
|
end
|
117
141
|
|
142
|
+
# logging out
|
143
|
+
|
144
|
+
def default_logout_button_selector
|
145
|
+
{xpath: '//input[@type="submit" and @value="Logout"]'}
|
146
|
+
end
|
147
|
+
|
148
|
+
def logout_button
|
149
|
+
if @logout_page_submit_button_selector
|
150
|
+
driver.find_element(@logout_button_selector.keys.first, @logout_button_selector.values.first)
|
151
|
+
else
|
152
|
+
driver.find_element(default_logout_button_selector.keys.first, default_logout_button_selector.values.first)
|
153
|
+
end
|
154
|
+
end
|
118
155
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webaccount
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- thoran
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-04-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: selenium-webdriver
|
@@ -24,19 +24,22 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
-
description: Easily log into web accounts
|
28
|
-
the URL of the login page, and a few page ids to a
|
27
|
+
description: Easily log into web accounts by supplying just a username and password,
|
28
|
+
the URL of the login page, and a few page ids to a sub-class of WebAccount.
|
29
29
|
email: code@thoran.com
|
30
30
|
executables: []
|
31
31
|
extensions: []
|
32
32
|
extra_rdoc_files: []
|
33
33
|
files:
|
34
|
+
- lib/Thoran/Array/AllButFirst/all_but_first.rb
|
35
|
+
- lib/Thoran/Array/FirstX/firstX.rb
|
34
36
|
- lib/Thoran/Selenium.rb
|
35
37
|
- lib/Thoran/Selenium/WebDriver/Driver/Attempt/attempt.rb
|
36
38
|
- lib/Thoran/Selenium/WebDriver/Remote/W3C/Bridge/ConvertLocators/convert_locators.rb
|
37
39
|
- lib/Thoran/Selenium/WebDriver/SearchContext/ElementPresentQ/element_presentQ.rb
|
38
40
|
- lib/Thoran/Selenium/WebDriver/SearchContext/ElementsPresentQ/elements_presentQ.rb
|
39
41
|
- lib/Thoran/Selenium/WebDriver/Setup/setup.rb
|
42
|
+
- lib/Thoran/String/ToConst/to_const.rb
|
40
43
|
- lib/WebAccount.rb
|
41
44
|
- lib/WebAccount/VERSION.rb
|
42
45
|
- lib/web_account.rb
|
@@ -44,7 +47,7 @@ homepage: http://github.com/thoran/WebAccount
|
|
44
47
|
licenses:
|
45
48
|
- Ruby
|
46
49
|
metadata: {}
|
47
|
-
post_install_message:
|
50
|
+
post_install_message:
|
48
51
|
rdoc_options: []
|
49
52
|
require_paths:
|
50
53
|
- lib
|
@@ -59,9 +62,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
59
62
|
- !ruby/object:Gem::Version
|
60
63
|
version: '0'
|
61
64
|
requirements: []
|
62
|
-
rubygems_version: 3.
|
63
|
-
signing_key:
|
65
|
+
rubygems_version: 3.5.6
|
66
|
+
signing_key:
|
64
67
|
specification_version: 4
|
65
|
-
summary:
|
66
|
-
|
68
|
+
summary: An abstract super-class for navigating a web-based user account via Selenium
|
69
|
+
WebDriver.
|
67
70
|
test_files: []
|