playwright-ruby-client 0.5.10 → 0.6.0

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.
@@ -64,6 +64,24 @@ module Playwright
64
64
  # with sync_playwright() as playwright:
65
65
  # run(playwright)
66
66
  # ```
67
+ #
68
+ # ```csharp
69
+ # using Microsoft.Playwright;
70
+ # using System.Threading.Tasks;
71
+ #
72
+ # class PlaywrightExample
73
+ # {
74
+ # public static async Task Main()
75
+ # {
76
+ # using var playwright = await Playwright.CreateAsync();
77
+ # await using var browser = await playwright.Chromium.LaunchAsync();
78
+ # var page = await browser.NewPageAsync();
79
+ #
80
+ # await page.GotoAsync("https://www.microsoft.com");
81
+ # // other actions...
82
+ # }
83
+ # }
84
+ # ```
67
85
  class Playwright < PlaywrightApi
68
86
 
69
87
  # This object can be used to launch or connect to Chromium, returning instances of `Browser`.
@@ -167,13 +185,13 @@ module Playwright
167
185
  end
168
186
 
169
187
  # @nodoc
170
- def electron
171
- wrap_impl(@impl.electron)
188
+ def android
189
+ wrap_impl(@impl.android)
172
190
  end
173
191
 
174
192
  # @nodoc
175
- def android
176
- wrap_impl(@impl.android)
193
+ def electron
194
+ wrap_impl(@impl.electron)
177
195
  end
178
196
 
179
197
  # -- inherited from EventEmitter --
@@ -34,6 +34,13 @@ module Playwright
34
34
  # ```py
35
35
  # page.on("requestfailed", lambda request: print(request.url + " " + request.failure))
36
36
  # ```
37
+ #
38
+ # ```csharp
39
+ # page.RequestFailed += (_, request) =>
40
+ # {
41
+ # Console.WriteLine(request.Failure);
42
+ # };
43
+ # ```
37
44
  def failure
38
45
  wrap_impl(@impl.failure)
39
46
  end
@@ -105,6 +112,11 @@ module Playwright
105
112
  # print(response.request.redirected_from.url) # "http://example.com"
106
113
  # ```
107
114
  #
115
+ # ```csharp
116
+ # var response = await page.GotoAsync("http://www.microsoft.com");
117
+ # Console.WriteLine(response.Request.RedirectedFrom?.Url); // http://www.microsoft.com
118
+ # ```
119
+ #
108
120
  # If the website `https://google.com` has no redirects:
109
121
  #
110
122
  #
@@ -127,6 +139,11 @@ module Playwright
127
139
  # response = page.goto("https://google.com")
128
140
  # print(response.request.redirected_from) # None
129
141
  # ```
142
+ #
143
+ # ```csharp
144
+ # var response = await page.GotoAsync("https://www.google.com");
145
+ # Console.WriteLine(response.Request.RedirectedFrom?.Url); // null
146
+ # ```
130
147
  def redirected_from
131
148
  wrap_impl(@impl.redirected_from)
132
149
  end
@@ -147,6 +164,10 @@ module Playwright
147
164
  # ```py
148
165
  # assert request.redirected_from.redirected_to == request
149
166
  # ```
167
+ #
168
+ # ```csharp
169
+ # Console.WriteLine(request.RedirectedFrom?.RedirectedTo == request); // True
170
+ # ```
150
171
  def redirected_to
151
172
  wrap_impl(@impl.redirected_to)
152
173
  end
@@ -197,6 +218,13 @@ module Playwright
197
218
  # request = request_info.value
198
219
  # print(request.timing)
199
220
  # ```
221
+ #
222
+ # ```csharp
223
+ # var waitForEventTask = page.WaitForEventAsync(PageEvent.RequestFinished);
224
+ # await page.GotoAsync("https://www.microsoft.com");
225
+ # var request = await waitForEventTask;
226
+ # Console.WriteLine(request.Timing.ResponseEnd);
227
+ # ```
200
228
  def timing
201
229
  wrap_impl(@impl.timing)
202
230
  end
@@ -41,7 +41,7 @@ module Playwright
41
41
  # "foo": "bar" # set "foo" header
