diff --git a/development/generate_api/example_codes.rb b/development/generate_api/example_codes.rb index 1f5f1e8a..17f98f5a 100644 --- a/development/generate_api/example_codes.rb +++ b/development/generate_api/example_codes.rb @@ -19,7 +19,7 @@ def example_2e5019929403491cde0c78bed1e0e18e0c86ab423d7ac8715876c4de4814f483(pag end # Accessibility - def example_388652162f4e169aab346af9ea657dd96de9217cd390a4cae2090af952b7aebe(page:) + def example_3d67a99411b5f924d573427b6f54aff63f7241f2b810959b79948bd3b522404a(page:) def find_focused_node(node) if node['focused'] node @@ -463,7 +463,7 @@ def example_6b70ea4cf0c7ae9c82cf0ed22ab0dbbb563e2d1419b35d04aa513cf91f0856f9(pag end # ElementHandle#eval_on_selector - def example_f6a83ec555fcf23877c11cf55f02a8c89a7fc11d3324859feda42e592e129f4f(page:) + def example_64bcac14fcbd1a2e6d6f32164d92124a90dddbfa9277f7503be7b0a401c9cf85(page:) tweet_handle = page.query_selector(".tweet") tweet_handle.eval_on_selector(".like", "node => node.innerText") # => "100" tweet_handle.eval_on_selector(".retweets", "node => node.innerText") # => "10" @@ -718,7 +718,7 @@ def example_2400f96eaaed3bc6ef6b0a16ba48e83d38a166c7d55a5dba0025472cffc6f2be(pag end # JSHandle#properties - def example_b5cbf187e1332705618516d4be127b8091a5d1acfa9a12d382086a2b0e738909(page:) + def example_49eec7966dd7a081de100e4563b110174e5e2dc4b89959cd14894097080346dc(page:) page.goto('https://example.com/') handle = page.evaluate_handle("({window, document})") properties = handle.properties @@ -921,7 +921,7 @@ def example_77567051f4c8531c719eb0b94e53a061ffe9a414e3bb131cbc956d1fdcf6eab3(pag end # Locator#filter - def example_516c962e3016789b2f0d21854daed72507a490b018b3f0213d4ae25f9ee03267(page:) + def example_981a978542d75734983c5b8d6fc19f2b2e94d93d3ecce2349a55fff99918b412(page:) row_locator = page.locator("tr") # ... row_locator. @@ -992,7 +992,7 @@ def example_d6cc7c4a653d7139137c582ad853bebd92e3b97893fb6d5f88919553404c57e4(pag end # Locator#or - def example_1828ac86226726cd674afe7d43e8d2bda4b1e9309c5ed1f2d57b4fd1c8024060(page:) + def example_180e47ad1dc80f352ad9ffc8519b25c65c17b7413febe4912e66acc198de69e7(page:) new_email = page.get_by_role("button", name: "New") dialog = page.get_by_text("Confirm security settings") new_email.or(dialog).wait_for(state: 'visible') diff --git a/development/unimplemented_examples.md b/development/unimplemented_examples.md index 6bf0f731..aa93d2c9 100644 --- a/development/unimplemented_examples.md +++ b/development/unimplemented_examples.md @@ -5,45 +5,6 @@ Excample codes in API documentation is replaces with the methods defined in deve The examples listed below is not yet implemented, and documentation shows Python code. -### example_49eec7966dd7a081de100e4563b110174e5e2dc4b89959cd14894097080346dc (JSHandle#get_properties) - -``` -handle = page.evaluate_handle("({ window, document })") -properties = handle.get_properties() -window_handle = properties.get("window") -document_handle = properties.get("document") -handle.dispose() - -``` - -### example_64bcac14fcbd1a2e6d6f32164d92124a90dddbfa9277f7503be7b0a401c9cf85 (ElementHandle#eval_on_selector) - -``` -tweet_handle = page.query_selector(".tweet") -assert tweet_handle.eval_on_selector(".like", "node => node.innerText") == "100" -assert tweet_handle.eval_on_selector(".retweets", "node => node.innerText") == "10" - -``` - -### example_3d67a99411b5f924d573427b6f54aff63f7241f2b810959b79948bd3b522404a (Accessibility#snapshot) - -``` -def find_focused_node(node): - if node.get("focused"): - return node - for child in (node.get("children") or []): - found_node = find_focused_node(child) - if found_node: - return found_node - return None - -snapshot = page.accessibility.snapshot() -node = find_focused_node(snapshot) -if node: - print(node["name"]) - -``` - ### example_a0ba081a92628cce9358e983826ad7143d6757dc2780f1b53f0d2e073000409e (Page#route) ``` @@ -67,26 +28,3 @@ def handle_route(route): context.route("/api/**", handle_route) ``` - -### example_981a978542d75734983c5b8d6fc19f2b2e94d93d3ecce2349a55fff99918b412 (Locator#filter) - -``` -row_locator = page.locator("tr") -# ... -row_locator.filter(has_text="text in column 1").filter( - has=page.get_by_role("button", name="column 2 button") -).screenshot() - -``` - -### example_180e47ad1dc80f352ad9ffc8519b25c65c17b7413febe4912e66acc198de69e7 (Locator#or) - -``` -new_email = page.get_by_role("button", name="New") -dialog = page.get_by_text("Confirm security settings") -expect(new_email.or_(dialog)).to_be_visible() -if (dialog.is_visible()): - page.get_by_role("button", name="Dismiss").click() -new_email.click() - -``` diff --git a/documentation/docs/api/accessibility.md b/documentation/docs/api/accessibility.md index 67f730e0..21abc562 100644 --- a/documentation/docs/api/accessibility.md +++ b/documentation/docs/api/accessibility.md @@ -43,19 +43,18 @@ puts snapshot An example of logging the focused node's name: -```python sync title=example_3d67a99411b5f924d573427b6f54aff63f7241f2b810959b79948bd3b522404a.py -def find_focused_node(node): - if node.get("focused"): - return node - for child in (node.get("children") or []): - found_node = find_focused_node(child) - if found_node: - return found_node - return None - -snapshot = page.accessibility.snapshot() -node = find_focused_node(snapshot) -if node: - print(node["name"]) +```ruby +def find_focused_node(node) + if node['focused'] + node + else + node['children']&.find do |child| + find_focused_node(child) + end + end +end +snapshot = page.accessibility.snapshot +node = find_focused_node(snapshot) +puts node['name'] ``` diff --git a/documentation/docs/api/element_handle.md b/documentation/docs/api/element_handle.md index 268f5636..3098bcb7 100644 --- a/documentation/docs/api/element_handle.md +++ b/documentation/docs/api/element_handle.md @@ -213,11 +213,10 @@ value. **Usage** -```python sync title=example_64bcac14fcbd1a2e6d6f32164d92124a90dddbfa9277f7503be7b0a401c9cf85.py +```ruby tweet_handle = page.query_selector(".tweet") -assert tweet_handle.eval_on_selector(".like", "node => node.innerText") == "100" -assert tweet_handle.eval_on_selector(".retweets", "node => node.innerText") == "10" - +tweet_handle.eval_on_selector(".like", "node => node.innerText") # => "100" +tweet_handle.eval_on_selector(".retweets", "node => node.innerText") # => "10" ``` ## eval_on_selector_all diff --git a/documentation/docs/api/js_handle.md b/documentation/docs/api/js_handle.md index 20a98bdd..09dfbf06 100644 --- a/documentation/docs/api/js_handle.md +++ b/documentation/docs/api/js_handle.md @@ -89,13 +89,14 @@ The method returns a map with **own property names** as keys and JSHandle instan **Usage** -```python sync title=example_49eec7966dd7a081de100e4563b110174e5e2dc4b89959cd14894097080346dc.py -handle = page.evaluate_handle("({ window, document })") -properties = handle.get_properties() -window_handle = properties.get("window") -document_handle = properties.get("document") -handle.dispose() - +```ruby +page.goto('https://example.com/') +handle = page.evaluate_handle("({window, document})") +properties = handle.properties +puts properties +window_handle = properties["window"] +document_handle = properties["document"] +handle.dispose ``` ## get_property diff --git a/documentation/docs/api/locator.md b/documentation/docs/api/locator.md index bbb62b2a..8ded5a6d 100644 --- a/documentation/docs/api/locator.md +++ b/documentation/docs/api/locator.md @@ -473,13 +473,13 @@ It can be chained to filter multiple times. **Usage** -```python sync title=example_981a978542d75734983c5b8d6fc19f2b2e94d93d3ecce2349a55fff99918b412.py +```ruby row_locator = page.locator("tr") # ... -row_locator.filter(has_text="text in column 1").filter( - has=page.get_by_role("button", name="column 2 button") -).screenshot() - +row_locator. + filter(hasText: "text in column 1"). + filter(has: page.get_by_role("button", name: "column 2 button")). + screenshot ``` ## first @@ -977,14 +977,14 @@ Creates a locator that matches either of the two locators. Consider a scenario where you'd like to click on a "New email" button, but sometimes a security settings dialog shows up instead. In this case, you can wait for either a "New email" button, or a dialog and act accordingly. -```python sync title=example_180e47ad1dc80f352ad9ffc8519b25c65c17b7413febe4912e66acc198de69e7.py -new_email = page.get_by_role("button", name="New") +```ruby +new_email = page.get_by_role("button", name: "New") dialog = page.get_by_text("Confirm security settings") -expect(new_email.or_(dialog)).to_be_visible() -if (dialog.is_visible()): - page.get_by_role("button", name="Dismiss").click() -new_email.click() - +new_email.or(dialog).wait_for(state: 'visible') +if dialog.visible? + page.get_by_role("button", name: "Dismiss").click +end +new_email.click ``` ## page diff --git a/spec/integration/example_spec.rb b/spec/integration/example_spec.rb index 5b32a654..4a1dc242 100644 --- a/spec/integration/example_spec.rb +++ b/spec/integration/example_spec.rb @@ -118,7 +118,7 @@ HTML example_2e5019929403491cde0c78bed1e0e18e0c86ab423d7ac8715876c4de4814f483(page: page) - example_388652162f4e169aab346af9ea657dd96de9217cd390a4cae2090af952b7aebe(page: page) + example_3d67a99411b5f924d573427b6f54aff63f7241f2b810959b79948bd3b522404a(page: page) end end @@ -255,7 +255,7 @@ it 'should work with JSHandle#properties' do with_page do |page| with_network_retry do - example_b5cbf187e1332705618516d4be127b8091a5d1acfa9a12d382086a2b0e738909(page: page) + example_49eec7966dd7a081de100e4563b110174e5e2dc4b89959cd14894097080346dc(page: page) end end end