playwright-ruby-client 0.6.0 → 0.6.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (96) hide show
  1. checksums.yaml +4 -4
  2. data/documentation/README.md +33 -0
  3. data/documentation/babel.config.js +3 -0
  4. data/documentation/docs/api/accessibility.md +7 -0
  5. data/documentation/docs/api/browser.md +188 -0
  6. data/documentation/docs/api/browser_context.md +397 -0
  7. data/documentation/docs/api/browser_type.md +158 -0
  8. data/documentation/docs/api/cdp_session.md +7 -0
  9. data/documentation/docs/api/console_message.md +41 -0
  10. data/documentation/docs/api/dialog.md +71 -0
  11. data/documentation/docs/api/element_handle.md +618 -0
  12. data/documentation/docs/api/experimental/_category_.yml +3 -0
  13. data/documentation/docs/api/experimental/android.md +26 -0
  14. data/documentation/docs/api/experimental/android_device.md +92 -0
  15. data/documentation/docs/api/experimental/android_input.md +38 -0
  16. data/documentation/docs/api/experimental/android_socket.md +7 -0
  17. data/documentation/docs/api/experimental/android_web_view.md +7 -0
  18. data/documentation/docs/api/file_chooser.md +50 -0
  19. data/documentation/docs/api/frame.md +866 -0
  20. data/documentation/docs/api/js_handle.md +113 -0
  21. data/documentation/docs/api/keyboard.md +157 -0
  22. data/documentation/docs/api/mouse.md +69 -0
  23. data/documentation/docs/api/page.md +1402 -0
  24. data/documentation/docs/api/playwright.md +63 -0
  25. data/documentation/docs/api/request.md +188 -0
  26. data/documentation/docs/api/response.md +97 -0
  27. data/documentation/docs/api/route.md +79 -0
  28. data/documentation/docs/api/selectors.md +23 -0
  29. data/documentation/docs/api/touchscreen.md +8 -0
  30. data/documentation/docs/api/tracing.md +47 -0
  31. data/documentation/docs/api/web_socket.md +7 -0
  32. data/documentation/docs/api/worker.md +24 -0
  33. data/documentation/docs/article/api_coverage.mdx +11 -0
  34. data/documentation/docs/article/getting_started.md +152 -0
  35. data/documentation/docs/article/guides/_category_.yml +3 -0
  36. data/documentation/docs/article/guides/download_playwright_driver.md +49 -0
  37. data/documentation/docs/article/guides/launch_browser.md +119 -0
  38. data/documentation/docs/article/guides/rails_integration.md +205 -0
  39. data/documentation/docs/article/guides/recording_video.md +79 -0
  40. data/{docs → documentation/docs/include}/api_coverage.md +4 -3
  41. data/documentation/docusaurus.config.js +107 -0
  42. data/documentation/package.json +39 -0
  43. data/documentation/sidebars.js +15 -0
  44. data/documentation/src/components/HomepageFeatures.js +61 -0
  45. data/documentation/src/components/HomepageFeatures.module.css +13 -0
  46. data/documentation/src/css/custom.css +44 -0
  47. data/documentation/src/pages/index.js +50 -0
  48. data/documentation/src/pages/index.module.css +41 -0
  49. data/documentation/src/pages/markdown-page.md +7 -0
  50. data/documentation/static/.nojekyll +0 -0
  51. data/documentation/static/img/playwright-logo.svg +9 -0
  52. data/documentation/static/img/undraw_dropdown_menu.svg +1 -0
  53. data/documentation/static/img/undraw_web_development.svg +1 -0
  54. data/documentation/static/img/undraw_windows.svg +1 -0
  55. data/documentation/yarn.lock +8785 -0
  56. data/lib/playwright/channel_owners/binding_call.rb +33 -0
  57. data/lib/playwright/channel_owners/browser.rb +15 -27
  58. data/lib/playwright/channel_owners/browser_context.rb +15 -7
  59. data/lib/playwright/channel_owners/browser_type.rb +23 -8
  60. data/lib/playwright/channel_owners/element_handle.rb +2 -10
  61. data/lib/playwright/channel_owners/frame.rb +6 -28
  62. data/lib/playwright/channel_owners/js_handle.rb +2 -10
  63. data/lib/playwright/channel_owners/page.rb +18 -8
  64. data/lib/playwright/channel_owners/worker.rb +4 -0
  65. data/lib/playwright/input_files.rb +0 -8
  66. data/lib/playwright/javascript.rb +0 -10
  67. data/lib/playwright/javascript/expression.rb +2 -7
  68. data/lib/playwright/playwright_api.rb +16 -1
  69. data/lib/playwright/tracing_impl.rb +9 -9
  70. data/lib/playwright/version.rb +1 -1
  71. data/lib/playwright_api/accessibility.rb +7 -89
  72. data/lib/playwright_api/android.rb +10 -66
  73. data/lib/playwright_api/android_device.rb +10 -9
  74. data/lib/playwright_api/browser.rb +21 -172
  75. data/lib/playwright_api/browser_context.rb +54 -617
  76. data/lib/playwright_api/browser_type.rb +20 -108
  77. data/lib/playwright_api/cdp_session.rb +2 -25
  78. data/lib/playwright_api/console_message.rb +6 -6
  79. data/lib/playwright_api/dialog.rb +11 -92
  80. data/lib/playwright_api/element_handle.rb +60 -362
  81. data/lib/playwright_api/file_chooser.rb +0 -28
  82. data/lib/playwright_api/frame.rb +74 -713
  83. data/lib/playwright_api/js_handle.rb +16 -90
  84. data/lib/playwright_api/keyboard.rb +21 -213
  85. data/lib/playwright_api/mouse.rb +1 -45
  86. data/lib/playwright_api/page.rb +181 -1647
  87. data/lib/playwright_api/playwright.rb +14 -117
  88. data/lib/playwright_api/request.rb +15 -121
  89. data/lib/playwright_api/response.rb +7 -7
  90. data/lib/playwright_api/route.rb +8 -105
  91. data/lib/playwright_api/selectors.rb +6 -97
  92. data/lib/playwright_api/tracing.rb +7 -73
  93. data/lib/playwright_api/web_socket.rb +1 -1
  94. data/lib/playwright_api/worker.rb +28 -42
  95. metadata +57 -4
  96. data/lib/playwright/javascript/function.rb +0 -67
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a283a84899327e4b56db01800535c7231c1c2e94e7cbf11bd72ec60b1415c92c
4
- data.tar.gz: 5e929e57b0b8d3b0970c2a0cb5029acd6cc5bd23e419bf06bc1b0a45e2f5e781
3
+ metadata.gz: 2c3d1d005addff01402de5290c11dbac3aaac9a49608b7d88b3f86dffac45090
4
+ data.tar.gz: 3bde2b4a9f082fbdfb8b4577cfc6afadf19fe538e741b2bd4728ea942e3dd85b
5
5
  SHA512:
