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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 616f8d5d0956947bdd8d2b2b7cfe8850dd90d9e2ce80a7b4349b7bfa81519a47
4
- data.tar.gz: 4ebd8841d40a95b9d1ab31f6d1459e55d1914d7acf0c61b8e231547418ea3702
3
+ metadata.gz: c3f6a656b20690e475178f82ce162fdf50d3832d6b61c7c96010baf4a89eb920
4
+ data.tar.gz: d415081d653084bc5a2e6a1c3da9123dfc7eb4d078bc16aff8c504cd633fa4ed
5
5
  SHA512:
6
- metadata.gz: 9c0ae6b350ef5dded123079161e6d46b0ac361e02bdbd4fa84b06e2a27d49c2cd7d476e832f00448807242757f950b47a2fff6b25ad2c28b9b2d2cfcc2e476e5
7
- data.tar.gz: 6f165b9dc44e03067a76952d9651c0290ac795e4c4f82da81d9365037d315d96d96f9e4b2ffffb5a1725d6fdd4c5e3d8e4822c3d12d65d4b5862de7111c2606f
6
+ metadata.gz: 151900f17d60f7a545455bdcfb757425a2eaee7f0eb96edd6b620334101123494c4f3d8eed7cc9439322073f8b20fe8f8653040c1010546050198af4eb38abc8
7
+ data.tar.gz: 9587106a957c5039aaed13cbeaa7c21a8e75558aa4fb997302a91d686b4e5703d480a7d3bb23d07232187b6152380b646a39f7f60b83b1b2723954090c4477d6
@@ -1 +1 @@
1
- 2.6.3
1
+ 2.6.5
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- webdriver (0.4.0)
4
+ webdriver (0.5.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/e2e/all.rb CHANGED
@@ -7,4 +7,5 @@ require_relative "sessions"
7
7
  require_relative "session"
8
8
  require_relative "windows"
9
9
  require_relative "window"
10
+ require_relative "element"
10
11
  puts "OK"
@@ -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"
@@ -1,5 +1,5 @@
1
1
  require_relative "../lib/webdriver"
2
- require "pry"
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!
@@ -16,4 +16,5 @@ require_relative "webdriver/prefix_connection"
16
16
 
17
17
  require_relative "webdriver/window"
18
18
  require_relative "webdriver/session"
19
+ require_relative "webdriver/element"
19
20
  require_relative "webdriver/client"
@@ -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
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Webdriver
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.0"
3
3
  end
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.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-28 00:00:00.000000000 Z
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.4
182
+ rubygems_version: 3.0.6
180
183
  signing_key:
181
184
  specification_version: 4
182
185
  summary: webdriver