Skip to content

Commit

Permalink
[py]: add chrome and edge set_permissions docs (#2058)[deploy site]
Browse files Browse the repository at this point in the history
add chrome and edge set_permissions docs

Co-authored-by: Sri Harsha <[email protected]>
  • Loading branch information
navin772 and harsha509 authored Nov 14, 2024
1 parent 25f35c0 commit 9d66c22
Show file tree
Hide file tree
Showing 10 changed files with 66 additions and 24 deletions.
21 changes: 21 additions & 0 deletions examples/python/tests/browsers/test_chrome.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,24 @@ def test_set_network_conditions():
assert driver.get_network_conditions() == network_conditions

driver.quit()


def test_set_permissions():
driver = webdriver.Chrome()
driver.get('https://www.selenium.dev')

driver.set_permissions('camera', 'denied')

assert get_permission_state(driver, 'camera') == 'denied'
driver.quit()


def get_permission_state(driver, name):
"""Helper function to query the permission state."""
script = """
const callback = arguments[arguments.length - 1];
navigator.permissions.query({name: arguments[0]}).then(permissionStatus => {
callback(permissionStatus.state);
});
"""
return driver.execute_async_script(script, name)
21 changes: 21 additions & 0 deletions examples/python/tests/browsers/test_edge.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,24 @@ def test_set_network_conditions():
assert driver.get_network_conditions() == network_conditions

driver.quit()


def test_set_permissions():
driver = webdriver.Edge()
driver.get('https://www.selenium.dev')

driver.set_permissions('camera', 'denied')

assert get_permission_state(driver, 'camera') == 'denied'
driver.quit()


def get_permission_state(driver, name):
"""Helper function to query the permission state."""
script = """
const callback = arguments[arguments.length - 1];
navigator.permissions.query({name: arguments[0]}).then(permissionStatus => {
callback(permissionStatus.state);
});
"""
return driver.execute_async_script(script, name)
Original file line number Diff line number Diff line change
Expand Up @@ -444,9 +444,9 @@ You can simulate various network conditions.
{{< tab header="Java" >}}
{{< badge-code >}}
{{< /tab >}}
{{% tab header="Python" %}}
{{< badge-code >}}
{{% /tab %}}
{{< tab header="Python" >}}
{{< gh-codeblock path="/examples/python/tests/browsers/test_chrome.py#L149" >}}
{{< /tab >}}
{{< tab header="CSharp" >}}
{{< badge-code >}}
{{< /tab >}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -438,9 +438,9 @@ Chrome Castデバイスを操作することができ、タブの共有も含ま
{{< tab header="Java" >}}
{{< badge-code >}}
{{< /tab >}}
{{% tab header="Python" %}}
{{< badge-code >}}
{{% /tab %}}
{{< tab header="Python" >}}
{{< gh-codeblock path="/examples/python/tests/browsers/test_chrome.py#L149" >}}
{{< /tab >}}
{{< tab header="CSharp" >}}
{{< badge-code >}}
{{< /tab >}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -447,9 +447,9 @@ please refer to the
{{< tab header="Java" >}}
{{< badge-code >}}
{{< /tab >}}
{{% tab header="Python" %}}
{{< badge-code >}}
{{% /tab %}}
{{< tab header="Python" >}}
{{< gh-codeblock path="/examples/python/tests/browsers/test_chrome.py#L149" >}}
{{< /tab >}}
{{< tab header="CSharp" >}}
{{< badge-code >}}
{{< /tab >}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -448,9 +448,9 @@ Chromedriver 和 Chrome 浏览器版本应该匹配, 如果它们不匹配, 驱
{{< tab header="Java" >}}
{{< badge-code >}}
{{< /tab >}}
{{% tab header="Python" %}}
{{< badge-code >}}
{{% /tab %}}
{{< tab header="Python" >}}
{{< gh-codeblock path="/examples/python/tests/browsers/test_chrome.py#L149" >}}
{{< /tab >}}
{{< tab header="CSharp" >}}
{{< badge-code >}}
{{< /tab >}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -444,9 +444,9 @@ You can simulate various network conditions.
{{< tab header="Java" >}}
{{< badge-code >}}
{{< /tab >}}
{{% tab header="Python" %}}
{{< badge-code >}}
{{% /tab %}}
{{< tab header="Python" >}}
{{< gh-codeblock path="/examples/python/tests/browsers/test_edge.py#L149" >}}
{{< /tab >}}
{{< tab header="CSharp" >}}
{{< badge-code >}}
{{< /tab >}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -430,9 +430,9 @@ Edge を使用して Chrome Cast デバイスを操作し、タブを共有す
{{< tab header="Java" >}}
{{< badge-code >}}
{{< /tab >}}
{{% tab header="Python" %}}
{{< badge-code >}}
{{% /tab %}}
{{< tab header="Python" >}}
{{< gh-codeblock path="/examples/python/tests/browsers/test_edge.py#L149" >}}
{{< /tab >}}
{{< tab header="CSharp" >}}
{{< badge-code >}}
{{< /tab >}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -446,9 +446,9 @@ You can simulate various network conditions.
{{< tab header="Java" >}}
{{< badge-code >}}
{{< /tab >}}
{{% tab header="Python" %}}
{{< badge-code >}}
{{% /tab %}}
{{< tab header="Python" >}}
{{< gh-codeblock path="/examples/python/tests/browsers/test_edge.py#L149" >}}
{{< /tab >}}
{{< tab header="CSharp" >}}
{{< badge-code >}}
{{< /tab >}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -446,9 +446,9 @@ You can simulate various network conditions.
{{< tab header="Java" >}}
{{< badge-code >}}
{{< /tab >}}
{{% tab header="Python" %}}
{{< badge-code >}}
{{% /tab %}}
{{< tab header="Python" >}}
{{< gh-codeblock path="/examples/python/tests/browsers/test_edge.py#L149" >}}
{{< /tab >}}
{{< tab header="CSharp" >}}
{{< badge-code >}}
{{< /tab >}}
Expand Down

0 comments on commit 9d66c22

Please sign in to comment.