Skip to content

Commit 9d66c22

Browse files
navin772harsha509
andauthored
[py]: add chrome and edge set_permissions docs (#2058)[deploy site]
add chrome and edge set_permissions docs Co-authored-by: Sri Harsha <[email protected]>
1 parent 25f35c0 commit 9d66c22

File tree

10 files changed

+66
-24
lines changed

10 files changed

+66
-24
lines changed

examples/python/tests/browsers/test_chrome.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,3 +140,24 @@ def test_set_network_conditions():
140140
assert driver.get_network_conditions() == network_conditions
141141

142142
driver.quit()
143+
144+
145+
def test_set_permissions():
146+
driver = webdriver.Chrome()
147+
driver.get('https://www.selenium.dev')
148+
149+
driver.set_permissions('camera', 'denied')
150+
151+
assert get_permission_state(driver, 'camera') == 'denied'
152+
driver.quit()
153+
154+
155+
def get_permission_state(driver, name):
156+
"""Helper function to query the permission state."""
157+
script = """
158+
const callback = arguments[arguments.length - 1];
159+
navigator.permissions.query({name: arguments[0]}).then(permissionStatus => {
160+
callback(permissionStatus.state);
161+
});
162+
"""
163+
return driver.execute_async_script(script, name)

examples/python/tests/browsers/test_edge.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,3 +140,24 @@ def test_set_network_conditions():
140140
assert driver.get_network_conditions() == network_conditions
141141

142142
driver.quit()
143+
144+
145+
def test_set_permissions():
146+
driver = webdriver.Edge()
147+
driver.get('https://www.selenium.dev')
148+
149+
driver.set_permissions('camera', 'denied')
150+
151+
assert get_permission_state(driver, 'camera') == 'denied'
152+
driver.quit()
153+
154+
155+
def get_permission_state(driver, name):
156+
"""Helper function to query the permission state."""
157+
script = """
158+
const callback = arguments[arguments.length - 1];
159+
navigator.permissions.query({name: arguments[0]}).then(permissionStatus => {
160+
callback(permissionStatus.state);
161+
});
162+
"""
163+
return driver.execute_async_script(script, name)

website_and_docs/content/documentation/webdriver/browsers/chrome.en.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -444,9 +444,9 @@ You can simulate various network conditions.
444444
{{< tab header="Java" >}}
445445
{{< badge-code >}}
446446
{{< /tab >}}
447-
{{% tab header="Python" %}}
448-
{{< badge-code >}}
449-
{{% /tab %}}
447+
{{< tab header="Python" >}}
448+
{{< gh-codeblock path="/examples/python/tests/browsers/test_chrome.py#L149" >}}
449+
{{< /tab >}}
450450
{{< tab header="CSharp" >}}
451451
{{< badge-code >}}
452452
{{< /tab >}}

website_and_docs/content/documentation/webdriver/browsers/chrome.ja.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -438,9 +438,9 @@ Chrome Castデバイスを操作することができ、タブの共有も含ま
438438
{{< tab header="Java" >}}
439439
{{< badge-code >}}
440440
{{< /tab >}}
441-
{{% tab header="Python" %}}
442-
{{< badge-code >}}
443-
{{% /tab %}}
441+
{{< tab header="Python" >}}
442+
{{< gh-codeblock path="/examples/python/tests/browsers/test_chrome.py#L149" >}}
443+
{{< /tab >}}
444444
{{< tab header="CSharp" >}}
445445
{{< badge-code >}}
446446
{{< /tab >}}

website_and_docs/content/documentation/webdriver/browsers/chrome.pt-br.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -447,9 +447,9 @@ please refer to the
447447
{{< tab header="Java" >}}
448448
{{< badge-code >}}
449449
{{< /tab >}}
450-
{{% tab header="Python" %}}
451-
{{< badge-code >}}
452-
{{% /tab %}}
450+
{{< tab header="Python" >}}
451+
{{< gh-codeblock path="/examples/python/tests/browsers/test_chrome.py#L149" >}}
452+
{{< /tab >}}
453453
{{< tab header="CSharp" >}}
454454
{{< badge-code >}}
455455
{{< /tab >}}

website_and_docs/content/documentation/webdriver/browsers/chrome.zh-cn.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -448,9 +448,9 @@ Chromedriver 和 Chrome 浏览器版本应该匹配, 如果它们不匹配, 驱
448448
{{< tab header="Java" >}}
449449
{{< badge-code >}}
450450
{{< /tab >}}
451-
{{% tab header="Python" %}}
452-
{{< badge-code >}}
453-
{{% /tab %}}
451+
{{< tab header="Python" >}}
452+
{{< gh-codeblock path="/examples/python/tests/browsers/test_chrome.py#L149" >}}
453+
{{< /tab >}}
454454
{{< tab header="CSharp" >}}
455455
{{< badge-code >}}
456456
{{< /tab >}}

website_and_docs/content/documentation/webdriver/browsers/edge.en.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -444,9 +444,9 @@ You can simulate various network conditions.
444444
{{< tab header="Java" >}}
445445
{{< badge-code >}}
446446
{{< /tab >}}
447-
{{% tab header="Python" %}}
448-
{{< badge-code >}}
449-
{{% /tab %}}
447+
{{< tab header="Python" >}}
448+
{{< gh-codeblock path="/examples/python/tests/browsers/test_edge.py#L149" >}}
449+
{{< /tab >}}
450450
{{< tab header="CSharp" >}}
451451
{{< badge-code >}}
452452
{{< /tab >}}

website_and_docs/content/documentation/webdriver/browsers/edge.ja.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -430,9 +430,9 @@ Edge を使用して Chrome Cast デバイスを操作し、タブを共有す
430430
{{< tab header="Java" >}}
431431
{{< badge-code >}}
432432
{{< /tab >}}
433-
{{% tab header="Python" %}}
434-
{{< badge-code >}}
435-
{{% /tab %}}
433+
{{< tab header="Python" >}}
434+
{{< gh-codeblock path="/examples/python/tests/browsers/test_edge.py#L149" >}}
435+
{{< /tab >}}
436436
{{< tab header="CSharp" >}}
437437
{{< badge-code >}}
438438
{{< /tab >}}

website_and_docs/content/documentation/webdriver/browsers/edge.pt-br.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -446,9 +446,9 @@ You can simulate various network conditions.
446446
{{< tab header="Java" >}}
447447
{{< badge-code >}}
448448
{{< /tab >}}
449-
{{% tab header="Python" %}}
450-
{{< badge-code >}}
451-
{{% /tab %}}
449+
{{< tab header="Python" >}}
450+
{{< gh-codeblock path="/examples/python/tests/browsers/test_edge.py#L149" >}}
451+
{{< /tab >}}
452452
{{< tab header="CSharp" >}}
453453
{{< badge-code >}}
454454
{{< /tab >}}

website_and_docs/content/documentation/webdriver/browsers/edge.zh-cn.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -446,9 +446,9 @@ You can simulate various network conditions.
446446
{{< tab header="Java" >}}
447447
{{< badge-code >}}
448448
{{< /tab >}}
449-
{{% tab header="Python" %}}
450-
{{< badge-code >}}
451-
{{% /tab %}}
449+
{{< tab header="Python" >}}
450+
{{< gh-codeblock path="/examples/python/tests/browsers/test_edge.py#L149" >}}
451+
{{< /tab >}}
452452
{{< tab header="CSharp" >}}
453453
{{< badge-code >}}
454454
{{< /tab >}}

0 commit comments

Comments
 (0)