diff --git a/examples/java/src/test/java/dev/selenium/browsers/ChromeTest.java b/examples/java/src/test/java/dev/selenium/browsers/ChromeTest.java index a7a6e55ef7b..430ae5d1639 100644 --- a/examples/java/src/test/java/dev/selenium/browsers/ChromeTest.java +++ b/examples/java/src/test/java/dev/selenium/browsers/ChromeTest.java @@ -180,4 +180,20 @@ private File getChromeLocation() { DriverFinder finder = new DriverFinder(ChromeDriverService.createDefaultService(), options); return new File(finder.getBrowserPath()); } + + @Test + public void setPermission() { + ChromeDriver driver = new ChromeDriver(); + driver.get("https://www.selenium.dev"); + + driver.setPermission("camera", "denied"); + + // Verify the permission state is 'denied' + String script = "return navigator.permissions.query({ name: 'camera' })" + + " .then(permissionStatus => permissionStatus.state);"; + String permissionState = (String) driver.executeScript(script); + + Assertions.assertEquals("denied", permissionState); + driver.quit(); + } } diff --git a/examples/java/src/test/java/dev/selenium/browsers/EdgeTest.java b/examples/java/src/test/java/dev/selenium/browsers/EdgeTest.java index 0711b26292c..164d73b0aa0 100644 --- a/examples/java/src/test/java/dev/selenium/browsers/EdgeTest.java +++ b/examples/java/src/test/java/dev/selenium/browsers/EdgeTest.java @@ -174,4 +174,20 @@ private File getEdgeLocation() { DriverFinder finder = new DriverFinder(EdgeDriverService.createDefaultService(), options); return new File(finder.getBrowserPath()); } + + @Test + public void setPermissions() { + EdgeDriver driver = new EdgeDriver(); + driver.get("https://www.selenium.dev"); + + driver.setPermission("camera", "denied"); + + // Verify the permission state is 'denied' + String script = "return navigator.permissions.query({ name: 'camera' })" + + " .then(permissionStatus => permissionStatus.state);"; + String permissionState = (String) driver.executeScript(script); + + Assertions.assertEquals("denied", permissionState); + driver.quit(); + } } diff --git a/website_and_docs/content/documentation/webdriver/browsers/chrome.en.md b/website_and_docs/content/documentation/webdriver/browsers/chrome.en.md index 64ca84f8bb8..511793595a0 100644 --- a/website_and_docs/content/documentation/webdriver/browsers/chrome.en.md +++ b/website_and_docs/content/documentation/webdriver/browsers/chrome.en.md @@ -442,7 +442,7 @@ You can simulate various network conditions. {{< tabpane text=true >}} {{< tab header="Java" >}} -{{< badge-code >}} +{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/browsers/ChromeTest.java#L189" >}} {{< /tab >}} {{< tab header="Python" >}} {{< gh-codeblock path="/examples/python/tests/browsers/test_chrome.py#L149" >}} diff --git a/website_and_docs/content/documentation/webdriver/browsers/chrome.ja.md b/website_and_docs/content/documentation/webdriver/browsers/chrome.ja.md index 4bb00f9601d..d467f29bd71 100644 --- a/website_and_docs/content/documentation/webdriver/browsers/chrome.ja.md +++ b/website_and_docs/content/documentation/webdriver/browsers/chrome.ja.md @@ -436,7 +436,7 @@ Chrome Castデバイスを操作することができ、タブの共有も含ま {{< tabpane text=true >}} {{< tab header="Java" >}} -{{< badge-code >}} +{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/browsers/ChromeTest.java#L189" >}} {{< /tab >}} {{< tab header="Python" >}} {{< gh-codeblock path="/examples/python/tests/browsers/test_chrome.py#L149" >}} diff --git a/website_and_docs/content/documentation/webdriver/browsers/chrome.pt-br.md b/website_and_docs/content/documentation/webdriver/browsers/chrome.pt-br.md index 0fc6df4a34d..4ab23dc41ea 100644 --- a/website_and_docs/content/documentation/webdriver/browsers/chrome.pt-br.md +++ b/website_and_docs/content/documentation/webdriver/browsers/chrome.pt-br.md @@ -445,7 +445,7 @@ please refer to the {{< tabpane text=true >}} {{< tab header="Java" >}} -{{< badge-code >}} +{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/browsers/ChromeTest.java#L189" >}} {{< /tab >}} {{< tab header="Python" >}} {{< gh-codeblock path="/examples/python/tests/browsers/test_chrome.py#L149" >}} diff --git a/website_and_docs/content/documentation/webdriver/browsers/chrome.zh-cn.md b/website_and_docs/content/documentation/webdriver/browsers/chrome.zh-cn.md index ca9b273ed67..7c11540fc1b 100644 --- a/website_and_docs/content/documentation/webdriver/browsers/chrome.zh-cn.md +++ b/website_and_docs/content/documentation/webdriver/browsers/chrome.zh-cn.md @@ -446,7 +446,7 @@ Chromedriver 和 Chrome 浏览器版本应该匹配, 如果它们不匹配, 驱 {{< tabpane text=true >}} {{< tab header="Java" >}} -{{< badge-code >}} +{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/browsers/ChromeTest.java#L189" >}} {{< /tab >}} {{< tab header="Python" >}} {{< gh-codeblock path="/examples/python/tests/browsers/test_chrome.py#L149" >}} diff --git a/website_and_docs/content/documentation/webdriver/browsers/edge.en.md b/website_and_docs/content/documentation/webdriver/browsers/edge.en.md index cb2a9cd63bc..ac1d97f5713 100644 --- a/website_and_docs/content/documentation/webdriver/browsers/edge.en.md +++ b/website_and_docs/content/documentation/webdriver/browsers/edge.en.md @@ -442,7 +442,7 @@ You can simulate various network conditions. {{< tabpane text=true >}} {{< tab header="Java" >}} -{{< badge-code >}} +{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/browsers/EdgeTest.java#L183" >}} {{< /tab >}} {{< tab header="Python" >}} {{< gh-codeblock path="/examples/python/tests/browsers/test_edge.py#L149" >}} diff --git a/website_and_docs/content/documentation/webdriver/browsers/edge.ja.md b/website_and_docs/content/documentation/webdriver/browsers/edge.ja.md index 857d2052449..9ec2b35bc6c 100644 --- a/website_and_docs/content/documentation/webdriver/browsers/edge.ja.md +++ b/website_and_docs/content/documentation/webdriver/browsers/edge.ja.md @@ -428,7 +428,7 @@ Edge を使用して Chrome Cast デバイスを操作し、タブを共有す {{< tabpane text=true >}} {{< tab header="Java" >}} -{{< badge-code >}} +{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/browsers/EdgeTest.java#L183" >}} {{< /tab >}} {{< tab header="Python" >}} {{< gh-codeblock path="/examples/python/tests/browsers/test_edge.py#L149" >}} diff --git a/website_and_docs/content/documentation/webdriver/browsers/edge.pt-br.md b/website_and_docs/content/documentation/webdriver/browsers/edge.pt-br.md index 058ed2a451e..ff70e45c066 100644 --- a/website_and_docs/content/documentation/webdriver/browsers/edge.pt-br.md +++ b/website_and_docs/content/documentation/webdriver/browsers/edge.pt-br.md @@ -444,7 +444,7 @@ You can simulate various network conditions. {{< tabpane text=true >}} {{< tab header="Java" >}} -{{< badge-code >}} +{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/browsers/EdgeTest.java#L183" >}} {{< /tab >}} {{< tab header="Python" >}} {{< gh-codeblock path="/examples/python/tests/browsers/test_edge.py#L149" >}} diff --git a/website_and_docs/content/documentation/webdriver/browsers/edge.zh-cn.md b/website_and_docs/content/documentation/webdriver/browsers/edge.zh-cn.md index f2a2d6cc1b5..0f72fe589e3 100644 --- a/website_and_docs/content/documentation/webdriver/browsers/edge.zh-cn.md +++ b/website_and_docs/content/documentation/webdriver/browsers/edge.zh-cn.md @@ -444,7 +444,7 @@ You can simulate various network conditions. {{< tabpane text=true >}} {{< tab header="Java" >}} -{{< badge-code >}} +{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/browsers/EdgeTest.java#L183" >}} {{< /tab >}} {{< tab header="Python" >}} {{< gh-codeblock path="/examples/python/tests/browsers/test_edge.py#L149" >}}