42
42
  # "origin": None # remove "origin" header
43
43
  # }
44
- # await route.continue(headers=headers)
44
+ # await route.continue_(headers=headers)
45
45
  # }
46
46
  # await page.route("**/*", handle)
47
47
  # ```
@@ -54,10 +54,19 @@ module Playwright
54
54
  # "foo": "bar" # set "foo" header
55
55
  # "origin": None # remove "origin" header
56
56
  # }
57
- # route.continue(headers=headers)
57
+ # route.continue_(headers=headers)
58
58
  # }
59
59
  # page.route("**/*", handle)
60
60
  # ```
61
+ #
62
+ # ```csharp
63
+ # await page.RouteAsync("**/*", route =>
64
+ # {
65
+ # var headers = new Dictionary<string, string>(route.Request.Headers) { { "foo", "bar" } };
66
+ # headers.Remove("origin");
67
+ # route.ContinueAsync(headers);
68
+ # });
69
+ # ```
61
70
  def continue(headers: nil, method: nil, postData: nil, url: nil)
62
71
  wrap_impl(@impl.continue(headers: unwrap_impl(headers), method: unwrap_impl(method), postData: unwrap_impl(postData), url: unwrap_impl(url)))
63
72
  end
@@ -100,6 +109,13 @@ module Playwright
100
109
  # body="not found!"))
101
110
  # ```
102
111
  #
112
+ # ```csharp
113
+ # await page.RouteAsync("**/*", route => route.FulfillAsync(
114
+ # status: 404,
115
+ # contentType: "text/plain",
116
+ # body: "Not Found!"));
117
+ # ```
118
+ #
103
119
  # An example of serving static file:
104
120
  #
105
121
  #
@@ -119,6 +135,10 @@ module Playwright
119
135
  # ```python sync
120
136
  # page.route("**/xhr_endpoint", lambda route: route.fulfill(path="mock_data.json"))
121
137
  # ```