6
- metadata.gz: d13545073c8a110c55098547c7f7c5c4adae5c542b6b18f78be4cf3e5187cf2c92d8ccc86484c0e7bdfbeaf619ff6c8f77ce2f9c82b5eccad4c72dffb22603a5
7
- data.tar.gz: ea4a751f747e5738121c8603eb3e495dd2ef32082d1fbd92841c2a0182637300b7c3bde0a00acbf1b25bdc572b140ff4e8a5a694dda95152f568ea5aa2760fef
6
+ metadata.gz: 2a48cffd45f0ffd1a946c08d7ab920aac304812545271e7c250eae1bf0004d4c5be78688b04a513c5ec950b8e9d5c90c54f8e18c24e9e0856be8aa739c0e379b
7
+ data.tar.gz: 9b75e4959d91687cc995453f9ae76fea2b62c4641f949b9c60a197c0d11ad70060405159180309bc874fa0945a40d97c07ff2aa8033eb0e60fc2d12fc5a781b1
@@ -0,0 +1,33 @@
1
+ # Website
2
+
3
+ This website is built using [Docusaurus 2](https://docusaurus.io/), a modern static website generator.
4
+
5
+ ## Installation
6
+
7
+ ```console
8
+ yarn install
9
+ ```
10
+
11
+ ## Local Development
12
+
13
+ ```console
14
+ yarn start
15
+ ```
16
+
17
+ This command starts a local development server and opens up a browser window. Most changes are reflected live without having to restart the server.
18
+
19
+ ## Build
20
+
21
+ ```console
22
+ yarn build
23
+ ```
24
+
25
+ This command generates static content into the `build` directory and can be served using any static contents hosting service.
26
+
27
+ ## Deployment
28
+
29
+ ```console
30
+ GIT_USER=<Your GitHub username> USE_SSH=true yarn deploy
31
+ ```
32
+
33
+ If you are using GitHub pages for hosting, this command is a convenient way to build the website and push to the `gh-pages` branch.
@@ -0,0 +1,3 @@
1
+ module.exports = {
2
+ presets: [require.resolve('@docusaurus/core/lib/babel/preset')],
3
+ };
@@ -0,0 +1,7 @@
1
+ ---
2
+ sidebar_position: 10
3
+ ---
4
+
5
+ # Accessibility
6
+
7
+ Not Implemented
@@ -0,0 +1,188 @@
1
+ ---
2
+ sidebar_position: 10
3
+ ---
4
+
5
+ # Browser
6
+
7
+ - extends: [EventEmitter]
8
+
9
+ A Browser is created via [BrowserType#launch](./browser_type#launch). An example of using a [Browser](./browser) to create a [Page](./page):
10
+
11
+ ```ruby
12
+ firefox = playwright.firefox
13
+ browser = firefox.launch
14
+ begin
15
+ page = browser.new_page
16
+ page.goto("https://example.com")
17
+ ensure
18
+ browser.close
19
+ end
20
+ ```
21
+
22
+
23
+
24
+ ## close
25
+
26
+ ```
27
+ def close
28
+ ```
29
+
30
+ In case this browser is obtained using [BrowserType#launch](./browser_type#launch), closes the browser and all of its pages (if any
31
+ were opened).
32
+
33
+ In case this browser is connected to, clears all created contexts belonging to this browser and disconnects from the
34
+ browser server.
35
+
36
+ The [Browser](./browser) object itself is considered to be disposed and cannot be used anymore.
37
+
38
+ ## contexts
39
+
40
+ ```
41
+ def contexts
42
+ ```
43
+
44
+ Returns an array of all open browser contexts. In a newly created browser, this will return zero browser contexts.
45
+
46
+ ```ruby
47
+ playwright.webkit.launch do |browser|
48
+ puts browser.contexts.count # => 0
49
+ context = browser.new_context
50
+ puts browser.contexts.count # => 1
51
+ end
52
+ ```
53
+
54
+
55
+
56
+ ## connected?
57
+
58
+ ```
59
+ def connected?
60
+ ```
61
+
62
+ Indicates that the browser is connected.
63
+
64
+ ## new_context
65
+
66
+ ```
67
+ def new_context(
68
+ acceptDownloads: nil,
69
+ bypassCSP: nil,
70
+ colorScheme: nil,
71
+ deviceScaleFactor: nil,
72
+ extraHTTPHeaders: nil,
73
+ geolocation: nil,
74
+ hasTouch: nil,
75
+ httpCredentials: nil,
76
+ ignoreHTTPSErrors: nil,
77
+ isMobile: nil,
78
+ javaScriptEnabled: nil,
79
+ locale: nil,
80
+ noViewport: nil,
81
+ offline: nil,
82
+ permissions: nil,
83
+ proxy: nil,
84
+ record_har_omit_content: nil,
85
+ record_har_path: nil,
86
+ record_video_dir: nil,
87
+ record_video_size: nil,
88
+ reducedMotion: nil,
89
+ screen: nil,
90
+ storageState: nil,
91
+ timezoneId: nil,
92
+ userAgent: nil,
93
+ viewport: nil,
94
+ &block)
95
+ ```
96
+
97
+ Creates a new browser context. It won't share cookies/cache with other browser contexts.
98
+
99
+ ```ruby
100
+ playwright.firefox.launch do |browser| # or "chromium.launch" or "webkit.launch".
101
+ # create a new incognito browser context.
102
+ context = browser.new_context
103
+
104
+ # create a new page in a pristine context.
105
+ page = context.new_page()
106
+ page.goto("https://example.com")
107
+ end
108
+ ```
109
+
110
+
111
+
112
+ ## new_page
113
+
114
+ ```
115
+ def new_page(
116
+ acceptDownloads: nil,
117
+ bypassCSP: nil,
118
+ colorScheme: nil,
119
+ deviceScaleFactor: nil,
120
+ extraHTTPHeaders: nil,
121
+ geolocation: nil,
122
+ hasTouch: nil,
123
+ httpCredentials: nil,
124
+ ignoreHTTPSErrors: nil,
125
+ isMobile: nil,
126
+ javaScriptEnabled: nil,
127
+ locale: nil,
128
+ noViewport: nil,
129
+ offline: nil,
130
+ permissions: nil,
131
+ proxy: nil,
132
+ record_har_omit_content: nil,
133
+ record_har_path: nil,
134
+ record_video_dir: nil,
135
+ record_video_size: nil,
136
+ reducedMotion: nil,
137
+ screen: nil,
138
+ storageState: nil,
139
+ timezoneId: nil,
140
+ userAgent: nil,
141
+ viewport: nil,
142
+ &block)
143
+ ```
144
+
145
+ Creates a new page in a new browser context. Closing this page will close the context as well.
146
+
147
+ This is a convenience API that should only be used for the single-page scenarios and short snippets. Production code and
148
+ testing frameworks should explicitly create [Browser#new_context](./browser#new_context) followed by the
149
+ [BrowserContext#new_page](./browser_context#new_page) to control their exact life times.
150
+
151
+ ## start_tracing
152
+
153
+ ```
154
+ def start_tracing(page: nil, categories: nil, path: nil, screenshots: nil)
155
+ ```
156
+
157
+ > NOTE: Tracing is only supported on Chromium-based browsers.
158
+
159
+ You can use [Browser#start_tracing](./browser#start_tracing) and [Browser#stop_tracing](./browser#stop_tracing) to create a trace file that can be
160
+ opened in Chrome DevTools performance panel.
161
+
162
+ ```ruby
163
+ browser.start_tracing(page: page, path: "trace.json")
164
+ begin
165
+ page.goto("https://www.google.com")
166
+ ensure
167
+ browser.stop_tracing
168
+ end
169
+ ```
170
+
171
+
172
+ ## stop_tracing
173
+
174
+ ```
175
+ def stop_tracing
176
+ ```
177
+
178
+ > NOTE: Tracing is only supported on Chromium-based browsers.
179
+
180
+ Returns the buffer with trace data.
181
+
182
+ ## version
183
+
184
+ ```
185
+ def version
186
+ ```
187
+
188
+ Returns the browser version.
@@ -0,0 +1,397 @@
1
+ ---
2
+ sidebar_position: 10
3
+ ---
4
+
5
+ # BrowserContext
6
+
7
+ - extends: [EventEmitter]
8
+
9
+ BrowserContexts provide a way to operate multiple independent browser sessions.
10
+
11
+ If a page opens another page, e.g. with a `window.open` call, the popup will belong to the parent page's browser
12
+ context.
13
+
14
+ Playwright allows creation of "incognito" browser contexts with [Browser#new_context](./browser#new_context) method. "Incognito" browser
15
+ contexts don't write any browsing data to disk.
16
+
17
+ ```ruby
18
+ # create a new incognito browser context
19
+ context = browser.new_context
20
+
21
+ # create a new page inside context.
22
+ page = context.new_page
23
+ page.goto("https://example.com")
24
+
25
+ # dispose context once it is no longer needed.
26
+ context.close()
27
+ ```
28
+
29
+
30
+
31
+ ## add_cookies
32
+
33
+ ```
34
+ def add_cookies(cookies)
35
+ ```
36
+
37
+ Adds cookies into this browser context. All pages within this context will have these cookies installed. Cookies can be
38
+ obtained via [BrowserContext#cookies](./browser_context#cookies).
39
+
40
+ ```ruby
41
+ browser_context.add_cookies([cookie_object1, cookie_object2])
42
+ ```
43
+
44
+
45
+
46
+ ## add_init_script
47
+
48
+ ```
49
+ def add_init_script(path: nil, script: nil)
50
+ ```
51
+
52
+ Adds a script which would be evaluated in one of the following scenarios:
53
+ - Whenever a page is created in the browser context or is navigated.
54
+ - Whenever a child frame is attached or navigated in any page in the browser context. In this case, the script is
55
+ evaluated in the context of the newly attached frame.
56
+
57
+ The script is evaluated after the document was created but before any of its scripts were run. This is useful to amend
58
+ the JavaScript environment, e.g. to seed `Math.random`.
59
+
60
+ An example of overriding `Math.random` before the page loads:
61
+
62
+ ```ruby
63
+ # in your playwright script, assuming the preload.js file is in same directory.
64
+ browser_context.add_init_script(path: "preload.js")
65
+ ```
66
+
67
+ > NOTE: The order of evaluation of multiple scripts installed via [BrowserContext#add_init_script](./browser_context#add_init_script) and
68
+ [Page#add_init_script](./page#add_init_script) is not defined.
69
+
70
+ ## browser
71
+
72
+ ```
73
+ def browser
74
+ ```
75
+
76
+ Returns the browser instance of the context. If it was launched as a persistent context null gets returned.
77
+
78
+ ## clear_cookies
79
+
80
+ ```
81
+ def clear_cookies
82
+ ```
83
+
84
+ Clears context cookies.
85
+
86
+ ## clear_permissions
87
+
88
+ ```
89
+ def clear_permissions
90
+ ```
91
+
92
+ Clears all permission overrides for the browser context.
93
+
94
+ ```ruby
95
+ context = browser.new_context
96
+ context.grant_permissions(["clipboard-read"])
97
+
98
+ # do stuff ..
99
+
100
+ context.clear_permissions
101
+ ```
102
+
103
+
104
+
105
+ ## close
106
+
107
+ ```
108
+ def close
109
+ ```
110
+
111
+ Closes the browser context. All the pages that belong to the browser context will be closed.
112
+
113
+ > NOTE: The default browser context cannot be closed.
114
+
115
+ ## cookies
116
+
117
+ ```
118
+ def cookies(urls: nil)
119
+ ```
120
+
121
+ If no URLs are specified, this method returns all cookies. If URLs are specified, only cookies that affect those URLs
122
+ are returned.
123
+
124
+ ## expose_binding
125
+
126
+ ```
127
+ def expose_binding(name, callback, handle: nil)
128
+ ```
129
+
130
+ The method adds a function called `name` on the `window` object of every frame in every page in the context. When
131
+ called, the function executes `callback` and returns a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) which resolves to the return value of `callback`. If
132
+ the `callback` returns a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise), it will be awaited.
133
+
134
+ The first argument of the `callback` function contains information about the caller: `{ browser_context: BrowserContext, page: Page, frame: Frame }`.
135
+
136
+ See [Page#expose_binding](./page#expose_binding) for page-only version.
137
+
138
+ An example of exposing page URL to all frames in all pages in the context:
139
+
140
+ ```ruby
141
+ browser_context.expose_binding("pageURL", ->(source) { source[:page].url })
142
+ page = browser_context.new_page
143
+
144
+ page.content = <<~HTML
145
+ <script>
146
+ async function onClick() {
147
+ document.querySelector('div').textContent = await window.pageURL();
148
+ }
149
+ </script>
150
+ <button onclick="onClick()">Click me</button>
151
+ <div></div>
152
+ HTML
153
+
154
+ page.click("button")
155
+ ```
156
+
157
+ An example of passing an element handle:
158
+
159
+ ```ruby
160
+ def print_text(source, element)
161
+ element.text_content
162
+ end
163
+
164
+ browser_context.expose_binding("clicked", method(:print_text), handle: true)
165
+ page = browser_context.new_page
166
+
167
+ page.content = <<~HTML
168
+ <script>
169
+ document.addEventListener('click', async (event) => {
170
+ alert(await window.clicked(event.target));
171
+ })
172
+ </script>
173
+ <div>Click me</div>
174
+ <div>Or click me</div>
175
+ HTML
176
+
177
+ page.click('div')
178
+ ```
179
+
180
+
181
+
182
+ ## expose_function
183
+
184
+ ```
185
+ def expose_function(name, callback)
186
+ ```
187
+
188
+ The method adds a function called `name` on the `window` object of every frame in every page in the context. When
189
+ called, the function executes `callback` and returns a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) which resolves to the return value of `callback`.
190
+
191
+ If the `callback` returns a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise), it will be awaited.
192
+
193
+ See [Page#expose_function](./page#expose_function) for page-only version.
194
+
195
+ An example of adding a `sha256` function to all pages in the context:
196
+
197
+ ```ruby
198
+ require 'digest'
199
+
200
+ def sha256(text)
201
+ Digest::SHA256.hexdigest(text)
202
+ end
203
+
204
+ browser_context.expose_function("sha256", method(:sha256))
205
+ page = browser_context.new_page()
206
+ page.content = <<~HTML
207
+ <script>
208
+ async function onClick() {
209
+ document.querySelector('div').textContent = await window.sha256('PLAYWRIGHT');
210
+ }
211
+ </script>
212
+ <button onclick="onClick()">Click me</button>
213
+ <div></div>
214
+ HTML
215
+ page.click("button")
216
+ ```
217
+
218
+
219
+
220
+ ## grant_permissions
221
+
222
+ ```
223
+ def grant_permissions(permissions, origin: nil)
224
+ ```
225
+
226
+ Grants specified permissions to the browser context. Only grants corresponding permissions to the given origin if
227
+ specified.
228
+
229
+ ## new_page
230
+
231
+ ```
232
+ def new_page(&block)
233
+ ```
234
+
235
+ Creates a new page in the browser context.
236
+
237
+ ## pages
238
+
239
+ ```
240
+ def pages
241
+ ```
242
+
243
+ Returns all open pages in the context.
244
+
245
+ ## route
246
+
247
+ ```
248
+ def route(url, handler)
249
+ ```
250
+
251
+ Routing provides the capability to modify network requests that are made by any page in the browser context. Once route
252
+ is enabled, every request matching the url pattern will stall unless it's continued, fulfilled or aborted.
253
+
254
+ An example of a naive handler that aborts all image requests:
255
+
256
+ ```ruby
257
+ context = browser.new_context
258
+ page = context.new_page
259
+ context.route("**/*.{png,jpg,jpeg}", ->(route, request) { route.abort })
260
+ page.goto("https://example.com")
261
+ ```
262
+
263
+ or the same snippet using a regex pattern instead:
264
+
265
+ ```ruby
266
+ context = browser.new_context
267
+ page = context.new_page
268
+ context.route(/\.(png|jpg)$/, ->(route, request) { route.abort })
269
+ page.goto("https://example.com")
270
+ ```
271
+
272
+ It is possible to examine the request to decide the route action. For example, mocking all requests that contain some
273
+ post data, and leaving all other requests as is:
274
+
275
+ ```ruby
276
+ def handle_route(route, request)
277
+ if request.post_data["my-string"]
278
+ mocked_data = request.post_data.merge({ "my-string" => 'mocked-data'})
279
+ route.fulfill(postData: mocked_data)
280
+ else
281
+ route.continue
282
+ end
283
+ end
284
+ context.route("/api/**", method(:handle_route))
285
+ ```
286
+
287
+ Page routes (set up with [Page#route](./page#route)) take precedence over browser context routes when request matches both
288
+ handlers.
289
+
290
+ To remove a route with its handler you can use [BrowserContext#unroute](./browser_context#unroute).
291
+
292
+ > NOTE: Enabling routing disables http cache.
293
+
294
+ ## set_default_navigation_timeout
295
+
296
+ ```
297
+ def set_default_navigation_timeout(timeout)
298
+ ```
299
+ alias: `default_navigation_timeout=`
300
+
301
+ This setting will change the default maximum navigation time for the following methods and related shortcuts:
302
+ - [Page#go_back](./page#go_back)
303
+ - [Page#go_forward](./page#go_forward)
304
+ - [Page#goto](./page#goto)
305
+ - [Page#reload](./page#reload)
306
+ - [Page#set_content](./page#set_content)
307
+ - [Page#expect_navigation](./page#expect_navigation)
308
+
309
+ > NOTE: [Page#set_default_navigation_timeout](./page#set_default_navigation_timeout) and [Page#set_default_timeout](./page#set_default_timeout) take priority over
310
+ [BrowserContext#set_default_navigation_timeout](./browser_context#set_default_navigation_timeout).
311
+
312
+ ## set_default_timeout
313
+
314
+ ```
315
+ def set_default_timeout(timeout)
316
+ ```
317
+ alias: `default_timeout=`
318
+
319
+ This setting will change the default maximum time for all the methods accepting `timeout` option.
320
+
321
+ > NOTE: [Page#set_default_navigation_timeout](./page#set_default_navigation_timeout), [Page#set_default_timeout](./page#set_default_timeout) and
322
+ [BrowserContext#set_default_navigation_timeout](./browser_context#set_default_navigation_timeout) take priority over [BrowserContext#set_default_timeout](./browser_context#set_default_timeout).
323
+
324
+ ## set_extra_http_headers
325
+
326
+ ```
327
+ def set_extra_http_headers(headers)
328
+ ```
329
+ alias: `extra_http_headers=`
330
+
331
+ The extra HTTP headers will be sent with every request initiated by any page in the context. These headers are merged
332
+ with page-specific extra HTTP headers set with [Page#set_extra_http_headers](./page#set_extra_http_headers). If page overrides a particular
333
+ header, page-specific header value will be used instead of the browser context header value.
334
+
335
+ > NOTE: [BrowserContext#set_extra_http_headers](./browser_context#set_extra_http_headers) does not guarantee the order of headers in the outgoing requests.
336
+
337
+ ## set_geolocation
338
+
339
+ ```
340
+ def set_geolocation(geolocation)
341
+ ```
342
+ alias: `geolocation=`
343
+
344
+ Sets the context's geolocation. Passing `null` or `undefined` emulates position unavailable.
345
+
346
+ ```ruby
347
+ browser_context.geolocation = { latitude: 59.95, longitude: 30.31667 }
348
+ ```
349
+
350
+ > NOTE: Consider using [BrowserContext#grant_permissions](./browser_context#grant_permissions) to grant permissions for the browser context pages to
351
+ read its geolocation.
352
+
353
+ ## set_offline
354
+
355
+ ```
356
+ def set_offline(offline)
357
+ ```
358
+ alias: `offline=`
359
+
360
+
361
+
362
+ ## unroute
363
+
364
+ ```
365
+ def unroute(url, handler: nil)
366
+ ```
367
+
368
+ Removes a route created with [BrowserContext#route](./browser_context#route). When `handler` is not specified, removes all routes for
369
+ the `url`.
370
+
371
+ ## expect_event
372
+
373
+ ```
374
+ def expect_event(event, predicate: nil, timeout: nil, &block)
375
+ ```
376
+
377
+ Waits for event to fire and passes its value into the predicate function. Returns when the predicate returns truthy
378
+ value. Will throw an error if the context closes before the event is fired. Returns the event data value.
379
+
380
+ ```ruby
381
+ new_page = browser_context.expect_event('page') do
382
+ page.click('button')
383
+ end
384
+ ```
385
+
386
+
387
+
388
+ ## expect_page
389
+
390
+ ```
391
+ def expect_page(predicate: nil, timeout: nil)
392
+ ```
393
+
394
+ Performs action and waits for a new [Page](./page) to be created in the context. If predicate is provided, it passes [Page](./page) value into the `predicate` and waits for `predicate.call(page)` to return a truthy value. Will throw an error if
395
+ the context closes before new [Page](./page) is created.
396
+
397
+ ## tracing