Skip to content

Commit

Permalink
[java]: add java docs for setPermission for chrome and edge browsers (#…
Browse files Browse the repository at this point in the history
…2063)

* add java docs for setPermission in chrome and edge

* remove text blocks to support Java 11
  • Loading branch information
navin772 authored Nov 15, 2024
1 parent 9f69706 commit 0ec7656
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 8 deletions.
16 changes: 16 additions & 0 deletions examples/java/src/test/java/dev/selenium/browsers/ChromeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
16 changes: 16 additions & 0 deletions examples/java/src/test/java/dev/selenium/browsers/EdgeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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" >}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" >}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" >}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" >}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" >}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" >}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" >}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" >}}
Expand Down

0 comments on commit 0ec7656

Please sign in to comment.