webdriver 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/Gemfile.lock +1 -1
- data/e2e/all.rb +1 -0
- data/e2e/element.rb +9 -0
- data/examples/args.rb +1 -2
- data/examples/text_and_html.rb +12 -0
- data/lib/webdriver.rb +1 -0
- data/lib/webdriver/element.rb +52 -0
- data/lib/webdriver/session.rb +16 -0
- data/lib/webdriver/version.rb +1 -1
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c3f6a656b20690e475178f82ce162fdf50d3832d6b61c7c96010baf4a89eb920
|
4
|
+
data.tar.gz: d415081d653084bc5a2e6a1c3da9123dfc7eb4d078bc16aff8c504cd633fa4ed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 151900f17d60f7a545455bdcfb757425a2eaee7f0eb96edd6b620334101123494c4f3d8eed7cc9439322073f8b20fe8f8653040c1010546050198af4eb38abc8
|
7
|
+
data.tar.gz: 9587106a957c5039aaed13cbeaa7c21a8e75558aa4fb997302a91d686b4e5703d480a7d3bb23d07232187b6152380b646a39f7f60b83b1b2723954090c4477d6
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.6.
|
1
|
+
2.6.5
|
data/Gemfile.lock
CHANGED
data/e2e/all.rb
CHANGED
data/e2e/element.rb
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
session = $client.session!
|
2
|
+
|
3
|
+
e = session.element "css selector", "html"
|
4
|
+
raise "text" unless e.text == ""
|
5
|
+
raise "property" unless e.property("innerHTML") == "<head></head><body></body>"
|
6
|
+
raise "attribute" unless e.attribute("innerHTML") == "<head></head><body></body>"
|
7
|
+
raise "tag" unless e.tag == "html"
|
8
|
+
|
9
|
+
raise "child" unless e.element("css selector", "body").tag == "body"
|
data/examples/args.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
require_relative "../lib/webdriver"
|
2
|
-
|
2
|
+
|
3
3
|
capabilities = {
|
4
4
|
chromeOptions: {
|
5
5
|
args: [
|
@@ -13,5 +13,4 @@ wd = Webdriver::Client.new "http://localhost:9515/wd/hub", capabilities
|
|
13
13
|
s = wd.session!
|
14
14
|
w = s.windows.first
|
15
15
|
|
16
|
-
binding.pry
|
17
16
|
s.delete!
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require_relative "../lib/webdriver"
|
2
|
+
|
3
|
+
s = (Webdriver::Client.new "http://localhost:9515/").session!
|
4
|
+
|
5
|
+
s.url! "https://example.com"
|
6
|
+
html_el = s.element "css selector", "html"
|
7
|
+
|
8
|
+
puts html_el.text
|
9
|
+
puts "-- 8< -----------------------"
|
10
|
+
puts html_el.property "innerHTML"
|
11
|
+
|
12
|
+
s.delete!
|
data/lib/webdriver.rb
CHANGED
@@ -0,0 +1,52 @@
|
|
1
|
+
module Webdriver
|
2
|
+
class Element
|
3
|
+
attr_reader :id
|
4
|
+
|
5
|
+
def initialize(id, connection)
|
6
|
+
@id = id
|
7
|
+
|
8
|
+
@session_connection = connection
|
9
|
+
@connection = Webdriver::PrefixConnection.new "element/#{@id}", connection
|
10
|
+
end
|
11
|
+
|
12
|
+
def text
|
13
|
+
@connection.get "text"
|
14
|
+
end
|
15
|
+
|
16
|
+
def rect
|
17
|
+
@connection.get "rect"
|
18
|
+
end
|
19
|
+
|
20
|
+
def tag
|
21
|
+
@connection.get "name"
|
22
|
+
end
|
23
|
+
|
24
|
+
def property name
|
25
|
+
@connection.get File.join("property", name)
|
26
|
+
end
|
27
|
+
|
28
|
+
def attribute name
|
29
|
+
@connection.get File.join("attribute", name)
|
30
|
+
end
|
31
|
+
|
32
|
+
def click!
|
33
|
+
@connection.post "click"
|
34
|
+
end
|
35
|
+
|
36
|
+
def element(using, value)
|
37
|
+
el = @connection.post "element", {}, {
|
38
|
+
using: using,
|
39
|
+
value: value
|
40
|
+
}
|
41
|
+
Webdriver::Element.new el["ELEMENT"], @session_connection
|
42
|
+
end
|
43
|
+
|
44
|
+
def elements(using, value)
|
45
|
+
resp = @connection.post "elements", {}, {
|
46
|
+
using: using,
|
47
|
+
value: value
|
48
|
+
}
|
49
|
+
resp.map { |el| Webdriver::Element.new el["ELEMENT"], @session_connection }
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
data/lib/webdriver/session.rb
CHANGED
@@ -52,5 +52,21 @@ module Webdriver
|
|
52
52
|
def screenshot
|
53
53
|
@connection.get "screenshot"
|
54
54
|
end
|
55
|
+
|
56
|
+
def element(using, value)
|
57
|
+
el = @connection.post "element", {}, {
|
58
|
+
using: using,
|
59
|
+
value: value
|
60
|
+
}
|
61
|
+
Webdriver::Element.new el["ELEMENT"], @connection
|
62
|
+
end
|
63
|
+
|
64
|
+
def elements(using, value)
|
65
|
+
resp = @connection.post "elements", {}, {
|
66
|
+
using: using,
|
67
|
+
value: value
|
68
|
+
}
|
69
|
+
resp.map { |el| Webdriver::Element.new el["ELEMENT"], @connection }
|
70
|
+
end
|
55
71
|
end
|
56
72
|
end
|
data/lib/webdriver/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webdriver
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matti Paksula
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-09
|
11
|
+
date: 2019-12-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -143,15 +143,18 @@ files:
|
|
143
143
|
- bin/console
|
144
144
|
- bin/setup
|
145
145
|
- e2e/all.rb
|
146
|
+
- e2e/element.rb
|
146
147
|
- e2e/session.rb
|
147
148
|
- e2e/sessions.rb
|
148
149
|
- e2e/status.rb
|
149
150
|
- e2e/window.rb
|
150
151
|
- e2e/windows.rb
|
151
152
|
- examples/args.rb
|
153
|
+
- examples/text_and_html.rb
|
152
154
|
- lib/webdriver.rb
|
153
155
|
- lib/webdriver/client.rb
|
154
156
|
- lib/webdriver/connection.rb
|
157
|
+
- lib/webdriver/element.rb
|
155
158
|
- lib/webdriver/prefix_connection.rb
|
156
159
|
- lib/webdriver/session.rb
|
157
160
|
- lib/webdriver/version.rb
|
@@ -176,7 +179,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
176
179
|
- !ruby/object:Gem::Version
|
177
180
|
version: '0'
|
178
181
|
requirements: []
|
179
|
-
rubygems_version: 3.0.
|
182
|
+
rubygems_version: 3.0.6
|
180
183
|
signing_key:
|
181
184
|
specification_version: 4
|
182
185
|
summary: webdriver
|