138
+ #
139
+ # ```csharp
140
+ # await page.RouteAsync("**/xhr_endpoint", route => route.FulfillAsync(path: "mock_data.json"));
141
+ # ```
122
142
  def fulfill(
123
143
  body: nil,
124
144
  contentType: nil,
@@ -74,6 +74,31 @@ module Playwright
74
74
  # ```python sync
75
75
  # # FIXME: add snippet
76
76
  # ```
77
+ #
78
+ # ```csharp
79
+ # using var playwright = await Playwright.CreateAsync();
80
+ # // Script that evaluates to a selector engine instance.
81
+ # await playwright.Selectors.RegisterAsync("tag", @"{
82
+ # // Returns the first element matching given selector in the root's subtree.
83
+ # query(root, selector) {
84
+ # return root.querySelector(selector);
85
+ # },
86
+ # // Returns all elements matching given selector in the root's subtree.
87
+ # queryAll(root, selector) {
88
+ # return Array.from(root.querySelectorAll(selector));
89
+ # }
90
+ # }");
91
+ #
92
+ # await using var browser = await playwright.Chromium.LaunchAsync();
93
+ # var page = await browser.NewPageAsync();
94
+ # await page.SetContentAsync("<div><button>Click me</button></div>");
95
+ # // Use the selector prefixed with its name.
96
+ # var button = await page.QuerySelectorAsync("tag=button");
97
+ # // Combine it with other selector engines.
98
+ # await page.ClickAsync("tag=div >> text=\"Click me\"");
99
+ # // Can use it in any methods supporting selectors.
100
+ # int buttonCount = await page.EvalOnSelectorAllAsync<int>("tag=button", "buttons => buttons.length");
101
+ # ```
77
102
  def register(name, contentScript: nil, path: nil, script: nil)
78
103
  wrap_impl(@impl.register(unwrap_impl(name), contentScript: unwrap_impl(contentScript), path: unwrap_impl(path), script: unwrap_impl(script)))
79
104
  end
@@ -0,0 +1,99 @@
1
+ module Playwright
2
+ # API for collecting and saving Playwright traces. Playwright traces can be opened using the Playwright CLI after
3
+ # Playwright script runs.
4
+ #
5
+ # Start with specifying the folder traces will be stored in:
6
+ #
7
+ #
8
+ # ```js
9
+ # const browser = await chromium.launch({ traceDir: 'traces' });
10
+ # const context = await browser.newContext();
11
+ # await context.tracing.start({ name: 'trace', screenshots: true, snapshots: true });
12
+ # const page = await context.newPage();
13
+ # await page.goto('https://playwright.dev');
14
+ # await context.tracing.stop();
15
+ # await context.tracing.export('trace.zip');
16
+ # ```
17
+ #
18
+ # ```java
19
+ # Browser browser = chromium.launch(new BrowserType.LaunchOptions().setTraceDir("trace"));
20
+ # BrowserContext context = browser.newContext();
21
+ # context.tracing.start(page, new Tracing.StartOptions()
22
+ # .setName("trace")
23
+ # .setScreenshots(true)
24
+ # .setSnapshots(true);
25
+ # Page page = context.newPage();
26
+ # page.goto("https://playwright.dev");
27
+ # context.tracing.stop();
28
+ # context.tracing.export(Paths.get("trace.zip")))
29
+ # ```
30
+ #
31
+ # ```python async
32
+ # browser = await chromium.launch(traceDir='traces')
33
+ # context = await browser.new_context()
34
+ # await context.tracing.start(name="trace", screenshots=True, snapshots=True)
35
+ # await page.goto("https://playwright.dev")
36
+ # await context.tracing.stop()
37
+ # await context.tracing.export("trace.zip")
38
+ # ```
39
+ #
40
+ # ```python sync
41
+ # browser = chromium.launch(traceDir='traces')
42
+ # context = browser.new_context()
43
+ # context.tracing.start(name="trace", screenshots=True, snapshots=True)
44
+ # page.goto("https://playwright.dev")
45
+ # context.tracing.stop()
46
+ # context.tracing.export("trace.zip")
47
+ # ```
48
+ class Tracing < PlaywrightApi
49
+
50
+ # Export trace into the file with the given name. Should be called after the tracing has stopped.
51
+ def export(path)
52
+ wrap_impl(@impl.export(unwrap_impl(path)))
53
+ end
54
+
55
+ # Start tracing.
56
+ #
57
+ #
58
+ # ```js
59
+ # await context.tracing.start({ name: 'trace', screenshots: true, snapshots: true });
60
+ # const page = await context.newPage();
61
+ # await page.goto('https://playwright.dev');
62
+ # await context.tracing.stop();
63
+ # await context.tracing.export('trace.zip');
64
+ # ```
65
+ #
66
+ # ```java
67
+ # context.tracing.start(page, new Tracing.StartOptions()
68
+ # .setName("trace")
69
+ # .setScreenshots(true)
70
+ # .setSnapshots(true);
71
+ # Page page = context.newPage();
72
+ # page.goto('https://playwright.dev');
73
+ # context.tracing.stop();
74
+ # context.tracing.export(Paths.get("trace.zip")))
75
+ # ```
76
+ #
77
+ # ```python async
78
+ # await context.tracing.start(name="trace", screenshots=True, snapshots=True)
79
+ # await page.goto("https://playwright.dev")
80
+ # await context.tracing.stop()
81
+ # await context.tracing.export("trace.zip")
82
+ # ```
83
+ #
84
+ # ```python sync
85
+ # context.tracing.start(name="trace", screenshots=True, snapshots=True)
86
+ # page.goto("https://playwright.dev")
87
+ # context.tracing.stop()
88
+ # context.tracing.export("trace.zip")
89
+ # ```
90
+ def start(name: nil, screenshots: nil, snapshots: nil)
91
+ wrap_impl(@impl.start(name: unwrap_impl(name), screenshots: unwrap_impl(screenshots), snapshots: unwrap_impl(snapshots)))
92
+ end
93
+
94
+ # Stop tracing.
95
+ def stop
96
+ wrap_impl(@impl.stop)
97
+ end
98
+ end
99
+ end
@@ -38,14 +38,14 @@ module Playwright
38
38
  # ```
39
39
  #
40
40
  # ```csharp
41
- # Page.Worker += (_, worker) =>
41
+ # page.Worker += (_, worker) =>
42
42
  # {
43
43
  # Console.WriteLine($"Worker created: {worker.Url}");
44
44
  # worker.Close += (_, _) => Console.WriteLine($"Worker closed {worker.Url}");
45
45
  # };
46
46
  #
47
47
  # Console.WriteLine("Current Workers:");
48
- # foreach(var pageWorker in Page.Workers)
48
+ # foreach(var pageWorker in page.Workers)
49
49
  # {
50
50
  # Console.WriteLine($"\tWorker: {pageWorker.Url}");
51
51
  # }
data/playwright.gemspec CHANGED
@@ -24,6 +24,7 @@ Gem::Specification.new do |spec|
24
24
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
25
25
  spec.require_paths = ['lib']
26
26
 
27
+ spec.required_ruby_version = '>= 2.4'
27
28
  spec.add_dependency 'concurrent-ruby', '>= 1.1.6'
28
29
  spec.add_dependency 'mime-types', '>= 3.0'
29
30
  spec.add_development_dependency 'bundler', '~> 2.2.3'
@@ -33,7 +34,6 @@ Gem::Specification.new do |spec|
33
34
  spec.add_development_dependency 'rake', '~> 13.0.3'
34
35
  spec.add_development_dependency 'rspec', '~> 3.10.0 '
35
36
  spec.add_development_dependency 'rspec_junit_formatter' # for CircleCI.
36
- spec.add_development_dependency 'rubocop', '~> 1.7.0'
37
37
  spec.add_development_dependency 'rubocop-rspec'
38
38
  spec.add_development_dependency 'sinatra'
39
39
  spec.add_development_dependency 'webrick'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: playwright-ruby-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.10
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - YusukeIwaki
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-05-17 00:00:00.000000000 Z
11
+ date: 2021-05-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -136,20 +136,6 @@ dependencies:
136
136
  - - ">="
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
- - !ruby/object:Gem::Dependency
140
- name: rubocop
141
- requirement: !ruby/object:Gem::Requirement
142
- requirements:
143
- - - "~>"
144
- - !ruby/object:Gem::Version
145
- version: 1.7.0
146
- type: :development
147
- prerelease: false
148
- version_requirements: !ruby/object:Gem::Requirement
149
- requirements:
150
- - - "~>"
151
- - !ruby/object:Gem::Version
152
- version: 1.7.0
153
139
  - !ruby/object:Gem::Dependency
154
140
  name: rubocop-rspec
155
141
  requirement: !ruby/object:Gem::Requirement
@@ -254,6 +240,7 @@ files:
254
240
  - lib/playwright/select_option_values.rb
255
241
  - lib/playwright/timeout_settings.rb
256
242
  - lib/playwright/touchscreen_impl.rb
243
+ - lib/playwright/tracing_impl.rb
257
244
  - lib/playwright/transport.rb
258
245
  - lib/playwright/url_matcher.rb
259
246
  - lib/playwright/utils.rb
@@ -285,6 +272,7 @@ files:
285
272
  - lib/playwright_api/route.rb
286
273
  - lib/playwright_api/selectors.rb
287
274
  - lib/playwright_api/touchscreen.rb
275
+ - lib/playwright_api/tracing.rb
288
276
  - lib/playwright_api/web_socket.rb
289
277
  - lib/playwright_api/worker.rb
290
278
  - playwright.gemspec
@@ -300,7 +288,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
300
288
  requirements:
301
289
  - - ">="
302
290
  - !ruby/object:Gem::Version
303
- version: '0'
291
+ version: '2.4'
304
292
  required_rubygems_version: !ruby/object:Gem::Requirement
305
293
  requirements:
306
294
  - - ">="
@@ -310,5 +298,5 @@ requirements: []
310
298
  rubygems_version: 3.2.15
311
299
  signing_key:
312
300
  specification_version: 4
313
- summary: The Ruby binding of playwright driver 1.11.0
301
+ summary: The Ruby binding of playwright driver 1.12.0
314
302
  test_files: []