Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[py]: add chrome and edge set_permissions docs #2058

Merged
merged 2 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading