Skip to content

Commit

Permalink
[java]: docs for set context in firefox (#2068)[deploy site]
Browse files Browse the repository at this point in the history
java docs for set context in firefox
  • Loading branch information
navin772 authored Nov 20, 2024
1 parent e4b258f commit cb7d8ae
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 9 deletions.
26 changes: 21 additions & 5 deletions examples/java/src/test/java/dev/selenium/browsers/FirefoxTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
import org.openqa.selenium.By;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxDriverLogLevel;
import org.openqa.selenium.firefox.FirefoxDriverService;
import org.openqa.selenium.firefox.FirefoxOptions;
import org.openqa.selenium.firefox.GeckoDriverService;
import org.openqa.selenium.firefox.*;
import org.openqa.selenium.remote.service.DriverFinder;





public class FirefoxTest extends BaseTest {
private FirefoxDriver driver;

Expand Down Expand Up @@ -189,4 +189,20 @@ public void fullPageScreenshot() throws Exception {

driver.quit();
}

@Test
public void setContext() {
driver = startFirefoxDriver();

((HasContext) driver).setContext(FirefoxCommandContext.CHROME);
driver.executeScript("console.log('Inside Chrome context');");

// Verify the context is back to "content"
Assertions.assertEquals(
FirefoxCommandContext.CHROME, ((HasContext) driver).getContext(),
"The context should be 'chrome'"
);

driver.quit();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ please refer to the

{{< tabpane text=true >}}
{{< tab header="Java" >}}
{{< badge-code >}}
{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/browsers/FirefoxTest.java#L197-L198" >}}
{{< /tab >}}
{{< tab header="Python" >}}
{{< gh-codeblock path="/examples/python/tests/browsers/test_firefox.py#L149-L150" >}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ IDはアドオンインストール時の戻り値から取得できます。

{{< tabpane text=true >}}
{{< tab header="Java" >}}
{{< badge-code >}}
{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/browsers/FirefoxTest.java#L197-L198" >}}
{{< /tab >}}
{{< tab header="Python" >}}
{{< gh-codeblock path="/examples/python/tests/browsers/test_firefox.py#L149-L150" >}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ please refer to the

{{< tabpane text=true >}}
{{< tab header="Java" >}}
{{< badge-code >}}
{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/browsers/FirefoxTest.java#L197-L198" >}}
{{< /tab >}}
{{< tab header="Python" >}}
{{< gh-codeblock path="/examples/python/tests/browsers/test_firefox.py#L149-L150" >}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ please refer to the

{{< tabpane text=true >}}
{{< tab header="Java" >}}
{{< badge-code >}}
{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/browsers/FirefoxTest.java#L197-L198" >}}
{{< /tab >}}
{{< tab header="Python" >}}
{{< gh-codeblock path="/examples/python/tests/browsers/test_firefox.py#L149-L150" >}}
Expand Down

0 comments on commit cb7d8ae

Please sign in to comment.