├── .github ├── FUNDING.yml ├── ISSUE_TEMPLATE.md ├── PULL_REQUEST_TEMPLATE.md ├── dependabot.yml └── workflows │ ├── auto-merge.yml │ └── build.yml ├── .gitignore ├── CHANGELOG.md ├── LICENSE ├── README.md ├── docs ├── backers.html ├── carbon.html ├── css │ ├── FaceType-PublicaPlay-Regular.woff │ └── styles.css ├── img │ ├── display-console-logs-example-v3.png │ ├── footer-bg.jpg │ ├── info-bg.jpg │ ├── jenkins-attachements-test.png │ ├── pre-bg.jpg │ ├── saucelabs.png │ ├── selenium-jupiter.png │ ├── seljup-vnc.png │ ├── seljup.png │ ├── test-template.png │ └── toc-bg.jpg ├── index.html ├── selenium-jupiter.pdf └── sponsors.html ├── pom.xml └── src ├── doc └── asciidoc │ ├── backers.html │ ├── carbon.html │ ├── css │ ├── FaceType-PublicaPlay-Regular.woff │ └── styles.css │ ├── docinfo.html │ ├── img │ ├── display-console-logs-example-v3.png │ ├── footer-bg.jpg │ ├── info-bg.jpg │ ├── pre-bg.jpg │ ├── selenium-jupiter.png │ ├── seljup-vnc.png │ ├── seljup.png │ ├── test-template.png │ └── toc-bg.jpg │ ├── index.adoc │ └── sponsors.html ├── main ├── java │ └── io │ │ └── github │ │ └── bonigarcia │ │ └── seljup │ │ ├── AnnotationsReader.java │ │ ├── Arguments.java │ │ ├── Binary.java │ │ ├── Browser.java │ │ ├── BrowserBuilder.java │ │ ├── BrowserScenarioTest.java │ │ ├── BrowserType.java │ │ ├── BrowsersTemplate.java │ │ ├── CapabilitiesHandler.java │ │ ├── DockerBrowser.java │ │ ├── DriverCapabilities.java │ │ ├── DriverUrl.java │ │ ├── EnabledIfBrowserAvailable.java │ │ ├── EnabledIfDockerAvailable.java │ │ ├── EnabledIfDriverUrlOnline.java │ │ ├── Extensions.java │ │ ├── Opera.java │ │ ├── Options.java │ │ ├── OutputHandler.java │ │ ├── Preferences.java │ │ ├── ScreenshotManager.java │ │ ├── SelenideConfiguration.java │ │ ├── SelenideHandler.java │ │ ├── SeleniumJupiter.java │ │ ├── SeleniumJupiterException.java │ │ ├── SingleSession.java │ │ ├── VersionComparator.java │ │ ├── Watch.java │ │ └── config │ │ ├── Config.java │ │ └── ConfigKey.java └── resources │ └── selenium-jupiter.properties └── test ├── java └── io │ └── github │ └── bonigarcia │ └── seljup │ └── test │ ├── annotations │ └── AnnotationsReaderTest.java │ ├── capabilities │ ├── ChromeBinaryTest.java │ ├── ChromeGlobalCapabilitiesTest.java │ ├── ChromeGlobalOptionsAndParentTest.java │ ├── ChromeInConstructorWithOptionsTest.java │ ├── ChromeOptionsParent.java │ ├── ChromeOptionsTest.java │ ├── ChromeWebRtcTest.java │ ├── ClassMultipleOptions.java │ ├── FirefoxWebRtcTest.java │ ├── FirefoxWithOptionsTest.java │ ├── MixedOptionsTest.java │ ├── OperaBinaryTest.java │ ├── OperaGlobalOptionsTest.java │ ├── OperaOptionsTest.java │ └── SafariGlobalOptionsTest.java │ ├── devtools │ └── FullPageScreenshotTest.java │ ├── docker │ ├── DockerChromeBetaTest.java │ ├── DockerChromeLatestMinusOneTest.java │ ├── DockerChromeRecordingConfigTest.java │ ├── DockerChromeRecordingFailureTest.java │ ├── DockerChromeRecordingTest.java │ ├── DockerChromeTest.java │ ├── DockerChromeVncTest.java │ ├── DockerChromeWebRtcTest.java │ ├── DockerChromeWithArgumentsTest.java │ ├── DockerChromeWithOptionsTest.java │ ├── DockerChromiumTest.java │ ├── DockerCustomWdmTest.java │ ├── DockerEdgeTest.java │ ├── DockerFirefoxDevTest.java │ ├── DockerFirefoxTest.java │ ├── DockerFirefoxWithOptionsTest.java │ ├── DockerListInConstructorTest.java │ ├── DockerListTest.java │ ├── DockerMixedListInConstructorTest.java │ ├── DockerMixedListTest.java │ └── DockerMixedTest.java │ ├── forced │ └── ForcedEmptyConfigTest.java │ ├── generic │ ├── GenericInConstructorTest.java │ ├── GenericMixedTest.java │ ├── GenericTest.java │ └── GenericWithScreenshotTest.java │ ├── jenkins │ └── JenkinsTest.java │ ├── local │ ├── ChromeInConstructorTest.java │ ├── ChromeTest.java │ ├── ChromiumTest.java │ ├── EdgeTest.java │ ├── FirefoxTest.java │ ├── IExplorerTest.java │ ├── NestedTest.java │ ├── OperaTest.java │ └── SafariTest.java │ ├── remote │ ├── AppiumTest.java │ ├── RemoteChromeTest.java │ ├── RemoteFirefoxTest.java │ └── SauceLabsTest.java │ ├── screenshot │ ├── ScreenshotBase64Test.java │ ├── ScreenshotOutputFolderPerClassTest.java │ ├── ScreenshotPngTest.java │ └── ScreenshotSurefireTest.java │ ├── selenide │ ├── DockerSelenideTest.java │ ├── RemoteSelenideTest.java │ ├── SelenideGlobalConfigJupiterTest.java │ ├── SelenideParameterConfigJupiterTest.java │ ├── SelenideTest.java │ └── TemplateSelenideTest.java │ ├── singlessession │ ├── FailureCreatesScreenshotTest.java │ ├── GenericInConstructorTest.java │ ├── OrderedMultipleTest.java │ ├── OrderedTest.java │ ├── ScreenshotNamedWithClassTest.java │ └── SingleSessionTemplateRegisterTest.java │ ├── template │ ├── BrowserBuilderTest.java │ ├── BrowserScenarioFormattingTest.java │ ├── TemplateCapabilitiesTest.java │ ├── TemplateContentTest.java │ ├── TemplateFileTest.java │ ├── TemplateRegisterOptionsTest.java │ ├── TemplateRegisterRemoteTest.java │ ├── TemplateRegisterTest.java │ ├── TemplateRemoteTest.java │ ├── TemplateTest.java │ └── TemplateTwoBrowsersTest.java │ └── watcher │ ├── DisableCspFirefoxTest.java │ ├── DisplayLogsFirefoxTest.java │ ├── GatherLogsFirefoxTest.java │ └── RecordChromeTest.java └── resources ├── browsers-caps.json ├── browsers-mini.json ├── browsers-selenide.json ├── browsers-two.json ├── browsers.json ├── dark-bg.crx ├── dark-bg.xpi └── logback-test.xml /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 4 | patreon: # Replace with a single Patreon username 5 | open_collective: selenium-jupiter 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | custom: https://www.buymeacoffee.com/bonigarcia 9 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | **Description of the problem**: 4 | 5 | **Browser and version**: 6 | 7 | **Operating system**: 8 | 9 | **Selenium-Jupiter version**: 10 | 11 | **Selenium-Jupiter use**: 12 | 13 | **Selenium-Jupiter traces**: 14 | 20 | 21 | **Error trace**: 22 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ### Purpose of changes 2 | 3 | 4 | ### Types of changes 5 | 6 | 7 | - [ ] Bug-fix (non-breaking change which fixes an issue) 8 | - [ ] New feature (non-breaking change which adds functionality) 9 | - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) 10 | 11 | ### How has this been tested? 12 | 13 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: maven 4 | directory: "/" 5 | schedule: 6 | interval: daily 7 | time: '06:00' 8 | open-pull-requests-limit: 99 9 | -------------------------------------------------------------------------------- /.github/workflows/auto-merge.yml: -------------------------------------------------------------------------------- 1 | name: Dependabot auto-merge 2 | on: pull_request 3 | 4 | permissions: 5 | contents: write 6 | pull-requests: write 7 | 8 | jobs: 9 | dependabot: 10 | runs-on: ubuntu-latest 11 | if: ${{ github.actor == 'dependabot[bot]' }} 12 | steps: 13 | - name: Dependabot metadata 14 | id: metadata 15 | uses: dependabot/fetch-metadata@v1.1.1 16 | with: 17 | github-token: "${{ secrets.GITHUB_TOKEN }}" 18 | - name: Enable auto-merge for Dependabot PRs 19 | run: | 20 | max_retries=10 21 | retry_count=0 22 | sleep_duration=1 23 | while ! gh pr merge "$PR_URL" --auto --squash --body="Co-authored-by: Boni Garcia "; do 24 | retry_count=$((retry_count+1)) 25 | if [ $retry_count -ge $max_retries ]; then 26 | echo "Command failed after $retry_count attempts." 27 | exit 1 28 | fi 29 | echo "Command failed. Retrying in $sleep_duration seconds..." 30 | sleep $sleep_duration 31 | sleep_duration=$((sleep_duration * 2)) # Exponential backoff 32 | done 33 | echo "Command succeeded after $retry_count attempts." 34 | env: 35 | PR_URL: ${{github.event.pull_request.html_url}} 36 | GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} 37 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: build 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | 9 | env: 10 | DISPLAY: :99 11 | WDM_GITHUBTOKEN: ${{ secrets.WDM_GITHUBTOKEN }} 12 | GITHUB_TOKEN: ${{ secrets.WDM_GITHUBTOKEN }} 13 | SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} 14 | 15 | jobs: 16 | build: 17 | runs-on: ${{ matrix.os }} 18 | strategy: 19 | matrix: 20 | os: [ ubuntu-latest ] 21 | java: [ '17' ] 22 | 23 | steps: 24 | - name: Checkout GitHub repo 25 | uses: actions/checkout@v2 26 | - name: Set up Java 27 | uses: actions/setup-java@v2 28 | with: 29 | distribution: 'temurin' 30 | java-version: ${{ matrix.java }} 31 | - name: Start Xvfb 32 | run: Xvfb :99 & 33 | - name: Run tests 34 | uses: nick-invision/retry@v3.0.2 35 | with: 36 | timeout_minutes: 30 37 | max_attempts: 3 38 | command: | 39 | mvn -B test 40 | - name: Upload analysis to SonarCloud 41 | if: success() && !contains(github.ref, 'pull') 42 | run: > 43 | mvn -B sonar:sonar 44 | -Dsonar.host.url=https://sonarcloud.io 45 | -Dsonar.organization=bonigarcia-github 46 | -Dsonar.projectKey=io.github.bonigarcia:selenium-jupiter 47 | - name: Upload coverage to Codecov 48 | if: success() && !contains(github.ref, 'pull') 49 | uses: codecov/codecov-action@v1 50 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | target 3 | .classpath 4 | .project 5 | .settings 6 | /.idea 7 | *.iml 8 | phantomjsdriver.log 9 | *.mp4 10 | build 11 | .gradle 12 | androidLogs 13 | -------------------------------------------------------------------------------- /docs/backers.html: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /docs/carbon.html: -------------------------------------------------------------------------------- 1 | 74 | 75 | -------------------------------------------------------------------------------- /docs/css/FaceType-PublicaPlay-Regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bonigarcia/selenium-jupiter/dd202cf2d62f3e5ba09b8a77212222f6ed7841ff/docs/css/FaceType-PublicaPlay-Regular.woff -------------------------------------------------------------------------------- /docs/img/display-console-logs-example-v3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bonigarcia/selenium-jupiter/dd202cf2d62f3e5ba09b8a77212222f6ed7841ff/docs/img/display-console-logs-example-v3.png -------------------------------------------------------------------------------- /docs/img/footer-bg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bonigarcia/selenium-jupiter/dd202cf2d62f3e5ba09b8a77212222f6ed7841ff/docs/img/footer-bg.jpg -------------------------------------------------------------------------------- /docs/img/info-bg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bonigarcia/selenium-jupiter/dd202cf2d62f3e5ba09b8a77212222f6ed7841ff/docs/img/info-bg.jpg -------------------------------------------------------------------------------- /docs/img/jenkins-attachements-test.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bonigarcia/selenium-jupiter/dd202cf2d62f3e5ba09b8a77212222f6ed7841ff/docs/img/jenkins-attachements-test.png -------------------------------------------------------------------------------- /docs/img/pre-bg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bonigarcia/selenium-jupiter/dd202cf2d62f3e5ba09b8a77212222f6ed7841ff/docs/img/pre-bg.jpg -------------------------------------------------------------------------------- /docs/img/saucelabs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bonigarcia/selenium-jupiter/dd202cf2d62f3e5ba09b8a77212222f6ed7841ff/docs/img/saucelabs.png -------------------------------------------------------------------------------- /docs/img/selenium-jupiter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bonigarcia/selenium-jupiter/dd202cf2d62f3e5ba09b8a77212222f6ed7841ff/docs/img/selenium-jupiter.png -------------------------------------------------------------------------------- /docs/img/seljup-vnc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bonigarcia/selenium-jupiter/dd202cf2d62f3e5ba09b8a77212222f6ed7841ff/docs/img/seljup-vnc.png -------------------------------------------------------------------------------- /docs/img/seljup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bonigarcia/selenium-jupiter/dd202cf2d62f3e5ba09b8a77212222f6ed7841ff/docs/img/seljup.png -------------------------------------------------------------------------------- /docs/img/test-template.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bonigarcia/selenium-jupiter/dd202cf2d62f3e5ba09b8a77212222f6ed7841ff/docs/img/test-template.png -------------------------------------------------------------------------------- /docs/img/toc-bg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bonigarcia/selenium-jupiter/dd202cf2d62f3e5ba09b8a77212222f6ed7841ff/docs/img/toc-bg.jpg -------------------------------------------------------------------------------- /docs/selenium-jupiter.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bonigarcia/selenium-jupiter/dd202cf2d62f3e5ba09b8a77212222f6ed7841ff/docs/selenium-jupiter.pdf -------------------------------------------------------------------------------- /docs/sponsors.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /src/doc/asciidoc/backers.html: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /src/doc/asciidoc/carbon.html: -------------------------------------------------------------------------------- 1 | 74 | 75 | -------------------------------------------------------------------------------- /src/doc/asciidoc/css/FaceType-PublicaPlay-Regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bonigarcia/selenium-jupiter/dd202cf2d62f3e5ba09b8a77212222f6ed7841ff/src/doc/asciidoc/css/FaceType-PublicaPlay-Regular.woff -------------------------------------------------------------------------------- /src/doc/asciidoc/docinfo.html: -------------------------------------------------------------------------------- 1 | 2 | 18 | -------------------------------------------------------------------------------- /src/doc/asciidoc/img/display-console-logs-example-v3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bonigarcia/selenium-jupiter/dd202cf2d62f3e5ba09b8a77212222f6ed7841ff/src/doc/asciidoc/img/display-console-logs-example-v3.png -------------------------------------------------------------------------------- /src/doc/asciidoc/img/footer-bg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bonigarcia/selenium-jupiter/dd202cf2d62f3e5ba09b8a77212222f6ed7841ff/src/doc/asciidoc/img/footer-bg.jpg -------------------------------------------------------------------------------- /src/doc/asciidoc/img/info-bg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bonigarcia/selenium-jupiter/dd202cf2d62f3e5ba09b8a77212222f6ed7841ff/src/doc/asciidoc/img/info-bg.jpg -------------------------------------------------------------------------------- /src/doc/asciidoc/img/pre-bg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bonigarcia/selenium-jupiter/dd202cf2d62f3e5ba09b8a77212222f6ed7841ff/src/doc/asciidoc/img/pre-bg.jpg -------------------------------------------------------------------------------- /src/doc/asciidoc/img/selenium-jupiter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bonigarcia/selenium-jupiter/dd202cf2d62f3e5ba09b8a77212222f6ed7841ff/src/doc/asciidoc/img/selenium-jupiter.png -------------------------------------------------------------------------------- /src/doc/asciidoc/img/seljup-vnc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bonigarcia/selenium-jupiter/dd202cf2d62f3e5ba09b8a77212222f6ed7841ff/src/doc/asciidoc/img/seljup-vnc.png -------------------------------------------------------------------------------- /src/doc/asciidoc/img/seljup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bonigarcia/selenium-jupiter/dd202cf2d62f3e5ba09b8a77212222f6ed7841ff/src/doc/asciidoc/img/seljup.png -------------------------------------------------------------------------------- /src/doc/asciidoc/img/test-template.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bonigarcia/selenium-jupiter/dd202cf2d62f3e5ba09b8a77212222f6ed7841ff/src/doc/asciidoc/img/test-template.png -------------------------------------------------------------------------------- /src/doc/asciidoc/img/toc-bg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bonigarcia/selenium-jupiter/dd202cf2d62f3e5ba09b8a77212222f6ed7841ff/src/doc/asciidoc/img/toc-bg.jpg -------------------------------------------------------------------------------- /src/doc/asciidoc/sponsors.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /src/main/java/io/github/bonigarcia/seljup/Arguments.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2017 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup; 18 | 19 | import static java.lang.annotation.ElementType.PARAMETER; 20 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 21 | 22 | import java.lang.annotation.Retention; 23 | import java.lang.annotation.Target; 24 | 25 | /** 26 | * WebDriver options (arguments). 27 | * 28 | * @author Boni Garcia 29 | * @since 2.0.0 30 | */ 31 | @Retention(RUNTIME) 32 | @Target(PARAMETER) 33 | public @interface Arguments { 34 | 35 | public String[] value(); 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/io/github/bonigarcia/seljup/Binary.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2017 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup; 18 | 19 | import static java.lang.annotation.ElementType.PARAMETER; 20 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 21 | 22 | import java.lang.annotation.Retention; 23 | import java.lang.annotation.Target; 24 | 25 | /** 26 | * WebDriver options (binary). 27 | * 28 | * @author Boni Garcia 29 | * @since 2.0.0 30 | */ 31 | @Retention(RUNTIME) 32 | @Target(PARAMETER) 33 | public @interface Binary { 34 | 35 | public String value(); 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/io/github/bonigarcia/seljup/Browser.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2021 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup; 18 | 19 | /** 20 | * Enumeration for disabling tests conditionally based on the availability of 21 | * local browsers. 22 | * 23 | * @author Boni Garcia 24 | * @since 4.0.0 25 | */ 26 | public enum Browser { 27 | 28 | CHROME, EDGE, FIREFOX, CHROMIUM, SAFARI, OPERA; 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/io/github/bonigarcia/seljup/BrowserType.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2017 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup; 18 | 19 | /** 20 | * Enumeration for browsers in Docker containers. 21 | * 22 | * @author Boni Garcia 23 | * @since 1.2.0 24 | */ 25 | public enum BrowserType { 26 | 27 | CHROME, FIREFOX, EDGE, CHROMIUM; 28 | 29 | public String toBrowserName() { 30 | return this.name(); 31 | } 32 | 33 | public boolean isChromeBased() { 34 | return this == BrowserType.CHROME || this == BrowserType.CHROMIUM; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/io/github/bonigarcia/seljup/DockerBrowser.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2017 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup; 18 | 19 | import static java.lang.annotation.ElementType.PARAMETER; 20 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 21 | 22 | import java.lang.annotation.Retention; 23 | import java.lang.annotation.Target; 24 | 25 | /** 26 | * Annotation for browsers in Docker. 27 | * 28 | * @author Boni Garcia 29 | * @since 2.0.0 30 | */ 31 | @Retention(RUNTIME) 32 | @Target(PARAMETER) 33 | public @interface DockerBrowser { 34 | 35 | public BrowserType type(); 36 | 37 | public String version() default ""; 38 | 39 | public int size() default 0; 40 | 41 | public boolean recording() default false; 42 | 43 | public boolean vnc() default false; 44 | 45 | public String lang() default ""; 46 | 47 | public String timezone() default ""; 48 | 49 | public String[] volumes() default {}; 50 | 51 | public String args() default "--disable-gpu"; 52 | 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/io/github/bonigarcia/seljup/DriverCapabilities.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2017 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup; 18 | 19 | import static java.lang.annotation.ElementType.FIELD; 20 | import static java.lang.annotation.ElementType.PARAMETER; 21 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 22 | 23 | import java.lang.annotation.Retention; 24 | import java.lang.annotation.Target; 25 | 26 | /** 27 | * Key-value for the array of capabilities (used with DriverCapabilities 28 | * annotation). 29 | * 30 | * @author Boni Garcia 31 | * @since 2.0.0 32 | */ 33 | 34 | @Retention(RUNTIME) 35 | @Target({ PARAMETER, FIELD }) 36 | public @interface DriverCapabilities { 37 | 38 | public String[] value() default ""; 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/io/github/bonigarcia/seljup/DriverUrl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2017 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup; 18 | 19 | import static java.lang.annotation.ElementType.FIELD; 20 | import static java.lang.annotation.ElementType.PARAMETER; 21 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 22 | 23 | import java.lang.annotation.Retention; 24 | import java.lang.annotation.Target; 25 | 26 | /** 27 | * Annotation for driver URL (used in RemoteWebDriver). 28 | * 29 | * @author Boni Garcia 30 | * @since 1.0.0 31 | */ 32 | @Retention(RUNTIME) 33 | @Target({ PARAMETER, FIELD }) 34 | public @interface DriverUrl { 35 | 36 | public String value() default ""; 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/io/github/bonigarcia/seljup/EnabledIfBrowserAvailable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2021 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup; 18 | 19 | import static java.lang.annotation.ElementType.METHOD; 20 | import static java.lang.annotation.ElementType.TYPE; 21 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 22 | 23 | import java.lang.annotation.Retention; 24 | import java.lang.annotation.Target; 25 | 26 | /** 27 | * Annotation for conditionally disabling tests depending on the availability of 28 | * local browsers. 29 | * 30 | * @author Boni Garcia 31 | * @since 4.0.0 32 | */ 33 | @Retention(RUNTIME) 34 | @Target({ TYPE, METHOD }) 35 | public @interface EnabledIfBrowserAvailable { 36 | 37 | Browser[] value(); 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/io/github/bonigarcia/seljup/EnabledIfDockerAvailable.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2021 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup; 18 | 19 | import static java.lang.annotation.ElementType.METHOD; 20 | import static java.lang.annotation.ElementType.TYPE; 21 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 22 | 23 | import java.lang.annotation.Retention; 24 | import java.lang.annotation.Target; 25 | 26 | /** 27 | * Annotation for conditionally disabling tests depending on the availability of 28 | * Docker. 29 | * 30 | * @author Boni Garcia 31 | * @since 4.0.3 32 | */ 33 | @Retention(RUNTIME) 34 | @Target({ TYPE, METHOD }) 35 | public @interface EnabledIfDockerAvailable { 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/io/github/bonigarcia/seljup/EnabledIfDriverUrlOnline.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2021 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup; 18 | 19 | import static java.lang.annotation.ElementType.METHOD; 20 | import static java.lang.annotation.ElementType.TYPE; 21 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 22 | 23 | import java.lang.annotation.Retention; 24 | import java.lang.annotation.Target; 25 | 26 | /** 27 | * Annotation for conditionally disabling tests depending on the availability of 28 | * the driver URL (if online, that URL will be used for remote tests). 29 | * 30 | * @author Boni Garcia 31 | * @since 4.0.3 32 | */ 33 | @Retention(RUNTIME) 34 | @Target({ TYPE, METHOD }) 35 | public @interface EnabledIfDriverUrlOnline { 36 | 37 | String value(); 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/io/github/bonigarcia/seljup/Extensions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2017 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup; 18 | 19 | import static java.lang.annotation.ElementType.PARAMETER; 20 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 21 | 22 | import java.lang.annotation.Retention; 23 | import java.lang.annotation.Target; 24 | 25 | /** 26 | * WebDriver options (extensions). 27 | * 28 | * @author Boni Garcia 29 | * @since 2.0.0 30 | */ 31 | @Retention(RUNTIME) 32 | @Target(PARAMETER) 33 | public @interface Extensions { 34 | 35 | public String[] value(); 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/io/github/bonigarcia/seljup/Opera.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2022 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup; 18 | 19 | import static java.lang.annotation.ElementType.PARAMETER; 20 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 21 | 22 | import java.lang.annotation.Retention; 23 | import java.lang.annotation.Target; 24 | 25 | /** 26 | * Annotation for local Opera. 27 | * 28 | * @author Boni Garcia 29 | * @since 4.2.0 30 | */ 31 | @Retention(RUNTIME) 32 | @Target(PARAMETER) 33 | public @interface Opera { 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/io/github/bonigarcia/seljup/Options.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2017 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup; 18 | 19 | import static java.lang.annotation.ElementType.FIELD; 20 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 21 | 22 | import java.lang.annotation.Retention; 23 | import java.lang.annotation.Target; 24 | 25 | /** 26 | * WebDriver options. 27 | * 28 | * @author Boni Garcia 29 | * @since 2.0.0 30 | */ 31 | @Retention(RUNTIME) 32 | @Target(FIELD) 33 | public @interface Options { 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/io/github/bonigarcia/seljup/Preferences.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2017 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup; 18 | 19 | import static java.lang.annotation.ElementType.PARAMETER; 20 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 21 | 22 | import java.lang.annotation.Retention; 23 | import java.lang.annotation.Target; 24 | 25 | /** 26 | * Firefox arguments. 27 | * 28 | * @author Boni Garcia 29 | * @since 2.0.0 30 | */ 31 | @Retention(RUNTIME) 32 | @Target(PARAMETER) 33 | public @interface Preferences { 34 | 35 | public String[] value(); 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/io/github/bonigarcia/seljup/SelenideConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2019 Boni Garcia (http://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup; 18 | 19 | import static java.lang.annotation.ElementType.FIELD; 20 | import static java.lang.annotation.ElementType.PARAMETER; 21 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 22 | 23 | import java.lang.annotation.Retention; 24 | import java.lang.annotation.Target; 25 | 26 | /** 27 | * Selenide configuration. 28 | * 29 | * @author Boni Garcia (boni.gg@gmail.com) 30 | * @since 3.2.0 31 | */ 32 | @Retention(RUNTIME) 33 | @Target({ FIELD, PARAMETER }) 34 | public @interface SelenideConfiguration { 35 | 36 | public String browser() default ""; 37 | 38 | public boolean headless() default false; 39 | 40 | public String browserBinary() default ""; 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/io/github/bonigarcia/seljup/SeleniumJupiterException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2017 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup; 18 | 19 | /** 20 | * Custom exception of selenium-jupiter extension. 21 | * 22 | * @author Boni Garcia 23 | * @since 1.0.0 24 | */ 25 | public class SeleniumJupiterException extends RuntimeException { 26 | 27 | private static final long serialVersionUID = -7026228903533825338L; 28 | 29 | public SeleniumJupiterException(String message) { 30 | super(message); 31 | } 32 | 33 | public SeleniumJupiterException(Throwable cause) { 34 | super(cause); 35 | } 36 | 37 | public SeleniumJupiterException(String message, Throwable cause) { 38 | super(message, cause); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/io/github/bonigarcia/seljup/SingleSession.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2019 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup; 18 | 19 | import static java.lang.annotation.ElementType.TYPE; 20 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 21 | 22 | import java.lang.annotation.Inherited; 23 | import java.lang.annotation.Retention; 24 | import java.lang.annotation.Target; 25 | 26 | /** 27 | * Single session annotation. 28 | * 29 | * @author Boni Garcia 30 | * @since 3.2.0 31 | */ 32 | @Retention(RUNTIME) 33 | @Inherited 34 | @Target(TYPE) 35 | public @interface SingleSession { 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/io/github/bonigarcia/seljup/VersionComparator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2018 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup; 18 | 19 | import static java.lang.Integer.parseInt; 20 | import static java.lang.Math.max; 21 | 22 | import java.util.Comparator; 23 | 24 | /** 25 | * Version comparator. 26 | * 27 | * @author Boni Garcia 28 | * @since 2.1.0 29 | */ 30 | public class VersionComparator implements Comparator { 31 | @Override 32 | public int compare(String v1, String v2) { 33 | String[] v1split = v1.split("\\."); 34 | String[] v2split = v2.split("\\."); 35 | int length = max(v1split.length, v2split.length); 36 | for (int i = 0; i < length; i++) { 37 | int v1Part = i < v1split.length ? parseInt(v1split[i]) : 0; 38 | int v2Part = i < v2split.length ? parseInt(v2split[i]) : 0; 39 | if (v1Part < v2Part) { 40 | return -1; 41 | } 42 | if (v1Part > v2Part) { 43 | return 1; 44 | } 45 | } 46 | return 0; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/io/github/bonigarcia/seljup/Watch.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2022 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup; 18 | 19 | import static java.lang.annotation.ElementType.PARAMETER; 20 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 21 | 22 | import java.lang.annotation.Retention; 23 | import java.lang.annotation.Target; 24 | 25 | /** 26 | * Annotation for monitoring capabilities. 27 | * 28 | * @author Boni Garcia 29 | * @since 4.3.0 30 | */ 31 | @Retention(RUNTIME) 32 | @Target(PARAMETER) 33 | public @interface Watch { 34 | 35 | public boolean display() default false; 36 | 37 | public boolean disableCsp() default false; 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/io/github/bonigarcia/seljup/config/ConfigKey.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2018 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup.config; 18 | 19 | /** 20 | * Configuration key class. 21 | * 22 | * @author Boni Garcia 23 | * @since 2.1.0 24 | */ 25 | public class ConfigKey { 26 | 27 | String name; 28 | Class type; 29 | T value; 30 | T defaultValue; 31 | 32 | public ConfigKey(String name, Class type) { 33 | this.name = name; 34 | this.type = type; 35 | 36 | } 37 | 38 | public ConfigKey(String name, Class type, T value) { 39 | this.name = name; 40 | this.type = type; 41 | this.value = value; 42 | this.defaultValue = value; 43 | } 44 | 45 | public String getName() { 46 | return name; 47 | } 48 | 49 | public Class getType() { 50 | return type; 51 | } 52 | 53 | public T getValue() { 54 | return value; 55 | } 56 | 57 | public void reset() { 58 | value = defaultValue; 59 | } 60 | 61 | @SuppressWarnings("unchecked") 62 | public void setValue(Object value) { 63 | this.value = (T) value; 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /src/main/resources/selenium-jupiter.properties: -------------------------------------------------------------------------------- 1 | sel.jup.output.folder=. 2 | sel.jup.screenshot=false 3 | sel.jup.screenshot.when.failure=false 4 | sel.jup.screenshot.format=png 5 | sel.jup.recording=false 6 | sel.jup.recording.when.failure=false 7 | sel.jup.vnc=false 8 | sel.jup.browser.template.json.file=classpath:browsers.json 9 | -------------------------------------------------------------------------------- /src/test/java/io/github/bonigarcia/seljup/test/capabilities/ChromeBinaryTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2025 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup.test.capabilities; 18 | 19 | import static org.assertj.core.api.Assertions.assertThat; 20 | import static org.assertj.core.api.Assumptions.assumeThat; 21 | 22 | import java.nio.file.Paths; 23 | 24 | import org.junit.jupiter.api.BeforeEach; 25 | import org.junit.jupiter.api.Test; 26 | import org.junit.jupiter.api.extension.ExtendWith; 27 | import org.openqa.selenium.chrome.ChromeDriver; 28 | 29 | import io.github.bonigarcia.seljup.Binary; 30 | import io.github.bonigarcia.seljup.SeleniumJupiter; 31 | 32 | @ExtendWith(SeleniumJupiter.class) 33 | class ChromeBinaryTest { 34 | 35 | static final String BROWSER_BINARY = "/usr/bin/google-chrome-beta"; 36 | 37 | @BeforeEach 38 | void setup() { 39 | assumeThat(Paths.get(BROWSER_BINARY)).exists(); 40 | } 41 | 42 | @Test 43 | void chromeBinaryTest(@Binary(BROWSER_BINARY) ChromeDriver driver) { 44 | driver.get("https://bonigarcia.dev/selenium-webdriver-java/"); 45 | assertThat(driver.getTitle()).contains("Selenium WebDriver"); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/test/java/io/github/bonigarcia/seljup/test/capabilities/ChromeGlobalCapabilitiesTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2017 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup.test.capabilities; 18 | 19 | import static org.assertj.core.api.Assertions.assertThat; 20 | 21 | import java.util.HashMap; 22 | import java.util.Map; 23 | 24 | import org.junit.jupiter.api.Test; 25 | import org.junit.jupiter.api.extension.ExtendWith; 26 | import org.openqa.selenium.chrome.ChromeDriver; 27 | import org.openqa.selenium.chrome.ChromeOptions; 28 | 29 | import io.github.bonigarcia.seljup.Options; 30 | import io.github.bonigarcia.seljup.SeleniumJupiter; 31 | 32 | @ExtendWith(SeleniumJupiter.class) 33 | class ChromeGlobalCapabilitiesTest { 34 | 35 | @Options 36 | ChromeOptions options = new ChromeOptions(); 37 | { 38 | Map mobileEmulation = new HashMap<>(); 39 | mobileEmulation.put("deviceName", "Nexus 5"); 40 | options.setExperimentalOption("mobileEmulation", mobileEmulation); 41 | } 42 | 43 | @Test 44 | void chromeTest(ChromeDriver driver) { 45 | driver.get("https://bonigarcia.dev/selenium-webdriver-java/"); 46 | assertThat(driver.getTitle()).contains("Selenium WebDriver"); 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /src/test/java/io/github/bonigarcia/seljup/test/capabilities/ChromeGlobalOptionsAndParentTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2017 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup.test.capabilities; 18 | 19 | import static org.assertj.core.api.Assertions.assertThat; 20 | 21 | import org.junit.jupiter.api.Test; 22 | import org.junit.jupiter.api.extension.ExtendWith; 23 | import org.openqa.selenium.chrome.ChromeDriver; 24 | 25 | import io.github.bonigarcia.seljup.SeleniumJupiter; 26 | 27 | @ExtendWith(SeleniumJupiter.class) 28 | class ChromeGlobalOptionsAndParentTest 29 | extends ChromeOptionsParent { 30 | 31 | @Test 32 | void chromeTest(ChromeDriver driver) { 33 | driver.get("https://bonigarcia.dev/selenium-webdriver-java/"); 34 | assertThat(driver.getTitle()).contains("Selenium WebDriver"); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/test/java/io/github/bonigarcia/seljup/test/capabilities/ChromeInConstructorWithOptionsTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2019 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup.test.capabilities; 18 | 19 | import static org.assertj.core.api.Assertions.assertThat; 20 | 21 | import org.junit.jupiter.api.Test; 22 | import org.junit.jupiter.api.extension.ExtendWith; 23 | import org.openqa.selenium.By; 24 | import org.openqa.selenium.chrome.ChromeDriver; 25 | 26 | import io.github.bonigarcia.seljup.Arguments; 27 | import io.github.bonigarcia.seljup.SeleniumJupiter; 28 | 29 | @ExtendWith(SeleniumJupiter.class) 30 | class ChromeInConstructorWithOptionsTest { 31 | 32 | ChromeDriver driver; 33 | 34 | ChromeInConstructorWithOptionsTest( 35 | @Arguments({ "--use-fake-device-for-media-stream", 36 | "--use-fake-ui-for-media-stream" }) ChromeDriver driver) { 37 | this.driver = driver; 38 | } 39 | 40 | @Test 41 | void testGlobalChrome() { 42 | driver.get( 43 | "https://webrtc.github.io/samples/src/content/devices/input-output/"); 44 | assertThat(driver.findElement(By.id("video")).getTagName()) 45 | .isEqualTo("video"); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/test/java/io/github/bonigarcia/seljup/test/capabilities/ChromeOptionsParent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2017 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup.test.capabilities; 18 | 19 | import org.openqa.selenium.chrome.ChromeOptions; 20 | 21 | import io.github.bonigarcia.seljup.Options; 22 | 23 | class ChromeOptionsParent { 24 | 25 | @Options 26 | ChromeOptions chromeOptions = new ChromeOptions(); 27 | { 28 | chromeOptions.addArguments("--incognito"); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/test/java/io/github/bonigarcia/seljup/test/capabilities/ChromeOptionsTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2017 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup.test.capabilities; 18 | 19 | //tag::snippet-in-doc[] 20 | import static org.assertj.core.api.Assertions.assertThat; 21 | 22 | import java.time.Duration; 23 | 24 | import org.junit.jupiter.api.Test; 25 | import org.junit.jupiter.api.extension.ExtendWith; 26 | import org.openqa.selenium.By; 27 | import org.openqa.selenium.chrome.ChromeDriver; 28 | 29 | import io.github.bonigarcia.seljup.Arguments; 30 | import io.github.bonigarcia.seljup.Extensions; 31 | import io.github.bonigarcia.seljup.SeleniumJupiter; 32 | 33 | @ExtendWith(SeleniumJupiter.class) 34 | class ChromeOptionsTest { 35 | 36 | @Test 37 | void headlessTest(@Arguments("--headless") ChromeDriver driver) { 38 | driver.get("https://bonigarcia.dev/selenium-webdriver-java/"); 39 | assertThat(driver.getTitle()).contains("Selenium WebDriver"); 40 | } 41 | 42 | @Test 43 | void webrtcTest( 44 | @Arguments({ "--use-fake-device-for-media-stream", 45 | "--use-fake-ui-for-media-stream" }) ChromeDriver driver) 46 | throws InterruptedException { 47 | driver.get( 48 | "https://webrtc.github.io/samples/src/content/devices/input-output/"); 49 | assertThat(driver.findElement(By.id("video")).getTagName()) 50 | .isEqualTo("video"); 51 | 52 | Thread.sleep(Duration.ofSeconds(5).toMillis()); 53 | } 54 | 55 | @Test 56 | void extensionTest(@Extensions("dark-bg.crx") ChromeDriver driver) { 57 | driver.get("https://bonigarcia.dev/selenium-webdriver-java/"); 58 | assertThat(driver.getTitle()).contains("Selenium WebDriver"); 59 | } 60 | 61 | } 62 | //end::snippet-in-doc[] 63 | -------------------------------------------------------------------------------- /src/test/java/io/github/bonigarcia/seljup/test/capabilities/ChromeWebRtcTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2017 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup.test.capabilities; 18 | 19 | import static org.assertj.core.api.Assertions.assertThat; 20 | 21 | import java.time.Duration; 22 | 23 | import org.junit.jupiter.api.Test; 24 | import org.junit.jupiter.api.extension.ExtendWith; 25 | import org.openqa.selenium.By; 26 | import org.openqa.selenium.chrome.ChromeDriver; 27 | import org.openqa.selenium.chrome.ChromeOptions; 28 | 29 | import io.github.bonigarcia.seljup.Options; 30 | import io.github.bonigarcia.seljup.SeleniumJupiter; 31 | 32 | @ExtendWith(SeleniumJupiter.class) 33 | class ChromeWebRtcTest { 34 | 35 | @Options 36 | ChromeOptions chromeOptions = new ChromeOptions(); 37 | { 38 | chromeOptions.addArguments("--use-fake-device-for-media-stream", 39 | "--use-fake-ui-for-media-stream"); 40 | } 41 | 42 | @Test 43 | void webrtcTest(ChromeDriver driver) throws InterruptedException { 44 | driver.get( 45 | "https://webrtc.github.io/samples/src/content/devices/input-output/"); 46 | assertThat(driver.findElement(By.id("video")).getTagName()) 47 | .isEqualTo("video"); 48 | 49 | Thread.sleep(Duration.ofSeconds(5).toMillis()); 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /src/test/java/io/github/bonigarcia/seljup/test/capabilities/ClassMultipleOptions.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2018 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup.test.capabilities; 18 | 19 | import org.openqa.selenium.edge.EdgeOptions; 20 | import org.openqa.selenium.firefox.FirefoxOptions; 21 | import org.openqa.selenium.safari.SafariOptions; 22 | 23 | import io.github.bonigarcia.seljup.Options; 24 | 25 | class ClassMultipleOptions { 26 | 27 | @Options 28 | Object options = new Object(); 29 | 30 | @Options 31 | EdgeOptions edgeOptions = new EdgeOptions(); 32 | 33 | @Options 34 | FirefoxOptions firefoxOptions = new FirefoxOptions(); 35 | 36 | @Options 37 | SafariOptions safariOptions = new SafariOptions(); 38 | } -------------------------------------------------------------------------------- /src/test/java/io/github/bonigarcia/seljup/test/capabilities/FirefoxWebRtcTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2017 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup.test.capabilities; 18 | 19 | //tag::snippet-in-doc[] 20 | import static org.assertj.core.api.Assertions.assertThat; 21 | 22 | import java.time.Duration; 23 | 24 | import org.junit.jupiter.api.Test; 25 | import org.junit.jupiter.api.extension.ExtendWith; 26 | import org.openqa.selenium.By; 27 | import org.openqa.selenium.firefox.FirefoxDriver; 28 | import org.openqa.selenium.firefox.FirefoxOptions; 29 | 30 | import io.github.bonigarcia.seljup.Options; 31 | import io.github.bonigarcia.seljup.SeleniumJupiter; 32 | 33 | @ExtendWith(SeleniumJupiter.class) 34 | class FirefoxWebRtcTest { 35 | 36 | @Options 37 | FirefoxOptions firefoxOptions = new FirefoxOptions(); 38 | { 39 | // Flag to use fake media for WebRTC user media 40 | firefoxOptions.addPreference("media.navigator.streams.fake", true); 41 | 42 | // Flag to avoid granting access to user media 43 | firefoxOptions.addPreference("media.navigator.permission.disabled", 44 | true); 45 | } 46 | 47 | @Test 48 | void webrtcTest(FirefoxDriver driver) throws InterruptedException { 49 | driver.get( 50 | "https://webrtc.github.io/samples/src/content/devices/input-output/"); 51 | assertThat(driver.findElement(By.id("video")).getTagName()) 52 | .isEqualTo("video"); 53 | 54 | Thread.sleep(Duration.ofSeconds(5).toMillis()); 55 | } 56 | 57 | } 58 | //end::snippet-in-doc[] 59 | -------------------------------------------------------------------------------- /src/test/java/io/github/bonigarcia/seljup/test/capabilities/FirefoxWithOptionsTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2017 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup.test.capabilities; 18 | 19 | //tag::snippet-in-doc[] 20 | import static org.assertj.core.api.Assertions.assertThat; 21 | 22 | import org.junit.jupiter.api.Test; 23 | import org.junit.jupiter.api.extension.ExtendWith; 24 | import org.openqa.selenium.By; 25 | import org.openqa.selenium.firefox.FirefoxDriver; 26 | 27 | import io.github.bonigarcia.seljup.Arguments; 28 | import io.github.bonigarcia.seljup.Extensions; 29 | import io.github.bonigarcia.seljup.Preferences; 30 | import io.github.bonigarcia.seljup.SeleniumJupiter; 31 | 32 | @ExtendWith(SeleniumJupiter.class) 33 | class FirefoxWithOptionsTest { 34 | 35 | @Test 36 | void webrtcTest(@Arguments("-private") @Preferences({ 37 | "media.navigator.permission.disabled=true", 38 | "media.navigator.streams.fake=true" }) FirefoxDriver driver) { 39 | driver.get( 40 | "https://webrtc.github.io/samples/src/content/devices/input-output/"); 41 | assertThat(driver.findElement(By.id("video")).getTagName()) 42 | .isEqualTo("video"); 43 | } 44 | 45 | @Test 46 | void extensionTest(@Extensions("dark-bg.xpi") FirefoxDriver driver) { 47 | driver.get("https://bonigarcia.dev/selenium-webdriver-java/"); 48 | assertThat(driver.getTitle()).contains("Selenium WebDriver"); 49 | } 50 | 51 | } 52 | //end::snippet-in-doc[] 53 | -------------------------------------------------------------------------------- /src/test/java/io/github/bonigarcia/seljup/test/capabilities/MixedOptionsTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2019 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup.test.capabilities; 18 | 19 | import static org.assertj.core.api.Assertions.assertThat; 20 | 21 | import org.junit.jupiter.api.Test; 22 | import org.junit.jupiter.api.extension.ExtendWith; 23 | import org.openqa.selenium.By; 24 | import org.openqa.selenium.WebDriver; 25 | import org.openqa.selenium.chrome.ChromeDriver; 26 | import org.openqa.selenium.chrome.ChromeOptions; 27 | import org.openqa.selenium.firefox.FirefoxDriver; 28 | import org.openqa.selenium.firefox.FirefoxOptions; 29 | 30 | import io.github.bonigarcia.seljup.Options; 31 | import io.github.bonigarcia.seljup.SeleniumJupiter; 32 | 33 | @ExtendWith(SeleniumJupiter.class) 34 | class MixedOptionsTest { 35 | 36 | @Options 37 | ChromeOptions chromeOptions = new ChromeOptions(); 38 | { 39 | chromeOptions.addArguments("--use-fake-device-for-media-stream", 40 | "--use-fake-ui-for-media-stream"); 41 | } 42 | 43 | @Options 44 | FirefoxOptions firefoxOptions = new FirefoxOptions(); 45 | { 46 | firefoxOptions.addPreference("media.navigator.streams.fake", true); 47 | firefoxOptions.addPreference("media.navigator.permission.disabled", 48 | true); 49 | } 50 | 51 | @Test 52 | void webrtcTest(ChromeDriver chrome, FirefoxDriver firefox) { 53 | exercise(chrome, firefox); 54 | } 55 | 56 | void exercise(WebDriver... drivers) { 57 | for (WebDriver driver : drivers) { 58 | driver.get( 59 | "https://webrtc.github.io/samples/src/content/devices/input-output/"); 60 | assertThat(driver.findElement(By.id("video")).getTagName()) 61 | .isEqualTo("video"); 62 | } 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /src/test/java/io/github/bonigarcia/seljup/test/capabilities/OperaBinaryTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2017 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup.test.capabilities; 18 | 19 | import static io.github.bonigarcia.seljup.Browser.OPERA; 20 | import static org.assertj.core.api.Assertions.assertThat; 21 | 22 | import org.junit.jupiter.api.Test; 23 | import org.junit.jupiter.api.extension.ExtendWith; 24 | import org.openqa.selenium.chrome.ChromeDriver; 25 | 26 | import io.github.bonigarcia.seljup.Binary; 27 | import io.github.bonigarcia.seljup.EnabledIfBrowserAvailable; 28 | import io.github.bonigarcia.seljup.Opera; 29 | import io.github.bonigarcia.seljup.SeleniumJupiter; 30 | 31 | @EnabledIfBrowserAvailable(OPERA) 32 | @ExtendWith(SeleniumJupiter.class) 33 | class OperaBinaryTest { 34 | 35 | @Test 36 | void operaExtensionTest( 37 | @Binary("/usr/bin/opera") @Opera ChromeDriver driver) { 38 | driver.get("https://bonigarcia.dev/selenium-webdriver-java/"); 39 | assertThat(driver.getTitle()).contains("Selenium WebDriver"); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/test/java/io/github/bonigarcia/seljup/test/capabilities/OperaGlobalOptionsTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2017 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup.test.capabilities; 18 | 19 | import static org.assertj.core.api.Assertions.assertThat; 20 | 21 | import org.junit.jupiter.api.Disabled; 22 | import org.junit.jupiter.api.Test; 23 | import org.junit.jupiter.api.extension.ExtendWith; 24 | import org.openqa.selenium.chrome.ChromeDriver; 25 | import org.openqa.selenium.chrome.ChromeOptions; 26 | 27 | import io.github.bonigarcia.seljup.Opera; 28 | import io.github.bonigarcia.seljup.Options; 29 | import io.github.bonigarcia.seljup.SeleniumJupiter; 30 | 31 | @Disabled("Redudant test for CI suite") 32 | @ExtendWith(SeleniumJupiter.class) 33 | class OperaGlobalOptionsTest { 34 | 35 | @Options 36 | ChromeOptions operaOptions = new ChromeOptions(); 37 | { 38 | operaOptions.setBinary("/usr/bin/opera"); 39 | } 40 | 41 | @Test 42 | void operaTest(@Opera ChromeDriver driver) { 43 | driver.get("https://bonigarcia.dev/selenium-webdriver-java/"); 44 | assertThat(driver.getTitle()).contains("Selenium WebDriver"); 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /src/test/java/io/github/bonigarcia/seljup/test/capabilities/OperaOptionsTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2017 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup.test.capabilities; 18 | 19 | import static io.github.bonigarcia.seljup.Browser.OPERA; 20 | import static org.assertj.core.api.Assertions.assertThat; 21 | 22 | import org.junit.jupiter.api.Test; 23 | import org.junit.jupiter.api.extension.ExtendWith; 24 | import org.openqa.selenium.chrome.ChromeDriver; 25 | 26 | import io.github.bonigarcia.seljup.Arguments; 27 | import io.github.bonigarcia.seljup.Binary; 28 | import io.github.bonigarcia.seljup.EnabledIfBrowserAvailable; 29 | import io.github.bonigarcia.seljup.Opera; 30 | import io.github.bonigarcia.seljup.SeleniumJupiter; 31 | 32 | @EnabledIfBrowserAvailable(OPERA) 33 | @ExtendWith(SeleniumJupiter.class) 34 | class OperaOptionsTest { 35 | 36 | @Test 37 | void operaTest( 38 | @Binary("/usr/bin/opera") @Arguments("private") @Opera ChromeDriver driver) { 39 | driver.get("https://bonigarcia.dev/selenium-webdriver-java/"); 40 | assertThat(driver.getTitle()).contains("Selenium WebDriver"); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/test/java/io/github/bonigarcia/seljup/test/capabilities/SafariGlobalOptionsTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2017 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup.test.capabilities; 18 | 19 | import static io.github.bonigarcia.seljup.Browser.SAFARI; 20 | import static org.assertj.core.api.Assertions.assertThat; 21 | 22 | import org.junit.jupiter.api.Test; 23 | import org.junit.jupiter.api.extension.ExtendWith; 24 | import org.openqa.selenium.safari.SafariDriver; 25 | import org.openqa.selenium.safari.SafariOptions; 26 | 27 | import io.github.bonigarcia.seljup.EnabledIfBrowserAvailable; 28 | import io.github.bonigarcia.seljup.Options; 29 | import io.github.bonigarcia.seljup.SeleniumJupiter; 30 | 31 | @EnabledIfBrowserAvailable(SAFARI) 32 | @ExtendWith(SeleniumJupiter.class) 33 | class SafariGlobalOptionsTest { 34 | 35 | @Options 36 | SafariOptions safariOptions = new SafariOptions(); 37 | { 38 | safariOptions.setUseTechnologyPreview(false); 39 | } 40 | 41 | @Test 42 | void safariTest(SafariDriver driver) { 43 | driver.get("https://bonigarcia.dev/selenium-webdriver-java/"); 44 | assertThat(driver.getTitle()).contains("Selenium WebDriver"); 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /src/test/java/io/github/bonigarcia/seljup/test/docker/DockerChromeBetaTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2017 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup.test.docker; 18 | 19 | //tag::snippet-in-doc[] 20 | import static io.github.bonigarcia.seljup.BrowserType.CHROME; 21 | import static org.assertj.core.api.Assertions.assertThat; 22 | 23 | import org.junit.jupiter.api.Test; 24 | import org.junit.jupiter.api.extension.ExtendWith; 25 | import org.openqa.selenium.WebDriver; 26 | 27 | import io.github.bonigarcia.seljup.DockerBrowser; 28 | import io.github.bonigarcia.seljup.EnabledIfDockerAvailable; 29 | import io.github.bonigarcia.seljup.SeleniumJupiter; 30 | 31 | @EnabledIfDockerAvailable 32 | @ExtendWith(SeleniumJupiter.class) 33 | class DockerChromeBetaTest { 34 | 35 | @Test 36 | void test( 37 | @DockerBrowser(type = CHROME, version = "beta") WebDriver driver) { 38 | driver.get("https://bonigarcia.dev/selenium-webdriver-java/"); 39 | assertThat(driver.getTitle()).contains("Selenium WebDriver"); 40 | } 41 | 42 | } 43 | //end::snippet-in-doc[] -------------------------------------------------------------------------------- /src/test/java/io/github/bonigarcia/seljup/test/docker/DockerChromeLatestMinusOneTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2021 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup.test.docker; 18 | 19 | import static io.github.bonigarcia.seljup.BrowserType.CHROME; 20 | import static org.assertj.core.api.Assertions.assertThat; 21 | 22 | import org.junit.jupiter.api.Test; 23 | import org.junit.jupiter.api.extension.ExtendWith; 24 | import org.openqa.selenium.WebDriver; 25 | 26 | import io.github.bonigarcia.seljup.DockerBrowser; 27 | import io.github.bonigarcia.seljup.SeleniumJupiter; 28 | 29 | @ExtendWith(SeleniumJupiter.class) 30 | class DockerChromeLatestMinusOneTest { 31 | 32 | @Test 33 | void test( 34 | @DockerBrowser(type = CHROME, version = "latest-1") WebDriver driver) { 35 | driver.get("https://bonigarcia.dev/selenium-webdriver-java/"); 36 | assertThat(driver.getTitle()).contains("Selenium WebDriver"); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/test/java/io/github/bonigarcia/seljup/test/docker/DockerChromeRecordingConfigTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2017 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup.test.docker; 18 | 19 | import static io.github.bonigarcia.seljup.BrowserType.CHROME; 20 | import static java.lang.invoke.MethodHandles.lookup; 21 | import static org.assertj.core.api.Assertions.assertThat; 22 | import static org.slf4j.LoggerFactory.getLogger; 23 | 24 | import java.io.File; 25 | import java.time.Duration; 26 | import java.util.Arrays; 27 | import java.util.Optional; 28 | 29 | import org.junit.jupiter.api.AfterAll; 30 | import org.junit.jupiter.api.BeforeAll; 31 | import org.junit.jupiter.api.Test; 32 | import org.junit.jupiter.api.extension.RegisterExtension; 33 | import org.openqa.selenium.remote.RemoteWebDriver; 34 | import org.openqa.selenium.remote.SessionId; 35 | import org.slf4j.Logger; 36 | 37 | import io.github.bonigarcia.seljup.DockerBrowser; 38 | import io.github.bonigarcia.seljup.SeleniumJupiter; 39 | 40 | class DockerChromeRecordingConfigTest { 41 | 42 | static final Logger log = getLogger(lookup().lookupClass()); 43 | 44 | @RegisterExtension 45 | static SeleniumJupiter seleniumJupiter = new SeleniumJupiter(); 46 | 47 | static SessionId sessionId; 48 | 49 | @BeforeAll 50 | static void setup() { 51 | seleniumJupiter.getConfig().enableRecording(); 52 | seleniumJupiter.getConfig().enableVnc(); 53 | } 54 | 55 | @AfterAll 56 | static void teardown() { 57 | File[] files = new File(".").listFiles(); 58 | Optional recording = Arrays.stream(files).filter( 59 | f -> f.getName().endsWith(sessionId.toString() + ".mp4")) 60 | .findFirst(); 61 | assertThat(recording).isNotEmpty(); 62 | recording.get().delete(); 63 | } 64 | 65 | @Test 66 | void recordingTest(@DockerBrowser(type = CHROME) RemoteWebDriver driver) 67 | throws InterruptedException { 68 | driver.get("https://bonigarcia.dev/selenium-webdriver-java/"); 69 | assertThat(driver.getTitle()).contains("Selenium WebDriver"); 70 | 71 | Thread.sleep(Duration.ofSeconds(3).toMillis()); 72 | 73 | sessionId = driver.getSessionId(); 74 | 75 | log.debug("noVNC URL (default): {}", 76 | seleniumJupiter.getDockerNoVncUrl()); 77 | log.debug("noVNC URL (for driver): {}", 78 | seleniumJupiter.getDockerNoVncUrl(driver)); 79 | } 80 | 81 | } 82 | -------------------------------------------------------------------------------- /src/test/java/io/github/bonigarcia/seljup/test/docker/DockerChromeRecordingFailureTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2017 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup.test.docker; 18 | 19 | import static io.github.bonigarcia.seljup.BrowserType.CHROME; 20 | import static java.lang.invoke.MethodHandles.lookup; 21 | import static org.assertj.core.api.Assertions.assertThat; 22 | import static org.slf4j.LoggerFactory.getLogger; 23 | 24 | import java.io.File; 25 | import java.time.Duration; 26 | import java.util.Arrays; 27 | import java.util.Optional; 28 | 29 | import org.junit.jupiter.api.AfterAll; 30 | import org.junit.jupiter.api.BeforeAll; 31 | import org.junit.jupiter.api.Test; 32 | import org.junit.jupiter.api.extension.RegisterExtension; 33 | import org.openqa.selenium.remote.RemoteWebDriver; 34 | import org.openqa.selenium.remote.SessionId; 35 | import org.slf4j.Logger; 36 | 37 | import io.github.bonigarcia.seljup.DockerBrowser; 38 | import io.github.bonigarcia.seljup.SeleniumJupiter; 39 | 40 | class DockerChromeRecordingFailureTest { 41 | 42 | @RegisterExtension 43 | static SeleniumJupiter seleniumJupiter = new SeleniumJupiter(); 44 | 45 | final Logger log = getLogger(lookup().lookupClass()); 46 | 47 | static SessionId sessionId; 48 | 49 | @BeforeAll 50 | static void setup() { 51 | seleniumJupiter.getConfig().enableRecordingWhenFailure(); 52 | } 53 | 54 | @AfterAll 55 | static void teardown() { 56 | File[] files = new File(".").listFiles(); 57 | Optional recording = Arrays.stream(files).filter( 58 | f -> f.getName().endsWith(sessionId.toString() + ".mp4")) 59 | .findFirst(); 60 | assertThat(recording).isEmpty(); 61 | } 62 | 63 | @Test 64 | void recordingTest(@DockerBrowser(type = CHROME) RemoteWebDriver driver) 65 | throws InterruptedException { 66 | driver.get("https://bonigarcia.dev/selenium-webdriver-java/"); 67 | assertThat(driver.getTitle()).contains("Selenium WebDriver"); 68 | 69 | Thread.sleep(Duration.ofSeconds(3).toMillis()); 70 | 71 | sessionId = driver.getSessionId(); 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /src/test/java/io/github/bonigarcia/seljup/test/docker/DockerChromeRecordingTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2017 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup.test.docker; 18 | 19 | //tag::snippet-in-doc[] 20 | import static io.github.bonigarcia.seljup.BrowserType.CHROME; 21 | import static org.assertj.core.api.Assertions.assertThat; 22 | 23 | import java.io.File; 24 | import java.time.Duration; 25 | import java.util.Arrays; 26 | import java.util.Optional; 27 | 28 | import org.junit.jupiter.api.AfterAll; 29 | import org.junit.jupiter.api.Test; 30 | import org.junit.jupiter.api.extension.ExtendWith; 31 | import org.openqa.selenium.remote.RemoteWebDriver; 32 | import org.openqa.selenium.remote.SessionId; 33 | 34 | import io.github.bonigarcia.seljup.DockerBrowser; 35 | import io.github.bonigarcia.seljup.SeleniumJupiter; 36 | 37 | @ExtendWith(SeleniumJupiter.class) 38 | class DockerChromeRecordingTest { 39 | 40 | static SessionId sessionId; 41 | 42 | @AfterAll 43 | static void teardown() { 44 | File[] files = new File(".").listFiles(); 45 | Optional recording = Arrays.stream(files).filter( 46 | f -> f.getName().endsWith(sessionId.toString() + ".mp4")) 47 | .findFirst(); 48 | assertThat(recording).isNotEmpty(); 49 | recording.get().delete(); 50 | } 51 | 52 | @Test 53 | void recordingTest( 54 | @DockerBrowser(type = CHROME, recording = true) RemoteWebDriver driver) 55 | throws InterruptedException { 56 | driver.get("https://bonigarcia.dev/selenium-webdriver-java/"); 57 | assertThat(driver.getTitle()).contains("Selenium WebDriver"); 58 | 59 | Thread.sleep(Duration.ofSeconds(3).toMillis()); 60 | 61 | sessionId = driver.getSessionId(); 62 | } 63 | 64 | } 65 | //end::snippet-in-doc[] 66 | -------------------------------------------------------------------------------- /src/test/java/io/github/bonigarcia/seljup/test/docker/DockerChromeTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2017 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup.test.docker; 18 | 19 | //tag::snippet-in-doc[] 20 | import static io.github.bonigarcia.seljup.BrowserType.CHROME; 21 | import static org.assertj.core.api.Assertions.assertThat; 22 | 23 | import org.junit.jupiter.api.Test; 24 | import org.junit.jupiter.api.extension.ExtendWith; 25 | import org.openqa.selenium.WebDriver; 26 | 27 | import io.github.bonigarcia.seljup.DockerBrowser; 28 | import io.github.bonigarcia.seljup.SeleniumJupiter; 29 | 30 | @ExtendWith(SeleniumJupiter.class) 31 | class DockerChromeTest { 32 | 33 | @Test 34 | void testChrome(@DockerBrowser(type = CHROME) WebDriver driver) { 35 | driver.get("https://bonigarcia.dev/selenium-webdriver-java/"); 36 | assertThat(driver.getTitle()).contains("Selenium WebDriver"); 37 | } 38 | 39 | } 40 | //end::snippet-in-doc[] 41 | -------------------------------------------------------------------------------- /src/test/java/io/github/bonigarcia/seljup/test/docker/DockerChromeVncTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2018 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup.test.docker; 18 | 19 | //tag::snippet-in-doc[] 20 | import static io.github.bonigarcia.seljup.BrowserType.CHROME; 21 | import static org.assertj.core.api.Assertions.assertThat; 22 | 23 | import org.junit.jupiter.api.Test; 24 | import org.junit.jupiter.api.extension.ExtendWith; 25 | import org.openqa.selenium.WebDriver; 26 | 27 | import io.github.bonigarcia.seljup.DockerBrowser; 28 | import io.github.bonigarcia.seljup.SeleniumJupiter; 29 | 30 | @ExtendWith(SeleniumJupiter.class) 31 | class DockerChromeVncTest { 32 | 33 | @Test 34 | void test( 35 | @DockerBrowser(type = CHROME, vnc = true, lang = "ES", timezone = "Europe/Madrid") WebDriver driver) 36 | throws Exception { 37 | driver.get("https://bonigarcia.dev/selenium-webdriver-java/"); 38 | assertThat(driver.getTitle()).contains("Selenium WebDriver"); 39 | 40 | // Uncomment this line to have time for manual inspection 41 | // Thread.sleep(30000); 42 | } 43 | 44 | } 45 | //end::snippet-in-doc[] -------------------------------------------------------------------------------- /src/test/java/io/github/bonigarcia/seljup/test/docker/DockerChromeWebRtcTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2017 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup.test.docker; 18 | 19 | import static io.github.bonigarcia.seljup.BrowserType.CHROME; 20 | import static org.assertj.core.api.Assertions.assertThat; 21 | 22 | import java.time.Duration; 23 | 24 | import org.junit.jupiter.api.Test; 25 | import org.junit.jupiter.api.extension.ExtendWith; 26 | import org.openqa.selenium.By; 27 | import org.openqa.selenium.WebDriver; 28 | 29 | import io.github.bonigarcia.seljup.Arguments; 30 | import io.github.bonigarcia.seljup.DockerBrowser; 31 | import io.github.bonigarcia.seljup.SeleniumJupiter; 32 | 33 | @ExtendWith(SeleniumJupiter.class) 34 | class DockerChromeWebRtcTest { 35 | 36 | @Test 37 | void webrtcTest( 38 | @DockerBrowser(type = CHROME, vnc = true) @Arguments({ 39 | "--use-fake-device-for-media-stream", 40 | "--use-fake-ui-for-media-stream" }) WebDriver driver) 41 | throws InterruptedException { 42 | driver.get( 43 | "https://webrtc.github.io/samples/src/content/devices/input-output/"); 44 | assertThat(driver.findElement(By.id("video")).getTagName()) 45 | .isEqualTo("video"); 46 | 47 | Thread.sleep(Duration.ofSeconds(5).toMillis()); 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /src/test/java/io/github/bonigarcia/seljup/test/docker/DockerChromeWithArgumentsTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2017 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup.test.docker; 18 | 19 | import static io.github.bonigarcia.seljup.BrowserType.CHROME; 20 | import static org.assertj.core.api.Assertions.assertThat; 21 | 22 | import org.junit.jupiter.api.Test; 23 | import org.junit.jupiter.api.extension.ExtendWith; 24 | import org.openqa.selenium.By; 25 | import org.openqa.selenium.WebDriver; 26 | 27 | import io.github.bonigarcia.seljup.Arguments; 28 | import io.github.bonigarcia.seljup.DockerBrowser; 29 | import io.github.bonigarcia.seljup.SeleniumJupiter; 30 | 31 | @ExtendWith(SeleniumJupiter.class) 32 | class DockerChromeWithArgumentsTest { 33 | 34 | @Test 35 | void webrtcTest(@Arguments({ "--use-fake-device-for-media-stream", 36 | "--use-fake-ui-for-media-stream" }) @DockerBrowser(type = CHROME, version = "91", recording = true) WebDriver driver) 37 | throws InterruptedException { 38 | driver.get( 39 | "https://webrtc.github.io/samples/src/content/devices/input-output/"); 40 | assertThat(driver.findElement(By.id("video")).getTagName()) 41 | .isEqualTo("video"); 42 | 43 | Thread.sleep(5000); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/test/java/io/github/bonigarcia/seljup/test/docker/DockerChromeWithOptionsTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2017 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup.test.docker; 18 | 19 | import static io.github.bonigarcia.seljup.BrowserType.CHROME; 20 | import static org.assertj.core.api.Assertions.assertThat; 21 | 22 | import org.junit.jupiter.api.Test; 23 | import org.junit.jupiter.api.extension.ExtendWith; 24 | import org.openqa.selenium.By; 25 | import org.openqa.selenium.WebDriver; 26 | import org.openqa.selenium.chrome.ChromeOptions; 27 | 28 | import io.github.bonigarcia.seljup.DockerBrowser; 29 | import io.github.bonigarcia.seljup.Options; 30 | import io.github.bonigarcia.seljup.SeleniumJupiter; 31 | 32 | @ExtendWith(SeleniumJupiter.class) 33 | class DockerChromeWithOptionsTest { 34 | 35 | @Options 36 | ChromeOptions chromeOptions = new ChromeOptions(); 37 | { 38 | chromeOptions.addArguments("--use-fake-device-for-media-stream", 39 | "--use-fake-ui-for-media-stream"); 40 | } 41 | 42 | @Test 43 | void webrtcTest( 44 | @DockerBrowser(type = CHROME, recording = true) WebDriver driver) 45 | throws InterruptedException { 46 | driver.get( 47 | "https://webrtc.github.io/samples/src/content/devices/input-output/"); 48 | assertThat(driver.findElement(By.id("video")).getTagName()) 49 | .isEqualTo("video"); 50 | 51 | Thread.sleep(2000); 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /src/test/java/io/github/bonigarcia/seljup/test/docker/DockerChromiumTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2025 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup.test.docker; 18 | 19 | //tag::snippet-in-doc[] 20 | import static io.github.bonigarcia.seljup.BrowserType.CHROMIUM; 21 | import static org.assertj.core.api.Assertions.assertThat; 22 | 23 | import org.junit.jupiter.api.Test; 24 | import org.junit.jupiter.api.extension.ExtendWith; 25 | import org.openqa.selenium.WebDriver; 26 | 27 | import io.github.bonigarcia.seljup.DockerBrowser; 28 | import io.github.bonigarcia.seljup.SeleniumJupiter; 29 | 30 | @ExtendWith(SeleniumJupiter.class) 31 | class DockerChromiumTest { 32 | 33 | @Test 34 | void testChrome(@DockerBrowser(type = CHROMIUM) WebDriver driver) { 35 | driver.get("https://bonigarcia.dev/selenium-webdriver-java/"); 36 | assertThat(driver.getTitle()).contains("Selenium WebDriver"); 37 | } 38 | 39 | } 40 | //end::snippet-in-doc[] 41 | -------------------------------------------------------------------------------- /src/test/java/io/github/bonigarcia/seljup/test/docker/DockerCustomWdmTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2021 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup.test.docker; 18 | 19 | import static org.assertj.core.api.Assertions.assertThat; 20 | 21 | import org.junit.jupiter.api.BeforeAll; 22 | import org.junit.jupiter.api.Test; 23 | import org.junit.jupiter.api.extension.RegisterExtension; 24 | import org.openqa.selenium.WebDriver; 25 | 26 | import io.github.bonigarcia.seljup.SeleniumJupiter; 27 | import io.github.bonigarcia.wdm.WebDriverManager; 28 | 29 | class DockerCustomWdmTest { 30 | 31 | @RegisterExtension 32 | static SeleniumJupiter seleniumJupiter = new SeleniumJupiter(); 33 | 34 | @BeforeAll 35 | static void setup() { 36 | WebDriverManager wdm = WebDriverManager.chromedriver().browserInDocker() 37 | .dockerCustomImage("selenoid/vnc:chrome_91.0"); 38 | seleniumJupiter.getConfig().setManager(wdm); 39 | } 40 | 41 | @Test 42 | void customWdmTest(WebDriver driver) { 43 | String sut = "https://bonigarcia.dev/selenium-webdriver-java/"; 44 | String title = "Selenium WebDriver"; 45 | 46 | driver.get(sut); 47 | assertThat(driver.getTitle()).contains(title); 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /src/test/java/io/github/bonigarcia/seljup/test/docker/DockerEdgeTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2019 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup.test.docker; 18 | 19 | import static io.github.bonigarcia.seljup.BrowserType.EDGE; 20 | import static org.assertj.core.api.Assertions.assertThat; 21 | 22 | import org.junit.jupiter.api.Test; 23 | import org.junit.jupiter.api.extension.ExtendWith; 24 | import org.openqa.selenium.WebDriver; 25 | 26 | import io.github.bonigarcia.seljup.DockerBrowser; 27 | import io.github.bonigarcia.seljup.SeleniumJupiter; 28 | 29 | @ExtendWith(SeleniumJupiter.class) 30 | class DockerEdgeTest { 31 | 32 | @Test 33 | void testEdge(@DockerBrowser(type = EDGE) WebDriver driver) { 34 | driver.get("https://bonigarcia.dev/selenium-webdriver-java/"); 35 | assertThat(driver.getTitle()).contains("Selenium WebDriver"); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/test/java/io/github/bonigarcia/seljup/test/docker/DockerFirefoxDevTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2021 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup.test.docker; 18 | 19 | import static io.github.bonigarcia.seljup.BrowserType.FIREFOX; 20 | import static org.assertj.core.api.Assertions.assertThat; 21 | 22 | import org.junit.jupiter.api.Test; 23 | import org.junit.jupiter.api.extension.ExtendWith; 24 | import org.openqa.selenium.WebDriver; 25 | 26 | import io.github.bonigarcia.seljup.DockerBrowser; 27 | import io.github.bonigarcia.seljup.SeleniumJupiter; 28 | 29 | @ExtendWith(SeleniumJupiter.class) 30 | class DockerFirefoxDevTest { 31 | 32 | @Test 33 | void test( 34 | @DockerBrowser(type = FIREFOX, version = "dev") WebDriver driver) { 35 | driver.get("https://bonigarcia.dev/selenium-webdriver-java/"); 36 | assertThat(driver.getTitle()).contains("Selenium WebDriver"); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/test/java/io/github/bonigarcia/seljup/test/docker/DockerFirefoxTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2021 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup.test.docker; 18 | 19 | import static io.github.bonigarcia.seljup.BrowserType.FIREFOX; 20 | import static org.assertj.core.api.Assertions.assertThat; 21 | 22 | import org.junit.jupiter.api.Test; 23 | import org.junit.jupiter.api.extension.ExtendWith; 24 | import org.openqa.selenium.WebDriver; 25 | 26 | import io.github.bonigarcia.seljup.DockerBrowser; 27 | import io.github.bonigarcia.seljup.SeleniumJupiter; 28 | 29 | @ExtendWith(SeleniumJupiter.class) 30 | class DockerFirefoxTest { 31 | 32 | @Test 33 | void testFirefox(@DockerBrowser(type = FIREFOX) WebDriver driver) { 34 | driver.get("https://bonigarcia.dev/selenium-webdriver-java/"); 35 | assertThat(driver.getTitle()).contains("Selenium WebDriver"); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/test/java/io/github/bonigarcia/seljup/test/docker/DockerFirefoxWithOptionsTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2017 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup.test.docker; 18 | 19 | import static io.github.bonigarcia.seljup.BrowserType.FIREFOX; 20 | import static org.assertj.core.api.Assertions.assertThat; 21 | 22 | import org.junit.jupiter.api.Test; 23 | import org.junit.jupiter.api.extension.ExtendWith; 24 | import org.openqa.selenium.By; 25 | import org.openqa.selenium.WebDriver; 26 | 27 | import io.github.bonigarcia.seljup.DockerBrowser; 28 | import io.github.bonigarcia.seljup.Preferences; 29 | import io.github.bonigarcia.seljup.SeleniumJupiter; 30 | 31 | @ExtendWith(SeleniumJupiter.class) 32 | class DockerFirefoxWithOptionsTest { 33 | 34 | @Test 35 | void webrtcTest(@Preferences({ "media.navigator.permission.disabled=true", 36 | "media.navigator.streams.fake=true" }) @DockerBrowser(type = FIREFOX) WebDriver driver) { 37 | driver.get( 38 | "https://webrtc.github.io/samples/src/content/devices/input-output/"); 39 | assertThat(driver.findElement(By.id("video")).getTagName()) 40 | .isEqualTo("video"); 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /src/test/java/io/github/bonigarcia/seljup/test/docker/DockerListInConstructorTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2018 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup.test.docker; 18 | 19 | import static io.github.bonigarcia.seljup.BrowserType.CHROME; 20 | import static org.assertj.core.api.Assertions.assertThat; 21 | 22 | import java.util.List; 23 | 24 | import org.junit.jupiter.api.Test; 25 | import org.junit.jupiter.api.extension.ExtendWith; 26 | import org.openqa.selenium.WebDriver; 27 | 28 | import io.github.bonigarcia.seljup.DockerBrowser; 29 | import io.github.bonigarcia.seljup.SeleniumJupiter; 30 | 31 | @ExtendWith(SeleniumJupiter.class) 32 | class DockerListInConstructorTest { 33 | 34 | static final int NUM_BROWSERS = 1; 35 | 36 | List driverList1; 37 | 38 | DockerListInConstructorTest( 39 | @DockerBrowser(type = CHROME, size = NUM_BROWSERS) List driverList1) { 40 | this.driverList1 = driverList1; 41 | } 42 | 43 | @Test 44 | void test() { 45 | driverList1.forEach(this::exercise); 46 | } 47 | 48 | private void exercise(WebDriver driver) { 49 | driver.get("https://bonigarcia.dev/selenium-webdriver-java/"); 50 | assertThat(driver.getTitle()) 51 | .contains("Selenium WebDriver"); 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /src/test/java/io/github/bonigarcia/seljup/test/docker/DockerListTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2017 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup.test.docker; 18 | 19 | //tag::snippet-in-doc[] 20 | import static io.github.bonigarcia.seljup.BrowserType.CHROME; 21 | import static java.lang.invoke.MethodHandles.lookup; 22 | import static java.util.concurrent.Executors.newFixedThreadPool; 23 | import static java.util.concurrent.TimeUnit.SECONDS; 24 | import static org.assertj.core.api.Assertions.assertThat; 25 | import static org.slf4j.LoggerFactory.getLogger; 26 | 27 | import java.util.List; 28 | import java.util.concurrent.CountDownLatch; 29 | import java.util.concurrent.ExecutorService; 30 | 31 | import org.junit.jupiter.api.Test; 32 | import org.junit.jupiter.api.extension.ExtendWith; 33 | import org.openqa.selenium.remote.RemoteWebDriver; 34 | import org.slf4j.Logger; 35 | 36 | import io.github.bonigarcia.seljup.DockerBrowser; 37 | import io.github.bonigarcia.seljup.SeleniumJupiter; 38 | 39 | @ExtendWith(SeleniumJupiter.class) 40 | class DockerListTest { 41 | 42 | static final int NUM_BROWSERS = 2; 43 | 44 | final Logger log = getLogger(lookup().lookupClass()); 45 | 46 | @Test 47 | void testPerformance( 48 | @DockerBrowser(type = CHROME, size = NUM_BROWSERS) List driverList) 49 | throws InterruptedException { 50 | 51 | ExecutorService executorService = newFixedThreadPool(NUM_BROWSERS); 52 | CountDownLatch latch = new CountDownLatch(NUM_BROWSERS); 53 | 54 | driverList.forEach((driver) -> { 55 | executorService.submit(() -> { 56 | try { 57 | log.info("Session id {}", driver.getSessionId()); 58 | driver.get("https://bonigarcia.dev/selenium-webdriver-java/"); 59 | assertThat(driver.getTitle()).contains("Selenium WebDriver"); 60 | } finally { 61 | latch.countDown(); 62 | } 63 | }); 64 | }); 65 | 66 | latch.await(50, SECONDS); 67 | executorService.shutdown(); 68 | } 69 | 70 | } 71 | //end::snippet-in-doc[] 72 | -------------------------------------------------------------------------------- /src/test/java/io/github/bonigarcia/seljup/test/docker/DockerMixedListInConstructorTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2018 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup.test.docker; 18 | 19 | import static io.github.bonigarcia.seljup.BrowserType.CHROME; 20 | 21 | import java.time.Duration; 22 | import java.util.List; 23 | 24 | import org.junit.jupiter.api.BeforeAll; 25 | import org.junit.jupiter.api.Test; 26 | import org.junit.jupiter.api.extension.RegisterExtension; 27 | import org.openqa.selenium.WebDriver; 28 | import org.openqa.selenium.remote.RemoteWebDriver; 29 | import org.openqa.selenium.support.ui.Wait; 30 | import org.openqa.selenium.support.ui.WebDriverWait; 31 | 32 | import io.github.bonigarcia.seljup.DockerBrowser; 33 | import io.github.bonigarcia.seljup.SeleniumJupiter; 34 | 35 | class DockerMixedListInConstructorTest { 36 | 37 | @RegisterExtension 38 | static SeleniumJupiter seleniumJupiter = new SeleniumJupiter(); 39 | 40 | static final int NUM_BROWSERS = 1; 41 | 42 | WebDriver driver1; 43 | List driverList1; 44 | 45 | @BeforeAll 46 | static void setup() { 47 | seleniumJupiter.getConfig().enableScreenshotWhenFailure(); 48 | seleniumJupiter.getConfig().takeScreenshotAsBase64(); 49 | } 50 | 51 | DockerMixedListInConstructorTest(RemoteWebDriver driver1, 52 | @DockerBrowser(type = CHROME, size = NUM_BROWSERS) List driverList1) { 53 | this.driver1 = driver1; 54 | this.driverList1 = driverList1; 55 | } 56 | 57 | @Test 58 | void testGlobalChrome(WebDriver driver2, 59 | @DockerBrowser(type = CHROME, size = NUM_BROWSERS) List driverList2) { 60 | exercise(driver1); 61 | driverList1.forEach(this::exercise); 62 | exercise(driver2); 63 | driverList2.forEach(this::exercise); 64 | } 65 | 66 | private void exercise(WebDriver driver) { 67 | driver.get("https://bonigarcia.dev/selenium-webdriver-java/"); 68 | driver.navigate().refresh(); 69 | 70 | Wait wait = new WebDriverWait(driver, 71 | Duration.ofSeconds(30)); 72 | wait.until(d -> d.getTitle().contains("Selenium WebDriver")); 73 | } 74 | 75 | } 76 | -------------------------------------------------------------------------------- /src/test/java/io/github/bonigarcia/seljup/test/docker/DockerMixedTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2018 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup.test.docker; 18 | 19 | import static io.github.bonigarcia.seljup.BrowserType.CHROME; 20 | import static io.github.bonigarcia.seljup.BrowserType.FIREFOX; 21 | import static org.assertj.core.api.Assertions.assertThat; 22 | 23 | import org.junit.jupiter.api.Test; 24 | import org.junit.jupiter.api.extension.RegisterExtension; 25 | import org.openqa.selenium.WebDriver; 26 | 27 | import io.github.bonigarcia.seljup.DockerBrowser; 28 | import io.github.bonigarcia.seljup.SeleniumJupiter; 29 | 30 | class DockerMixedTest { 31 | 32 | @RegisterExtension 33 | static SeleniumJupiter seleniumJupiter = new SeleniumJupiter(); 34 | 35 | @Test 36 | void testHtmlVnc(@DockerBrowser(type = CHROME) WebDriver driver1, 37 | @DockerBrowser(type = FIREFOX) WebDriver driver2) { 38 | driver1.get("https://bonigarcia.dev/selenium-webdriver-java/"); 39 | driver2.get("https://bonigarcia.dev/selenium-webdriver-java/"); 40 | 41 | assertThat(driver1.getTitle()).contains("Selenium WebDriver"); 42 | assertThat(driver2.getTitle()).contains("Selenium WebDriver"); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/test/java/io/github/bonigarcia/seljup/test/forced/ForcedEmptyConfigTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2018 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup.test.forced; 18 | 19 | import static org.assertj.core.api.Assertions.assertThat; 20 | 21 | import java.lang.reflect.Method; 22 | 23 | import org.junit.jupiter.api.BeforeAll; 24 | import org.junit.jupiter.api.Test; 25 | import org.junit.jupiter.api.extension.RegisterExtension; 26 | import org.openqa.selenium.WebDriver; 27 | 28 | import io.github.bonigarcia.seljup.SeleniumJupiter; 29 | import io.github.bonigarcia.seljup.config.Config; 30 | 31 | class ForcedEmptyConfigTest { 32 | 33 | @RegisterExtension 34 | static SeleniumJupiter seleniumJupiter = new SeleniumJupiter(); 35 | 36 | @BeforeAll 37 | static void setup() throws Exception { 38 | Config config = seleniumJupiter.getConfig(); 39 | for (Method method : config.getClass().getMethods()) { 40 | if (method.getName().startsWith("set")) { 41 | if (method.getParameterTypes()[0].equals(String.class)) { 42 | method.invoke(config, ""); 43 | } else if (method.getParameterTypes()[0] 44 | .equals(Boolean.class)) { 45 | method.invoke(config, false); 46 | } else if (method.getParameterTypes()[0] 47 | .equals(Integer.class)) { 48 | method.invoke(config, 0); 49 | } 50 | } 51 | } 52 | } 53 | 54 | @Test 55 | void test(WebDriver driver) { 56 | assertThat(driver).isNotNull(); 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /src/test/java/io/github/bonigarcia/seljup/test/generic/GenericInConstructorTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2018 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup.test.generic; 18 | 19 | import static org.assertj.core.api.Assertions.assertThat; 20 | 21 | import org.junit.jupiter.api.Test; 22 | import org.junit.jupiter.api.extension.ExtendWith; 23 | import org.openqa.selenium.WebDriver; 24 | 25 | import io.github.bonigarcia.seljup.SeleniumJupiter; 26 | 27 | @ExtendWith(SeleniumJupiter.class) 28 | class GenericInConstructorTest { 29 | 30 | WebDriver driver; 31 | 32 | GenericInConstructorTest(WebDriver driver) { 33 | this.driver = driver; 34 | } 35 | 36 | @Test 37 | void test() { 38 | driver.get("https://bonigarcia.dev/selenium-webdriver-java/"); 39 | assertThat(driver.getTitle()).contains("Selenium WebDriver"); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/test/java/io/github/bonigarcia/seljup/test/generic/GenericMixedTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2018 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup.test.generic; 18 | 19 | import java.time.Duration; 20 | 21 | import org.junit.jupiter.api.AfterEach; 22 | import org.junit.jupiter.api.BeforeAll; 23 | import org.junit.jupiter.api.BeforeEach; 24 | import org.junit.jupiter.api.Test; 25 | import org.junit.jupiter.api.extension.RegisterExtension; 26 | import org.openqa.selenium.WebDriver; 27 | import org.openqa.selenium.chrome.ChromeDriver; 28 | import org.openqa.selenium.remote.RemoteWebDriver; 29 | import org.openqa.selenium.support.ui.Wait; 30 | import org.openqa.selenium.support.ui.WebDriverWait; 31 | 32 | import io.github.bonigarcia.seljup.SeleniumJupiter; 33 | 34 | class GenericMixedTest { 35 | 36 | @RegisterExtension 37 | static SeleniumJupiter seleniumJupiter = new SeleniumJupiter(); 38 | 39 | @BeforeAll 40 | static void setupClass() { 41 | seleniumJupiter.getConfig().enableScreenshotWhenFailure(); 42 | seleniumJupiter.getConfig().takeScreenshotAsBase64(); 43 | } 44 | 45 | @BeforeEach 46 | void setup() { 47 | System.setProperty("wdm.defaultBrowser", "chrome-in-docker"); 48 | } 49 | 50 | @AfterEach 51 | void teardown() { 52 | System.clearProperty("wdm.defaultBrowser"); 53 | } 54 | 55 | @Test 56 | void genericMixedTest(ChromeDriver local, RemoteWebDriver remote) { 57 | exercise(local); 58 | exercise(remote); 59 | } 60 | 61 | private void exercise(WebDriver driver) { 62 | driver.get("https://bonigarcia.dev/selenium-webdriver-java/"); 63 | driver.navigate().refresh(); 64 | Wait wait = new WebDriverWait(driver, 65 | Duration.ofSeconds(30)); 66 | wait.until(d -> d.getTitle().contains("Selenium WebDriver")); 67 | } 68 | 69 | } 70 | -------------------------------------------------------------------------------- /src/test/java/io/github/bonigarcia/seljup/test/generic/GenericTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2018 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup.test.generic; 18 | 19 | //tag::snippet-in-doc[] 20 | import static org.assertj.core.api.Assertions.assertThat; 21 | 22 | import org.junit.jupiter.api.Test; 23 | import org.junit.jupiter.api.extension.ExtendWith; 24 | import org.openqa.selenium.WebDriver; 25 | 26 | import io.github.bonigarcia.seljup.SeleniumJupiter; 27 | 28 | @ExtendWith(SeleniumJupiter.class) 29 | class GenericTest { 30 | 31 | @Test 32 | void genericTest(WebDriver driver) { 33 | driver.get("https://bonigarcia.dev/selenium-webdriver-java/"); 34 | assertThat(driver.getTitle()).contains("Selenium WebDriver"); 35 | } 36 | 37 | } 38 | //end::snippet-in-doc[] -------------------------------------------------------------------------------- /src/test/java/io/github/bonigarcia/seljup/test/generic/GenericWithScreenshotTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2018 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup.test.generic; 18 | 19 | import static org.assertj.core.api.Assertions.assertThat; 20 | 21 | import java.io.File; 22 | import java.util.Arrays; 23 | import java.util.Optional; 24 | 25 | import org.junit.jupiter.api.AfterEach; 26 | import org.junit.jupiter.api.BeforeAll; 27 | import org.junit.jupiter.api.Test; 28 | import org.junit.jupiter.api.extension.RegisterExtension; 29 | import org.openqa.selenium.WebDriver; 30 | import org.openqa.selenium.remote.RemoteWebDriver; 31 | import org.openqa.selenium.remote.SessionId; 32 | 33 | import io.github.bonigarcia.seljup.SeleniumJupiter; 34 | 35 | class GenericWithScreenshotTest { 36 | 37 | @RegisterExtension 38 | static SeleniumJupiter seleniumJupiter = new SeleniumJupiter(); 39 | 40 | SessionId sessionId; 41 | 42 | @BeforeAll 43 | static void setup() { 44 | seleniumJupiter.getConfig().enableScreenshot(); 45 | seleniumJupiter.getConfig().takeScreenshotAsPng(); 46 | } 47 | 48 | @AfterEach 49 | void teardown() { 50 | File[] files = new File(".").listFiles(); 51 | Optional screenshot = Arrays.stream(files).filter( 52 | f -> f.getName().endsWith(sessionId.toString() + ".png")) 53 | .findFirst(); 54 | assertThat(screenshot).isNotEmpty(); 55 | screenshot.get().delete(); 56 | } 57 | 58 | @Test 59 | void screenshotGenericTest(WebDriver driver) { 60 | driver.get("https://bonigarcia.dev/selenium-webdriver-java/"); 61 | assertThat(driver.getTitle()).contains("Selenium WebDriver"); 62 | 63 | sessionId = ((RemoteWebDriver) driver).getSessionId(); 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /src/test/java/io/github/bonigarcia/seljup/test/jenkins/JenkinsTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2021 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup.test.jenkins; 18 | 19 | import static io.github.bonigarcia.seljup.BrowserType.CHROME; 20 | //tag::snippet-in-doc[] 21 | import static org.assertj.core.api.Assertions.assertThat; 22 | 23 | import java.time.Duration; 24 | 25 | import org.junit.jupiter.api.BeforeAll; 26 | import org.junit.jupiter.api.Test; 27 | import org.junit.jupiter.api.extension.RegisterExtension; 28 | import org.openqa.selenium.WebDriver; 29 | 30 | import io.github.bonigarcia.seljup.DockerBrowser; 31 | import io.github.bonigarcia.seljup.SeleniumJupiter; 32 | 33 | class JenkinsTest { 34 | 35 | @RegisterExtension 36 | static SeleniumJupiter seleniumJupiter = new SeleniumJupiter(); 37 | 38 | @BeforeAll 39 | static void setup() { 40 | seleniumJupiter.getConfig().enableScreenshot(); 41 | seleniumJupiter.getConfig().enableRecording(); 42 | seleniumJupiter.getConfig().useSurefireOutputFolder(); 43 | } 44 | 45 | @Test 46 | void jenkinsTest(@DockerBrowser(type = CHROME) WebDriver driver) 47 | throws InterruptedException { 48 | driver.get("https://bonigarcia.dev/selenium-webdriver-java/"); 49 | assertThat(driver.getTitle()).contains("Selenium WebDriver"); 50 | 51 | Thread.sleep(Duration.ofSeconds(5).toMillis()); 52 | } 53 | 54 | } 55 | //end::snippet-in-doc[] 56 | -------------------------------------------------------------------------------- /src/test/java/io/github/bonigarcia/seljup/test/local/ChromeInConstructorTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2018 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup.test.local; 18 | 19 | import static org.assertj.core.api.Assertions.assertThat; 20 | 21 | import org.junit.jupiter.api.Test; 22 | import org.junit.jupiter.api.extension.ExtendWith; 23 | import org.openqa.selenium.chrome.ChromeDriver; 24 | 25 | import io.github.bonigarcia.seljup.SeleniumJupiter; 26 | 27 | @ExtendWith(SeleniumJupiter.class) 28 | class ChromeInConstructorTest { 29 | 30 | ChromeDriver driver; 31 | 32 | ChromeInConstructorTest(ChromeDriver driver) { 33 | this.driver = driver; 34 | } 35 | 36 | @Test 37 | void test() { 38 | driver.get("https://bonigarcia.dev/selenium-webdriver-java/"); 39 | assertThat(driver.getTitle()).contains("Selenium WebDriver"); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/test/java/io/github/bonigarcia/seljup/test/local/ChromeTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2017 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup.test.local; 18 | 19 | //tag::snippet-in-doc[] 20 | import static org.assertj.core.api.Assertions.assertThat; 21 | 22 | import org.junit.jupiter.api.Test; 23 | import org.junit.jupiter.api.extension.ExtendWith; 24 | import org.openqa.selenium.chrome.ChromeDriver; 25 | 26 | import io.github.bonigarcia.seljup.SeleniumJupiter; 27 | 28 | @ExtendWith(SeleniumJupiter.class) 29 | class ChromeTest { 30 | 31 | @Test 32 | void test(ChromeDriver driver) { 33 | driver.get("https://bonigarcia.dev/selenium-webdriver-java/"); 34 | assertThat(driver.getTitle()).contains("Selenium WebDriver"); 35 | } 36 | 37 | } 38 | //end::snippet-in-doc[] 39 | -------------------------------------------------------------------------------- /src/test/java/io/github/bonigarcia/seljup/test/local/ChromiumTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2020 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup.test.local; 18 | 19 | import static io.github.bonigarcia.seljup.Browser.CHROMIUM; 20 | import static org.assertj.core.api.Assertions.assertThat; 21 | 22 | import org.junit.jupiter.api.Test; 23 | import org.junit.jupiter.api.extension.ExtendWith; 24 | import org.openqa.selenium.chromium.ChromiumDriver; 25 | 26 | import io.github.bonigarcia.seljup.EnabledIfBrowserAvailable; 27 | import io.github.bonigarcia.seljup.SeleniumJupiter; 28 | 29 | @EnabledIfBrowserAvailable(CHROMIUM) 30 | @ExtendWith(SeleniumJupiter.class) 31 | class ChromiumTest { 32 | 33 | @Test 34 | void test(ChromiumDriver driver) { 35 | driver.get("https://bonigarcia.dev/selenium-webdriver-java/"); 36 | assertThat(driver.getTitle()).contains("Selenium WebDriver"); 37 | } 38 | 39 | } -------------------------------------------------------------------------------- /src/test/java/io/github/bonigarcia/seljup/test/local/EdgeTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2017 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup.test.local; 18 | 19 | import static io.github.bonigarcia.seljup.Browser.EDGE; 20 | import static org.assertj.core.api.Assertions.assertThat; 21 | 22 | import org.junit.jupiter.api.Disabled; 23 | import org.junit.jupiter.api.Test; 24 | import org.junit.jupiter.api.extension.ExtendWith; 25 | import org.openqa.selenium.edge.EdgeDriver; 26 | 27 | import io.github.bonigarcia.seljup.EnabledIfBrowserAvailable; 28 | import io.github.bonigarcia.seljup.SeleniumJupiter; 29 | 30 | @Disabled 31 | @EnabledIfBrowserAvailable(EDGE) 32 | @ExtendWith(SeleniumJupiter.class) 33 | class EdgeTest { 34 | 35 | @Test 36 | void test(EdgeDriver driver) { 37 | driver.get("https://bonigarcia.dev/selenium-webdriver-java/"); 38 | assertThat(driver.getTitle()).contains("Selenium WebDriver"); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/test/java/io/github/bonigarcia/seljup/test/local/FirefoxTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2017 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup.test.local; 18 | 19 | import static java.lang.invoke.MethodHandles.lookup; 20 | import static org.assertj.core.api.Assertions.assertThat; 21 | import static org.slf4j.LoggerFactory.getLogger; 22 | 23 | import org.junit.jupiter.api.Test; 24 | import org.junit.jupiter.api.extension.ExtendWith; 25 | import org.openqa.selenium.firefox.FirefoxDriver; 26 | import org.slf4j.Logger; 27 | 28 | import io.github.bonigarcia.seljup.SeleniumJupiter; 29 | 30 | @ExtendWith(SeleniumJupiter.class) 31 | class FirefoxTest { 32 | 33 | final Logger log = getLogger(lookup().lookupClass()); 34 | 35 | @Test 36 | void testFirefox(FirefoxDriver driver) { 37 | String sutUrl = "https://bonigarcia.dev/selenium-webdriver-java/"; 38 | driver.get(sutUrl); 39 | String title = driver.getTitle(); 40 | log.debug("The title of {} is {}", sutUrl, title); 41 | 42 | assertThat(title).contains("Selenium WebDriver"); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/test/java/io/github/bonigarcia/seljup/test/local/IExplorerTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2019 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup.test.local; 18 | 19 | import static org.assertj.core.api.Assertions.assertThat; 20 | 21 | import org.junit.jupiter.api.Disabled; 22 | import org.junit.jupiter.api.Test; 23 | import org.junit.jupiter.api.extension.ExtendWith; 24 | import org.openqa.selenium.ie.InternetExplorerDriver; 25 | 26 | import io.github.bonigarcia.seljup.SeleniumJupiter; 27 | 28 | @Disabled("Internet Explorer is not available on CI") 29 | @ExtendWith(SeleniumJupiter.class) 30 | class IExplorerTest { 31 | 32 | @Test 33 | void test(InternetExplorerDriver driver) { 34 | driver.get("https://bonigarcia.dev/selenium-webdriver-java/"); 35 | assertThat(driver.getTitle()).contains("Selenium WebDriver"); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/test/java/io/github/bonigarcia/seljup/test/local/NestedTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2019 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup.test.local; 18 | 19 | import static org.assertj.core.api.Assertions.assertThat; 20 | 21 | import org.junit.jupiter.api.Nested; 22 | import org.junit.jupiter.api.Test; 23 | import org.junit.jupiter.api.extension.ExtendWith; 24 | import org.openqa.selenium.chrome.ChromeDriver; 25 | 26 | import io.github.bonigarcia.seljup.SeleniumJupiter; 27 | 28 | @ExtendWith(SeleniumJupiter.class) 29 | class NestedTest { 30 | 31 | @Test 32 | void test(ChromeDriver driver) { 33 | exercise(driver); 34 | } 35 | 36 | private void exercise(ChromeDriver driver) { 37 | driver.get("https://bonigarcia.dev/selenium-webdriver-java/"); 38 | assertThat(driver.getTitle()).contains("Selenium WebDriver"); 39 | } 40 | 41 | @Nested 42 | class MyNestedClass { 43 | 44 | @Test 45 | void testWithOtherChrome(ChromeDriver driver) { 46 | exercise(driver); 47 | } 48 | 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /src/test/java/io/github/bonigarcia/seljup/test/local/OperaTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2017 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup.test.local; 18 | 19 | import static io.github.bonigarcia.seljup.Browser.OPERA; 20 | import static org.assertj.core.api.Assertions.assertThat; 21 | 22 | import org.junit.jupiter.api.Test; 23 | import org.junit.jupiter.api.extension.ExtendWith; 24 | import org.openqa.selenium.chrome.ChromeDriver; 25 | 26 | import io.github.bonigarcia.seljup.EnabledIfBrowserAvailable; 27 | import io.github.bonigarcia.seljup.Opera; 28 | import io.github.bonigarcia.seljup.SeleniumJupiter; 29 | 30 | @EnabledIfBrowserAvailable(OPERA) 31 | @ExtendWith(SeleniumJupiter.class) 32 | class OperaTest { 33 | 34 | @Test 35 | void test(@Opera ChromeDriver driver) { 36 | driver.get("https://bonigarcia.dev/selenium-webdriver-java/"); 37 | assertThat(driver.getTitle()).contains("Selenium WebDriver"); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /src/test/java/io/github/bonigarcia/seljup/test/local/SafariTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2017 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup.test.local; 18 | 19 | //tag::snippet-in-doc[] 20 | import static io.github.bonigarcia.seljup.Browser.SAFARI; 21 | import static org.assertj.core.api.Assertions.assertThat; 22 | 23 | import org.junit.jupiter.api.Test; 24 | import org.junit.jupiter.api.extension.ExtendWith; 25 | import org.openqa.selenium.safari.SafariDriver; 26 | 27 | import io.github.bonigarcia.seljup.EnabledIfBrowserAvailable; 28 | import io.github.bonigarcia.seljup.SeleniumJupiter; 29 | 30 | @EnabledIfBrowserAvailable(SAFARI) 31 | @ExtendWith(SeleniumJupiter.class) 32 | class SafariTest { 33 | 34 | @Test 35 | void test(SafariDriver driver) { 36 | driver.get("https://bonigarcia.dev/selenium-webdriver-java/"); 37 | assertThat(driver.getTitle()).contains("Selenium WebDriver"); 38 | } 39 | 40 | } 41 | //end::snippet-in-doc[] 42 | -------------------------------------------------------------------------------- /src/test/java/io/github/bonigarcia/seljup/test/remote/AppiumTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2022 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup.test.remote; 18 | 19 | //tag::snippet-in-doc[] 20 | import static org.assertj.core.api.Assertions.assertThat; 21 | 22 | import org.junit.jupiter.api.BeforeEach; 23 | import org.junit.jupiter.api.Test; 24 | import org.junit.jupiter.api.extension.ExtendWith; 25 | import org.openqa.selenium.chrome.ChromeOptions; 26 | import org.openqa.selenium.remote.CapabilityType; 27 | 28 | import io.appium.java_client.AppiumDriver; 29 | import io.appium.java_client.android.options.EspressoOptions; 30 | import io.github.bonigarcia.seljup.DriverCapabilities; 31 | import io.github.bonigarcia.seljup.EnabledIfDriverUrlOnline; 32 | import io.github.bonigarcia.seljup.SeleniumJupiter; 33 | 34 | @EnabledIfDriverUrlOnline("http://localhost:4723") 35 | @ExtendWith(SeleniumJupiter.class) 36 | class AppiumTest { 37 | 38 | @DriverCapabilities 39 | ChromeOptions options = new ChromeOptions(); 40 | 41 | @BeforeEach 42 | void setup() { 43 | options.setCapability(CapabilityType.PLATFORM_NAME, "Android"); 44 | options.setCapability(EspressoOptions.DEVICE_NAME_OPTION, 45 | "Nexus 5 API 30"); 46 | options.setCapability(EspressoOptions.AUTOMATION_NAME_OPTION, 47 | "UiAutomator2"); 48 | } 49 | 50 | @Test 51 | void test(AppiumDriver driver) { 52 | driver.get("https://bonigarcia.dev/selenium-webdriver-java/"); 53 | assertThat(driver.getTitle()).contains("Selenium WebDriver"); 54 | } 55 | 56 | } 57 | //end::snippet-in-doc[] -------------------------------------------------------------------------------- /src/test/java/io/github/bonigarcia/seljup/test/remote/RemoteChromeTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2017 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup.test.remote; 18 | 19 | //tag::snippet-in-doc[] 20 | import static org.assertj.core.api.Assertions.assertThat; 21 | 22 | import org.junit.jupiter.api.Test; 23 | import org.junit.jupiter.api.extension.ExtendWith; 24 | import org.openqa.selenium.Capabilities; 25 | import org.openqa.selenium.WebDriver; 26 | import org.openqa.selenium.chrome.ChromeOptions; 27 | 28 | import io.github.bonigarcia.seljup.DriverCapabilities; 29 | import io.github.bonigarcia.seljup.EnabledIfDriverUrlOnline; 30 | import io.github.bonigarcia.seljup.SeleniumJupiter; 31 | 32 | @EnabledIfDriverUrlOnline("http://localhost:4444/") 33 | @ExtendWith(SeleniumJupiter.class) 34 | class RemoteChromeTest { 35 | 36 | @DriverCapabilities 37 | Capabilities capabilities = new ChromeOptions(); 38 | 39 | @Test 40 | void test(WebDriver driver) { 41 | driver.get("https://bonigarcia.dev/selenium-webdriver-java/"); 42 | assertThat(driver.getTitle()).contains("Selenium WebDriver"); 43 | } 44 | 45 | } 46 | //end::snippet-in-doc[] -------------------------------------------------------------------------------- /src/test/java/io/github/bonigarcia/seljup/test/remote/RemoteFirefoxTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2017 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup.test.remote; 18 | 19 | //tag::snippet-in-doc[] 20 | import static org.assertj.core.api.Assertions.assertThat; 21 | 22 | import org.junit.jupiter.api.BeforeAll; 23 | import org.junit.jupiter.api.Test; 24 | import org.junit.jupiter.api.extension.ExtendWith; 25 | import org.openqa.selenium.WebDriver; 26 | import org.openqa.selenium.grid.Main; 27 | 28 | import io.github.bonigarcia.seljup.DriverCapabilities; 29 | import io.github.bonigarcia.seljup.DriverUrl; 30 | import io.github.bonigarcia.seljup.SeleniumJupiter; 31 | import io.github.bonigarcia.wdm.WebDriverManager; 32 | 33 | @ExtendWith(SeleniumJupiter.class) 34 | class RemoteFirefoxTest { 35 | 36 | @BeforeAll 37 | static void setup() { 38 | // Resolve driver 39 | WebDriverManager.firefoxdriver().setup(); 40 | 41 | // Start Selenium Grid in standalone mode 42 | Main.main(new String[] { "standalone", "--port", "4444" }); 43 | } 44 | 45 | @Test 46 | void test(@DriverUrl("http://localhost:4444/") @DriverCapabilities({ 47 | "browserName=firefox" }) WebDriver driver) { 48 | driver.get("https://bonigarcia.dev/selenium-webdriver-java/"); 49 | assertThat(driver.getTitle()).contains("Selenium WebDriver"); 50 | } 51 | 52 | } 53 | //end::snippet-in-doc[] 54 | -------------------------------------------------------------------------------- /src/test/java/io/github/bonigarcia/seljup/test/remote/SauceLabsTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2019 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup.test.remote; 18 | 19 | import static org.assertj.core.api.Assertions.assertThat; 20 | 21 | import org.junit.jupiter.api.Test; 22 | import org.junit.jupiter.api.condition.EnabledIfSystemProperties; 23 | import org.junit.jupiter.api.condition.EnabledIfSystemProperty; 24 | import org.junit.jupiter.api.extension.ExtendWith; 25 | import org.openqa.selenium.remote.DesiredCapabilities; 26 | import org.openqa.selenium.remote.RemoteWebDriver; 27 | 28 | import io.github.bonigarcia.seljup.DriverCapabilities; 29 | import io.github.bonigarcia.seljup.DriverUrl; 30 | import io.github.bonigarcia.seljup.SeleniumJupiter; 31 | 32 | @EnabledIfSystemProperties({ 33 | @EnabledIfSystemProperty(named = "sauceLabsUsername", matches = ".*"), 34 | @EnabledIfSystemProperty(named = "sauceLabsPassword", matches = ".*") }) 35 | @ExtendWith(SeleniumJupiter.class) 36 | class SauceLabsTest { 37 | 38 | @DriverUrl 39 | String url = "https://ondemand.eu-central-1.saucelabs.com/wd/hub"; 40 | 41 | @DriverCapabilities 42 | DesiredCapabilities capabilities = new DesiredCapabilities(); 43 | { 44 | capabilities.setCapability("username", 45 | System.getProperty("sauceLabsUsername")); 46 | capabilities.setCapability("accessKey", 47 | System.getProperty("sauceLabsPassword")); 48 | capabilities.setCapability("browserName", "Chrome"); 49 | capabilities.setCapability("platform", "Windows 10"); 50 | capabilities.setCapability("version", "59.0"); 51 | capabilities.setCapability("name", "selenium-jupiter-and-saucelabs"); 52 | } 53 | 54 | @Test 55 | void testWithSaucelabs(RemoteWebDriver driver) { 56 | driver.get("https://bonigarcia.dev/selenium-webdriver-java/"); 57 | assertThat(driver.getTitle()).contains("Selenium WebDriver"); 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /src/test/java/io/github/bonigarcia/seljup/test/screenshot/ScreenshotBase64Test.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2017 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup.test.screenshot; 18 | 19 | import static org.assertj.core.api.Assertions.assertThat; 20 | 21 | import java.io.File; 22 | import java.util.Arrays; 23 | import java.util.Optional; 24 | 25 | import org.junit.jupiter.api.AfterEach; 26 | import org.junit.jupiter.api.BeforeAll; 27 | import org.junit.jupiter.api.Test; 28 | import org.junit.jupiter.api.extension.RegisterExtension; 29 | import org.openqa.selenium.chrome.ChromeDriver; 30 | import org.openqa.selenium.remote.SessionId; 31 | 32 | import io.github.bonigarcia.seljup.SeleniumJupiter; 33 | 34 | class ScreenshotBase64Test { 35 | 36 | @RegisterExtension 37 | static SeleniumJupiter seleniumJupiter = new SeleniumJupiter(); 38 | 39 | SessionId sessionId; 40 | 41 | @BeforeAll 42 | static void setup() { 43 | seleniumJupiter.getConfig().enableScreenshot(); 44 | seleniumJupiter.getConfig().takeScreenshotAsBase64(); 45 | } 46 | 47 | @AfterEach 48 | void teardown() { 49 | File[] files = new File(".").listFiles(); 50 | Optional screenshot = Arrays.stream(files).filter( 51 | f -> f.getName().endsWith(sessionId.toString() + ".png")) 52 | .findFirst(); 53 | assertThat(screenshot).isEmpty(); 54 | } 55 | 56 | @Test 57 | void screenshotTest(ChromeDriver driver) { 58 | driver.get("https://bonigarcia.dev/selenium-webdriver-java/"); 59 | assertThat(driver.getTitle()).contains("Selenium WebDriver"); 60 | 61 | sessionId = driver.getSessionId(); 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /src/test/java/io/github/bonigarcia/seljup/test/screenshot/ScreenshotOutputFolderPerClassTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2022 Bosch.IO GmbH 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup.test.screenshot; 18 | 19 | import io.github.bonigarcia.seljup.SeleniumJupiter; 20 | import io.github.bonigarcia.seljup.config.Config; 21 | 22 | import org.junit.jupiter.api.AfterEach; 23 | import org.junit.jupiter.api.BeforeAll; 24 | import org.junit.jupiter.api.Test; 25 | import org.junit.jupiter.api.extension.RegisterExtension; 26 | import org.openqa.selenium.chrome.ChromeDriver; 27 | import org.openqa.selenium.remote.SessionId; 28 | 29 | import java.io.File; 30 | import java.util.Arrays; 31 | import java.util.Optional; 32 | 33 | import static org.assertj.core.api.Assertions.assertThat; 34 | 35 | class ScreenshotOutputFolderPerClassTest { 36 | 37 | private static final String RECORDINGS_FOLDER = "./target/recordings"; 38 | 39 | @RegisterExtension 40 | static SeleniumJupiter seleniumJupiter = new SeleniumJupiter(); 41 | 42 | SessionId sessionId; 43 | 44 | @BeforeAll 45 | static void setup() { 46 | Config config = seleniumJupiter.getConfig(); 47 | 48 | config.enableScreenshot(); 49 | config.takeScreenshotAsPng(); 50 | config.setOutputFolder(RECORDINGS_FOLDER); 51 | config.setOutputFolderPerClass(true); 52 | } 53 | 54 | @AfterEach 55 | void teardown() { 56 | File[] files = new File( 57 | RECORDINGS_FOLDER + File.separator + this.getClass().getName()) 58 | .listFiles(); 59 | Optional screenshot = Arrays.stream(files).filter( 60 | f -> f.getName().endsWith(sessionId.toString() + ".png")) 61 | .findFirst(); 62 | assertThat(screenshot).isNotEmpty(); 63 | screenshot.get().delete(); 64 | } 65 | 66 | @Test 67 | void screenshotTest(ChromeDriver driver) { 68 | driver.get("https://bonigarcia.dev/selenium-webdriver-java/"); 69 | assertThat(driver.getTitle()).contains("Selenium WebDriver"); 70 | 71 | sessionId = driver.getSessionId(); 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /src/test/java/io/github/bonigarcia/seljup/test/screenshot/ScreenshotPngTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2017 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup.test.screenshot; 18 | 19 | //tag::snippet-in-doc[] 20 | import static org.assertj.core.api.Assertions.assertThat; 21 | 22 | import java.io.File; 23 | import java.util.Arrays; 24 | import java.util.Optional; 25 | 26 | import org.junit.jupiter.api.AfterEach; 27 | import org.junit.jupiter.api.BeforeAll; 28 | import org.junit.jupiter.api.Test; 29 | import org.junit.jupiter.api.extension.RegisterExtension; 30 | import org.openqa.selenium.chrome.ChromeDriver; 31 | import org.openqa.selenium.remote.SessionId; 32 | 33 | import io.github.bonigarcia.seljup.SeleniumJupiter; 34 | 35 | class ScreenshotPngTest { 36 | 37 | @RegisterExtension 38 | static SeleniumJupiter seleniumJupiter = new SeleniumJupiter(); 39 | 40 | SessionId sessionId; 41 | 42 | @BeforeAll 43 | static void setup() { 44 | seleniumJupiter.getConfig().enableScreenshot(); 45 | seleniumJupiter.getConfig().takeScreenshotAsPng(); // Default option 46 | } 47 | 48 | @AfterEach 49 | void teardown() { 50 | File[] files = new File(".").listFiles(); 51 | Optional screenshot = Arrays.stream(files).filter( 52 | f -> f.getName().endsWith(sessionId.toString() + ".png")) 53 | .findFirst(); 54 | assertThat(screenshot).isNotEmpty(); 55 | screenshot.get().delete(); 56 | } 57 | 58 | @Test 59 | void screenshotTest(ChromeDriver driver) { 60 | driver.get("https://bonigarcia.dev/selenium-webdriver-java/"); 61 | assertThat(driver.getTitle()).contains("Selenium WebDriver"); 62 | 63 | sessionId = driver.getSessionId(); 64 | } 65 | 66 | } 67 | //end::snippet-in-doc[] 68 | -------------------------------------------------------------------------------- /src/test/java/io/github/bonigarcia/seljup/test/screenshot/ScreenshotSurefireTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2017 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup.test.screenshot; 18 | 19 | //tag::snippet-in-doc[] 20 | import static org.assertj.core.api.Assertions.assertThat; 21 | 22 | import java.io.File; 23 | import java.util.Arrays; 24 | import java.util.Optional; 25 | 26 | import org.junit.jupiter.api.AfterEach; 27 | import org.junit.jupiter.api.BeforeAll; 28 | import org.junit.jupiter.api.Test; 29 | import org.junit.jupiter.api.extension.RegisterExtension; 30 | import org.openqa.selenium.chrome.ChromeDriver; 31 | import org.openqa.selenium.remote.SessionId; 32 | 33 | import io.github.bonigarcia.seljup.SeleniumJupiter; 34 | 35 | class ScreenshotSurefireTest { 36 | 37 | @RegisterExtension 38 | static SeleniumJupiter seleniumJupiter = new SeleniumJupiter(); 39 | 40 | SessionId sessionId; 41 | 42 | @BeforeAll 43 | static void setup() { 44 | seleniumJupiter.getConfig().enableScreenshot(); 45 | seleniumJupiter.getConfig().takeScreenshotAsPng(); 46 | seleniumJupiter.getConfig().useSurefireOutputFolder(); 47 | } 48 | 49 | @AfterEach 50 | void teardown() { 51 | File[] files = new File( 52 | "./target/surefire-reports/io.github.bonigarcia.seljup.test.screenshot.ScreenshotSurefireTest") 53 | .listFiles(); 54 | Optional screenshot = Arrays.stream(files).filter( 55 | f -> f.getName().endsWith(sessionId.toString() + ".png")) 56 | .findFirst(); 57 | assertThat(screenshot).isNotEmpty(); 58 | screenshot.get().delete(); 59 | } 60 | 61 | @Test 62 | void screenshotTest(ChromeDriver driver) { 63 | driver.get("https://bonigarcia.dev/selenium-webdriver-java/"); 64 | assertThat(driver.getTitle()).contains("Selenium WebDriver"); 65 | 66 | sessionId = driver.getSessionId(); 67 | } 68 | 69 | } 70 | //end::snippet-in-doc[] 71 | -------------------------------------------------------------------------------- /src/test/java/io/github/bonigarcia/seljup/test/selenide/DockerSelenideTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2022 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup.test.selenide; 18 | 19 | //tag::snippet-in-doc[] 20 | import static io.github.bonigarcia.seljup.BrowserType.CHROME; 21 | import static org.assertj.core.api.Assertions.assertThat; 22 | 23 | import org.junit.jupiter.api.Test; 24 | import org.junit.jupiter.api.extension.ExtendWith; 25 | 26 | import com.codeborne.selenide.SelenideDriver; 27 | 28 | import io.github.bonigarcia.seljup.DockerBrowser; 29 | import io.github.bonigarcia.seljup.SeleniumJupiter; 30 | 31 | @ExtendWith(SeleniumJupiter.class) 32 | class DockerSelenideTest { 33 | 34 | @Test 35 | void test(@DockerBrowser(type = CHROME) SelenideDriver driver) { 36 | driver.open("https://bonigarcia.dev/selenium-webdriver-java/"); 37 | assertThat(driver.title()).contains("Selenium WebDriver"); 38 | } 39 | 40 | } 41 | //end::snippet-in-doc[] 42 | -------------------------------------------------------------------------------- /src/test/java/io/github/bonigarcia/seljup/test/selenide/RemoteSelenideTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2017 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup.test.selenide; 18 | 19 | import static org.assertj.core.api.Assertions.assertThat; 20 | 21 | import org.junit.jupiter.api.Test; 22 | import org.junit.jupiter.api.extension.ExtendWith; 23 | import org.openqa.selenium.Capabilities; 24 | import org.openqa.selenium.chrome.ChromeOptions; 25 | 26 | import com.codeborne.selenide.SelenideDriver; 27 | 28 | import io.github.bonigarcia.seljup.DriverCapabilities; 29 | import io.github.bonigarcia.seljup.EnabledIfDriverUrlOnline; 30 | import io.github.bonigarcia.seljup.SeleniumJupiter; 31 | 32 | //tag::snippet-in-doc[] 33 | @EnabledIfDriverUrlOnline("http://localhost:4444/") 34 | @ExtendWith(SeleniumJupiter.class) 35 | class RemoteSelenideTest { 36 | 37 | @DriverCapabilities 38 | Capabilities capabilities = new ChromeOptions(); 39 | 40 | @Test 41 | void test(SelenideDriver driver) { 42 | driver.open("https://bonigarcia.dev/selenium-webdriver-java/"); 43 | assertThat(driver.title()).contains("Selenium WebDriver"); 44 | } 45 | 46 | } 47 | //end::snippet-in-doc[] -------------------------------------------------------------------------------- /src/test/java/io/github/bonigarcia/seljup/test/selenide/SelenideGlobalConfigJupiterTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2019 Boni Garcia (http://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup.test.selenide; 18 | 19 | // tag::snippet-in-doc[] 20 | import static com.codeborne.selenide.Browsers.FIREFOX; 21 | import static com.codeborne.selenide.Condition.visible; 22 | import static org.openqa.selenium.By.linkText; 23 | 24 | import org.junit.jupiter.api.Test; 25 | import org.junit.jupiter.api.extension.ExtendWith; 26 | 27 | import com.codeborne.selenide.SelenideConfig; 28 | import com.codeborne.selenide.SelenideDriver; 29 | import com.codeborne.selenide.SelenideElement; 30 | 31 | import io.github.bonigarcia.seljup.SelenideConfiguration; 32 | import io.github.bonigarcia.seljup.SeleniumJupiter; 33 | 34 | @ExtendWith(SeleniumJupiter.class) 35 | class SelenideGlobalConfigJupiterTest { 36 | 37 | @SelenideConfiguration 38 | SelenideConfig selenideConfig = new SelenideConfig().browser(FIREFOX); 39 | 40 | @Test 41 | void testSelenideConfig(SelenideDriver driver) { 42 | driver.open("https://bonigarcia.dev/selenium-webdriver-java/"); 43 | SelenideElement about = driver.$(linkText("Web form")); 44 | about.shouldBe(visible); 45 | about.click(); 46 | } 47 | 48 | } 49 | // end::snippet-in-doc[] 50 | -------------------------------------------------------------------------------- /src/test/java/io/github/bonigarcia/seljup/test/selenide/SelenideParameterConfigJupiterTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2019 Boni Garcia (http://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup.test.selenide; 18 | 19 | // tag::snippet-in-doc[] 20 | import static com.codeborne.selenide.Browsers.CHROME; 21 | import static com.codeborne.selenide.Browsers.FIREFOX; 22 | import static org.assertj.core.api.Assertions.assertThat; 23 | 24 | import org.junit.jupiter.api.Test; 25 | import org.junit.jupiter.api.extension.ExtendWith; 26 | 27 | import com.codeborne.selenide.SelenideDriver; 28 | 29 | import io.github.bonigarcia.seljup.SelenideConfiguration; 30 | import io.github.bonigarcia.seljup.SeleniumJupiter; 31 | 32 | @ExtendWith(SeleniumJupiter.class) 33 | class SelenideParameterConfigJupiterTest { 34 | 35 | @Test 36 | void testHeadlessFirefoxSelenide( 37 | @SelenideConfiguration(browser = FIREFOX, headless = true) SelenideDriver driver) { 38 | exercise(driver); 39 | } 40 | 41 | @Test 42 | void testChromeAndFirefoxSelenide( 43 | @SelenideConfiguration(browser = CHROME) SelenideDriver chrome, 44 | @SelenideConfiguration(browser = FIREFOX) SelenideDriver firefox) { 45 | exercise(chrome, firefox); 46 | } 47 | 48 | private void exercise(SelenideDriver... drivers) { 49 | for (SelenideDriver driver : drivers) { 50 | driver.open("https://bonigarcia.dev/selenium-webdriver-java/"); 51 | assertThat(driver.title()).contains("Selenium WebDriver"); 52 | } 53 | } 54 | 55 | } 56 | // end::snippet-in-doc[] 57 | -------------------------------------------------------------------------------- /src/test/java/io/github/bonigarcia/seljup/test/selenide/SelenideTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2022 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup.test.selenide; 18 | 19 | //tag::snippet-in-doc[] 20 | import static org.assertj.core.api.Assertions.assertThat; 21 | 22 | import org.junit.jupiter.api.Test; 23 | import org.junit.jupiter.api.extension.ExtendWith; 24 | 25 | import com.codeborne.selenide.SelenideDriver; 26 | 27 | import io.github.bonigarcia.seljup.SeleniumJupiter; 28 | 29 | @ExtendWith(SeleniumJupiter.class) 30 | class SelenideTest { 31 | 32 | @Test 33 | void test(SelenideDriver driver) { 34 | driver.open("https://bonigarcia.dev/selenium-webdriver-java/"); 35 | assertThat(driver.title()).contains("Selenium WebDriver"); 36 | } 37 | 38 | } 39 | //end::snippet-in-doc[] 40 | -------------------------------------------------------------------------------- /src/test/java/io/github/bonigarcia/seljup/test/selenide/TemplateSelenideTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2022 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup.test.selenide; 18 | 19 | import static org.assertj.core.api.Assertions.assertThat; 20 | 21 | import org.junit.jupiter.api.BeforeAll; 22 | import org.junit.jupiter.api.TestTemplate; 23 | import org.junit.jupiter.api.extension.RegisterExtension; 24 | 25 | import com.codeborne.selenide.SelenideDriver; 26 | 27 | import io.github.bonigarcia.seljup.SeleniumJupiter; 28 | 29 | class TemplateSelenideTest { 30 | 31 | @RegisterExtension 32 | static SeleniumJupiter seleniumJupiter = new SeleniumJupiter(); 33 | 34 | @BeforeAll 35 | static void setup() { 36 | seleniumJupiter.getConfig().setBrowserTemplateJsonFile( 37 | "./src/test/resources/browsers-selenide.json"); 38 | } 39 | 40 | @TestTemplate 41 | void templateTest(SelenideDriver driver) { 42 | driver.open("https://bonigarcia.dev/selenium-webdriver-java/"); 43 | assertThat(driver.title()).contains("Selenium WebDriver"); 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/test/java/io/github/bonigarcia/seljup/test/singlessession/FailureCreatesScreenshotTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2019 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup.test.singlessession; 18 | 19 | import static org.assertj.core.api.Assertions.assertThat; 20 | import static org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS; 21 | 22 | import org.junit.jupiter.api.BeforeAll; 23 | import org.junit.jupiter.api.Disabled; 24 | import org.junit.jupiter.api.MethodOrderer.OrderAnnotation; 25 | import org.junit.jupiter.api.Test; 26 | import org.junit.jupiter.api.TestInstance; 27 | import org.junit.jupiter.api.TestMethodOrder; 28 | import org.junit.jupiter.api.extension.RegisterExtension; 29 | import org.openqa.selenium.WebDriver; 30 | 31 | import io.github.bonigarcia.seljup.SeleniumJupiter; 32 | import io.github.bonigarcia.seljup.SingleSession; 33 | 34 | @TestInstance(PER_CLASS) 35 | @TestMethodOrder(OrderAnnotation.class) 36 | @SingleSession 37 | @Disabled("To avoid breaking CI build") 38 | class FailureCreatesScreenshotTest { 39 | 40 | @RegisterExtension 41 | static SeleniumJupiter seleniumJupiter = new SeleniumJupiter(); 42 | 43 | WebDriver driver; 44 | 45 | FailureCreatesScreenshotTest(WebDriver driver) { 46 | this.driver = driver; 47 | } 48 | 49 | @BeforeAll 50 | void setup() { 51 | seleniumJupiter.getConfig().enableScreenshotWhenFailure(); 52 | seleniumJupiter.getConfig().takeScreenshotAsPng(); 53 | } 54 | 55 | @Test 56 | void shouldFailAndCreateScreenshotTest() { 57 | driver.get("https://bonigarcia.dev/selenium-webdriver-java/"); 58 | assertThat(driver.getTitle()).contains("AAAA"); 59 | } 60 | 61 | @Test 62 | void notFailAndNotCreateScreenshotTest() { 63 | driver.get("https://bonigarcia.dev/selenium-webdriver-java/"); 64 | assertThat(driver.getTitle()).contains("Selenium WebDriver"); 65 | } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /src/test/java/io/github/bonigarcia/seljup/test/singlessession/GenericInConstructorTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2019 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup.test.singlessession; 18 | 19 | import static org.assertj.core.api.Assertions.assertThat; 20 | 21 | import org.junit.jupiter.api.Test; 22 | import org.junit.jupiter.api.extension.ExtendWith; 23 | import org.openqa.selenium.WebDriver; 24 | 25 | import io.github.bonigarcia.seljup.SeleniumJupiter; 26 | import io.github.bonigarcia.seljup.SingleSession; 27 | 28 | @ExtendWith(SeleniumJupiter.class) 29 | @SingleSession 30 | class GenericInConstructorTest { 31 | 32 | WebDriver driver; 33 | 34 | GenericInConstructorTest(WebDriver driver) { 35 | this.driver = driver; 36 | } 37 | 38 | @Test 39 | void genericTest() { 40 | driver.get("https://bonigarcia.dev/selenium-webdriver-java/"); 41 | assertThat(driver.getTitle()).contains("Selenium WebDriver"); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/test/java/io/github/bonigarcia/seljup/test/singlessession/OrderedMultipleTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2019 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup.test.singlessession; 18 | 19 | import static java.lang.invoke.MethodHandles.lookup; 20 | import static org.assertj.core.api.Assertions.assertThat; 21 | import static org.junit.jupiter.api.Assertions.assertTrue; 22 | import static org.slf4j.LoggerFactory.getLogger; 23 | 24 | import org.junit.jupiter.api.MethodOrderer.OrderAnnotation; 25 | import org.junit.jupiter.api.Order; 26 | import org.junit.jupiter.api.Test; 27 | import org.junit.jupiter.api.TestMethodOrder; 28 | import org.junit.jupiter.api.extension.ExtendWith; 29 | import org.openqa.selenium.By; 30 | import org.openqa.selenium.WebElement; 31 | import org.openqa.selenium.chrome.ChromeDriver; 32 | import org.openqa.selenium.remote.RemoteWebDriver; 33 | import org.slf4j.Logger; 34 | 35 | import io.github.bonigarcia.seljup.SeleniumJupiter; 36 | import io.github.bonigarcia.seljup.SingleSession; 37 | 38 | @ExtendWith(SeleniumJupiter.class) 39 | @TestMethodOrder(OrderAnnotation.class) 40 | @SingleSession 41 | class OrderedMultipleTest { 42 | 43 | final Logger log = getLogger(lookup().lookupClass()); 44 | 45 | RemoteWebDriver driver1, driver2; 46 | 47 | OrderedMultipleTest(ChromeDriver driver1, RemoteWebDriver driver2) { 48 | this.driver1 = driver1; 49 | this.driver2 = driver2; 50 | } 51 | 52 | @Test 53 | @Order(1) 54 | void testStep1() { 55 | log.debug("Step 1: {} {}", driver1, driver2); 56 | step1(driver1); 57 | step1(driver2); 58 | } 59 | 60 | @Test 61 | @Order(2) 62 | void testStep2() { 63 | log.debug("Step 2: {} {}", driver1, driver2); 64 | step2(driver1); 65 | step2(driver2); 66 | } 67 | 68 | private void step1(RemoteWebDriver driver) { 69 | driver.get("https://bonigarcia.dev/selenium-webdriver-java/"); 70 | assertThat(driver.getTitle()).contains("Selenium WebDriver"); 71 | } 72 | 73 | private void step2(RemoteWebDriver driver) { 74 | WebElement form = driver.findElement(By.partialLinkText("form")); 75 | assertTrue(form.isDisplayed()); 76 | form.click(); 77 | } 78 | 79 | } 80 | -------------------------------------------------------------------------------- /src/test/java/io/github/bonigarcia/seljup/test/singlessession/OrderedTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2019 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup.test.singlessession; 18 | 19 | //tag::snippet-in-doc[] 20 | import static java.lang.invoke.MethodHandles.lookup; 21 | import static org.assertj.core.api.Assertions.assertThat; 22 | import static org.junit.jupiter.api.Assertions.assertTrue; 23 | import static org.slf4j.LoggerFactory.getLogger; 24 | 25 | import org.junit.jupiter.api.MethodOrderer.OrderAnnotation; 26 | import org.junit.jupiter.api.Order; 27 | import org.junit.jupiter.api.Test; 28 | import org.junit.jupiter.api.TestMethodOrder; 29 | import org.junit.jupiter.api.extension.ExtendWith; 30 | import org.openqa.selenium.By; 31 | import org.openqa.selenium.WebDriver; 32 | import org.openqa.selenium.WebElement; 33 | import org.openqa.selenium.chrome.ChromeDriver; 34 | import org.slf4j.Logger; 35 | 36 | import io.github.bonigarcia.seljup.SeleniumJupiter; 37 | import io.github.bonigarcia.seljup.SingleSession; 38 | 39 | @ExtendWith(SeleniumJupiter.class) 40 | @TestMethodOrder(OrderAnnotation.class) 41 | @SingleSession 42 | class OrderedTest { 43 | 44 | final Logger log = getLogger(lookup().lookupClass()); 45 | 46 | WebDriver driver; 47 | 48 | OrderedTest(ChromeDriver driver) { 49 | this.driver = driver; 50 | } 51 | 52 | @Test 53 | @Order(1) 54 | void testStep1() { 55 | log.debug("Step 1: {}", driver); 56 | driver.get("https://bonigarcia.dev/selenium-webdriver-java/"); 57 | assertThat(driver.getTitle()).contains("Selenium WebDriver"); 58 | 59 | } 60 | 61 | @Test 62 | @Order(2) 63 | void testStep2() { 64 | log.debug("Step 2: {}", driver); 65 | WebElement form = driver.findElement(By.partialLinkText("form")); 66 | assertTrue(form.isDisplayed()); 67 | form.click(); 68 | } 69 | 70 | } 71 | //end::snippet-in-doc[] 72 | -------------------------------------------------------------------------------- /src/test/java/io/github/bonigarcia/seljup/test/singlessession/ScreenshotNamedWithClassTest.java: -------------------------------------------------------------------------------- 1 | package io.github.bonigarcia.seljup.test.singlessession; 2 | 3 | import static org.assertj.core.api.Assertions.assertThat; 4 | import static org.junit.jupiter.api.TestInstance.Lifecycle.PER_CLASS; 5 | 6 | import org.junit.jupiter.api.BeforeAll; 7 | import org.junit.jupiter.api.Disabled; 8 | import org.junit.jupiter.api.MethodOrderer; 9 | import org.junit.jupiter.api.Test; 10 | import org.junit.jupiter.api.TestInstance; 11 | import org.junit.jupiter.api.TestMethodOrder; 12 | import org.junit.jupiter.api.extension.RegisterExtension; 13 | import org.openqa.selenium.chrome.ChromeDriver; 14 | import org.openqa.selenium.remote.RemoteWebDriver; 15 | 16 | import io.github.bonigarcia.seljup.SeleniumJupiter; 17 | import io.github.bonigarcia.seljup.SingleSession; 18 | 19 | @TestInstance(PER_CLASS) 20 | @TestMethodOrder(MethodOrderer.OrderAnnotation.class) 21 | @SingleSession 22 | @Disabled("To avoid breaking CI build") 23 | class ScreenshotNamedWithClassTest { 24 | 25 | @RegisterExtension 26 | static SeleniumJupiter seleniumJupiter = new SeleniumJupiter(); 27 | 28 | RemoteWebDriver driver; 29 | 30 | @BeforeAll 31 | void setup() { 32 | seleniumJupiter.getConfig().enableScreenshotWhenFailure(); 33 | seleniumJupiter.getConfig().takeScreenshotAsPng(); 34 | } 35 | 36 | @BeforeAll 37 | void resolveWebDriver(ChromeDriver webDriver) { 38 | this.driver = webDriver; 39 | } 40 | 41 | @Test 42 | void shouldFailAndCreateScreenshotTest() { 43 | driver.get("https://bonigarcia.dev/selenium-webdriver-java/"); 44 | assertThat(driver.getTitle()).contains("AAA"); 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /src/test/java/io/github/bonigarcia/seljup/test/singlessession/SingleSessionTemplateRegisterTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2021 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup.test.singlessession; 18 | 19 | import static org.assertj.core.api.Assertions.assertThat; 20 | 21 | import org.junit.jupiter.api.BeforeAll; 22 | import org.junit.jupiter.api.Disabled; 23 | import org.junit.jupiter.api.TestTemplate; 24 | import org.junit.jupiter.api.extension.RegisterExtension; 25 | import org.openqa.selenium.WebDriver; 26 | 27 | import io.github.bonigarcia.seljup.BrowserBuilder; 28 | import io.github.bonigarcia.seljup.BrowsersTemplate.Browser; 29 | import io.github.bonigarcia.seljup.SeleniumJupiter; 30 | import io.github.bonigarcia.seljup.SingleSession; 31 | 32 | @SingleSession 33 | @Disabled("Redudant test in CI") 34 | class SingleSessionTemplateRegisterTest { 35 | 36 | @RegisterExtension 37 | static SeleniumJupiter seleniumJupiter = new SeleniumJupiter(); 38 | 39 | @BeforeAll 40 | static void setup() { 41 | Browser chrome = BrowserBuilder.chrome().build(); 42 | Browser firefox = BrowserBuilder.firefox().build(); 43 | seleniumJupiter.addBrowsers(chrome); 44 | seleniumJupiter.addBrowsers(firefox); 45 | } 46 | 47 | @TestTemplate 48 | void templateTest(WebDriver driver) { 49 | driver.get("https://bonigarcia.dev/selenium-webdriver-java/"); 50 | assertThat(driver.getTitle()).contains("Selenium WebDriver"); 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /src/test/java/io/github/bonigarcia/seljup/test/template/BrowserBuilderTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2018 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup.test.template; 18 | 19 | import static io.github.bonigarcia.seljup.BrowserBuilder.chrome; 20 | import static io.github.bonigarcia.seljup.BrowserBuilder.chromeInDocker; 21 | import static io.github.bonigarcia.seljup.BrowserBuilder.edge; 22 | import static io.github.bonigarcia.seljup.BrowserBuilder.firefox; 23 | import static io.github.bonigarcia.seljup.BrowserBuilder.firefoxInDocker; 24 | import static io.github.bonigarcia.seljup.BrowserBuilder.iexplorer; 25 | import static io.github.bonigarcia.seljup.BrowserBuilder.opera; 26 | import static io.github.bonigarcia.seljup.BrowserBuilder.safari; 27 | import static org.assertj.core.api.Assertions.assertThat; 28 | 29 | import java.util.stream.Stream; 30 | 31 | import org.junit.jupiter.params.ParameterizedTest; 32 | import org.junit.jupiter.params.provider.MethodSource; 33 | 34 | import io.github.bonigarcia.seljup.BrowserBuilder; 35 | import io.github.bonigarcia.seljup.BrowsersTemplate.Browser; 36 | 37 | class BrowserBuilderTest { 38 | 39 | static Stream browserBuilderProvider() { 40 | return Stream.of(chrome(), firefox(), opera(), edge(), safari(), 41 | iexplorer(), chromeInDocker(), firefoxInDocker()); 42 | } 43 | 44 | @ParameterizedTest 45 | @MethodSource("browserBuilderProvider") 46 | void templateTest(BrowserBuilder browserBuilder) { 47 | Browser browser = browserBuilder.build(); 48 | assertThat(browser).isNotNull(); 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /src/test/java/io/github/bonigarcia/seljup/test/template/TemplateCapabilitiesTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2021 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup.test.template; 18 | 19 | import static org.assertj.core.api.Assertions.assertThat; 20 | 21 | import org.junit.jupiter.api.BeforeAll; 22 | import org.junit.jupiter.api.TestTemplate; 23 | import org.junit.jupiter.api.extension.RegisterExtension; 24 | import org.openqa.selenium.By; 25 | import org.openqa.selenium.WebDriver; 26 | 27 | import io.github.bonigarcia.seljup.SeleniumJupiter; 28 | 29 | class TemplateCapabilitiesTest { 30 | 31 | @RegisterExtension 32 | static SeleniumJupiter seleniumJupiter = new SeleniumJupiter(); 33 | 34 | @BeforeAll 35 | static void setup() { 36 | seleniumJupiter.getConfig() 37 | .setBrowserTemplateJsonFile("classpath:browsers-caps.json"); 38 | seleniumJupiter.getConfig().enableVnc(); 39 | seleniumJupiter.getConfig().enableRecording(); 40 | } 41 | 42 | @TestTemplate 43 | void templateTest(WebDriver driver) throws InterruptedException { 44 | driver.get( 45 | "https://webrtc.github.io/samples/src/content/devices/input-output/"); 46 | assertThat(driver.findElement(By.id("video")).getTagName()) 47 | .isEqualTo("video"); 48 | 49 | Thread.sleep(2000); 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /src/test/java/io/github/bonigarcia/seljup/test/template/TemplateContentTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2017 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup.test.template; 18 | 19 | import static org.assertj.core.api.Assertions.assertThat; 20 | 21 | import org.junit.jupiter.api.BeforeAll; 22 | import org.junit.jupiter.api.TestTemplate; 23 | import org.junit.jupiter.api.extension.RegisterExtension; 24 | import org.openqa.selenium.WebDriver; 25 | 26 | import io.github.bonigarcia.seljup.SeleniumJupiter; 27 | 28 | class TemplateContentTest { 29 | 30 | @RegisterExtension 31 | static SeleniumJupiter seleniumJupiter = new SeleniumJupiter(); 32 | 33 | @BeforeAll 34 | static void setup() { 35 | seleniumJupiter.getConfig().setBrowserTemplateJsonContent( 36 | "{ \"browsers\": [ [ { \"type\": \"chrome\" } ] ] }"); 37 | } 38 | 39 | @TestTemplate 40 | void templateTest(WebDriver driver) { 41 | driver.get("https://bonigarcia.dev/selenium-webdriver-java/"); 42 | assertThat(driver.getTitle()).contains("Selenium WebDriver"); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/test/java/io/github/bonigarcia/seljup/test/template/TemplateFileTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2017 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup.test.template; 18 | 19 | import static org.assertj.core.api.Assertions.assertThat; 20 | 21 | import org.junit.jupiter.api.BeforeAll; 22 | import org.junit.jupiter.api.TestTemplate; 23 | import org.junit.jupiter.api.extension.RegisterExtension; 24 | import org.openqa.selenium.WebDriver; 25 | 26 | import io.github.bonigarcia.seljup.SeleniumJupiter; 27 | 28 | class TemplateFileTest { 29 | 30 | @RegisterExtension 31 | static SeleniumJupiter seleniumJupiter = new SeleniumJupiter(); 32 | 33 | @BeforeAll 34 | static void setup() { 35 | seleniumJupiter.getConfig().setBrowserTemplateJsonFile( 36 | "./src/test/resources/browsers-mini.json"); 37 | } 38 | 39 | @TestTemplate 40 | void templateTest(WebDriver driver) { 41 | driver.get("https://bonigarcia.dev/selenium-webdriver-java/"); 42 | assertThat(driver.getTitle()).contains("Selenium WebDriver"); 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /src/test/java/io/github/bonigarcia/seljup/test/template/TemplateRegisterOptionsTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2021 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup.test.template; 18 | 19 | import static org.assertj.core.api.Assertions.assertThat; 20 | 21 | import java.time.Duration; 22 | 23 | import org.junit.jupiter.api.BeforeAll; 24 | import org.junit.jupiter.api.TestTemplate; 25 | import org.junit.jupiter.api.extension.RegisterExtension; 26 | import org.openqa.selenium.By; 27 | import org.openqa.selenium.WebDriver; 28 | import org.openqa.selenium.chrome.ChromeOptions; 29 | 30 | import io.github.bonigarcia.seljup.BrowserBuilder; 31 | import io.github.bonigarcia.seljup.Options; 32 | import io.github.bonigarcia.seljup.BrowsersTemplate.Browser; 33 | import io.github.bonigarcia.seljup.SeleniumJupiter; 34 | 35 | class TemplateRegisterOptionsTest { 36 | 37 | @RegisterExtension 38 | static SeleniumJupiter seleniumJupiter = new SeleniumJupiter(); 39 | 40 | @Options 41 | static ChromeOptions chromeOptions = new ChromeOptions(); 42 | 43 | @BeforeAll 44 | static void setup() { 45 | chromeOptions.addArguments("--use-fake-device-for-media-stream", 46 | "--use-fake-ui-for-media-stream"); 47 | 48 | Browser chrome = BrowserBuilder.chrome().build(); 49 | Browser chromeInDocker = BrowserBuilder.chromeInDocker().build(); 50 | seleniumJupiter.addBrowsers(chrome); 51 | seleniumJupiter.addBrowsers(chromeInDocker); 52 | 53 | seleniumJupiter.getConfig().enableScreenshot(); 54 | } 55 | 56 | @TestTemplate 57 | void templateTest(WebDriver driver) throws InterruptedException { 58 | driver.get( 59 | "https://webrtc.github.io/samples/src/content/devices/input-output/"); 60 | assertThat(driver.findElement(By.id("video")).getTagName()) 61 | .isEqualTo("video"); 62 | 63 | Thread.sleep(Duration.ofSeconds(5).toMillis()); 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /src/test/java/io/github/bonigarcia/seljup/test/template/TemplateRegisterRemoteTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2019 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup.test.template; 18 | 19 | import static org.assertj.core.api.Assertions.assertThat; 20 | 21 | import org.junit.jupiter.api.BeforeAll; 22 | import org.junit.jupiter.api.TestTemplate; 23 | import org.junit.jupiter.api.extension.RegisterExtension; 24 | import org.openqa.selenium.WebDriver; 25 | import org.openqa.selenium.grid.Main; 26 | 27 | import io.github.bonigarcia.seljup.BrowserBuilder; 28 | import io.github.bonigarcia.seljup.BrowsersTemplate.Browser; 29 | import io.github.bonigarcia.seljup.DriverUrl; 30 | import io.github.bonigarcia.seljup.SeleniumJupiter; 31 | import io.github.bonigarcia.wdm.WebDriverManager; 32 | 33 | class TemplateRegisterRemoteTest { 34 | 35 | @RegisterExtension 36 | static SeleniumJupiter seleniumJupiter = new SeleniumJupiter(); 37 | 38 | @DriverUrl 39 | String url = "http://localhost:4446/wd/hub"; 40 | 41 | @BeforeAll 42 | static void setup() throws Exception { 43 | // Resolve drivers 44 | WebDriverManager.chromedriver().setup(); 45 | WebDriverManager.firefoxdriver().setup(); 46 | 47 | // Start Selenium Grid in standalone mode 48 | Main.main(new String[] { "standalone", "--port", "4446" }); 49 | 50 | Browser chrome = BrowserBuilder.chrome().build(); 51 | seleniumJupiter.addBrowsers(chrome); 52 | } 53 | 54 | @TestTemplate 55 | void templateTest(WebDriver driver) { 56 | driver.get("https://bonigarcia.dev/selenium-webdriver-java/"); 57 | assertThat(driver.getTitle()).contains("Selenium WebDriver"); 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /src/test/java/io/github/bonigarcia/seljup/test/template/TemplateRegisterTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2018 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup.test.template; 18 | 19 | import static org.assertj.core.api.Assertions.assertThat; 20 | 21 | import org.junit.jupiter.api.BeforeAll; 22 | import org.junit.jupiter.api.TestTemplate; 23 | import org.junit.jupiter.api.extension.RegisterExtension; 24 | import org.openqa.selenium.WebDriver; 25 | 26 | import io.github.bonigarcia.seljup.BrowserBuilder; 27 | import io.github.bonigarcia.seljup.BrowsersTemplate.Browser; 28 | import io.github.bonigarcia.seljup.SeleniumJupiter; 29 | 30 | class TemplateRegisterTest { 31 | 32 | @RegisterExtension 33 | static SeleniumJupiter seleniumJupiter = new SeleniumJupiter(); 34 | 35 | @BeforeAll 36 | static void setup() { 37 | Browser chrome = BrowserBuilder.chrome().build(); 38 | Browser firefox = BrowserBuilder.firefox().build(); 39 | seleniumJupiter.addBrowsers(chrome); 40 | seleniumJupiter.addBrowsers(firefox); 41 | } 42 | 43 | @TestTemplate 44 | void templateTest(WebDriver driver) { 45 | driver.get("https://bonigarcia.dev/selenium-webdriver-java/"); 46 | assertThat(driver.getTitle()).contains("Selenium WebDriver"); 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /src/test/java/io/github/bonigarcia/seljup/test/template/TemplateRemoteTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2018 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup.test.template; 18 | 19 | import static org.assertj.core.api.Assertions.assertThat; 20 | import static org.openqa.selenium.net.PortProber.findFreePort; 21 | 22 | import org.junit.jupiter.api.BeforeAll; 23 | import org.junit.jupiter.api.TestTemplate; 24 | import org.junit.jupiter.api.extension.RegisterExtension; 25 | import org.openqa.selenium.WebDriver; 26 | import org.openqa.selenium.grid.Main; 27 | 28 | import io.github.bonigarcia.seljup.BrowserBuilder; 29 | import io.github.bonigarcia.seljup.BrowsersTemplate.Browser; 30 | import io.github.bonigarcia.seljup.SeleniumJupiter; 31 | import io.github.bonigarcia.wdm.WebDriverManager; 32 | 33 | class TemplateRemoteTest { 34 | 35 | @RegisterExtension 36 | static SeleniumJupiter seleniumJupiter = new SeleniumJupiter(); 37 | 38 | @BeforeAll 39 | static void setup() { 40 | // Resolve drivers 41 | WebDriverManager.chromedriver().setup(); 42 | WebDriverManager.firefoxdriver().setup(); 43 | 44 | // Start Selenium Grid in standalone mode 45 | int port = findFreePort(); 46 | Main.main( 47 | new String[] { "standalone", "--port", String.valueOf(port) }); 48 | 49 | // Register Chrome and Firefox in the browser scenario for the template 50 | String serverUrl = "http://localhost:" + port + "/wd/hub"; 51 | Browser chrome = BrowserBuilder.chrome().remoteUrl(serverUrl).build(); 52 | Browser firefox = BrowserBuilder.firefox().remoteUrl(serverUrl).build(); 53 | seleniumJupiter.addBrowsers(chrome); 54 | seleniumJupiter.addBrowsers(firefox); 55 | } 56 | 57 | @TestTemplate 58 | void templateTest(WebDriver driver) { 59 | driver.get("https://bonigarcia.dev/selenium-webdriver-java/"); 60 | assertThat(driver.getTitle()).contains("Selenium WebDriver"); 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /src/test/java/io/github/bonigarcia/seljup/test/template/TemplateTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2017 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup.test.template; 18 | 19 | //tag::snippet-in-doc[] 20 | import static org.assertj.core.api.Assertions.assertThat; 21 | 22 | import io.github.bonigarcia.seljup.BrowserScenarioTest; 23 | import org.junit.jupiter.api.TestTemplate; 24 | import org.junit.jupiter.api.extension.ExtendWith; 25 | import org.openqa.selenium.WebDriver; 26 | 27 | import io.github.bonigarcia.seljup.SeleniumJupiter; 28 | 29 | @ExtendWith(SeleniumJupiter.class) 30 | class TemplateTest { 31 | 32 | @TestTemplate 33 | void templateTest(WebDriver driver) { 34 | driver.get("https://bonigarcia.dev/selenium-webdriver-java/"); 35 | assertThat(driver.getTitle()).contains("Selenium WebDriver"); 36 | } 37 | 38 | @BrowserScenarioTest(name = "Templated Test Name - {type} {version}") 39 | void namePatternTest(WebDriver driver) { 40 | driver.get("https://bonigarcia.dev/selenium-webdriver-java/"); 41 | assertThat(driver.getTitle()).contains("Selenium WebDriver"); 42 | } 43 | 44 | } 45 | //end::snippet-in-doc[] 46 | -------------------------------------------------------------------------------- /src/test/java/io/github/bonigarcia/seljup/test/template/TemplateTwoBrowsersTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2017 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup.test.template; 18 | 19 | import static org.assertj.core.api.Assertions.assertThat; 20 | 21 | import org.junit.jupiter.api.BeforeAll; 22 | import org.junit.jupiter.api.TestTemplate; 23 | import org.junit.jupiter.api.extension.RegisterExtension; 24 | import org.openqa.selenium.WebDriver; 25 | 26 | import io.github.bonigarcia.seljup.SeleniumJupiter; 27 | 28 | class TemplateTwoBrowsersTest { 29 | 30 | @RegisterExtension 31 | static SeleniumJupiter seleniumJupiter = new SeleniumJupiter(); 32 | 33 | @BeforeAll 34 | static void setup() { 35 | seleniumJupiter.getConfig().setBrowserTemplateJsonFile( 36 | "./src/test/resources/browsers-two.json"); 37 | } 38 | 39 | @TestTemplate 40 | void templateTest(WebDriver driver1, WebDriver driver2) { 41 | driver1.get("https://bonigarcia.dev/selenium-webdriver-java/"); 42 | driver2.get("https://bonigarcia.dev/selenium-webdriver-java/"); 43 | assertThat(driver1.getTitle()).contains("Selenium WebDriver"); 44 | assertThat(driver2.getTitle()).contains("Selenium WebDriver"); 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /src/test/java/io/github/bonigarcia/seljup/test/watcher/DisableCspFirefoxTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2022 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup.test.watcher; 18 | 19 | //tag::snippet-in-doc[] 20 | import static org.assertj.core.api.Assertions.assertThat; 21 | 22 | import java.util.List; 23 | import java.util.Map; 24 | 25 | import org.junit.jupiter.api.Test; 26 | import org.junit.jupiter.api.extension.RegisterExtension; 27 | import org.openqa.selenium.firefox.FirefoxDriver; 28 | 29 | import io.github.bonigarcia.seljup.SeleniumJupiter; 30 | import io.github.bonigarcia.seljup.Watch; 31 | 32 | class DisableCspFirefoxTest { 33 | 34 | @RegisterExtension 35 | static SeleniumJupiter seleniumJupiter = new SeleniumJupiter(); 36 | 37 | @Test 38 | void test(@Watch(disableCsp = true) FirefoxDriver driver) { 39 | driver.get("https://paypal.com/"); 40 | List> logMessages = seleniumJupiter.getLogs(); 41 | assertThat(logMessages).isNotNull(); 42 | } 43 | 44 | } 45 | //end::snippet-in-doc[] 46 | -------------------------------------------------------------------------------- /src/test/java/io/github/bonigarcia/seljup/test/watcher/DisplayLogsFirefoxTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2022 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup.test.watcher; 18 | 19 | //tag::snippet-in-doc[] 20 | import static java.lang.invoke.MethodHandles.lookup; 21 | import static org.assertj.core.api.Assertions.assertThat; 22 | import static org.slf4j.LoggerFactory.getLogger; 23 | 24 | import java.time.Duration; 25 | import java.util.List; 26 | import java.util.Map; 27 | 28 | import org.junit.jupiter.api.AfterEach; 29 | import org.junit.jupiter.api.Test; 30 | import org.junit.jupiter.api.extension.RegisterExtension; 31 | import org.openqa.selenium.firefox.FirefoxDriver; 32 | import org.slf4j.Logger; 33 | 34 | import io.github.bonigarcia.seljup.SeleniumJupiter; 35 | import io.github.bonigarcia.seljup.Watch; 36 | 37 | class DisplayLogsFirefoxTest { 38 | 39 | static final Logger log = getLogger(lookup().lookupClass()); 40 | 41 | @RegisterExtension 42 | static SeleniumJupiter seleniumJupiter = new SeleniumJupiter(); 43 | 44 | @AfterEach 45 | void teardown() throws InterruptedException { 46 | // pause for manual browser inspection 47 | Thread.sleep(Duration.ofSeconds(3).toMillis()); 48 | } 49 | 50 | @Test 51 | void test(@Watch(display = true) FirefoxDriver driver) { 52 | driver.get( 53 | "https://bonigarcia.dev/selenium-webdriver-java/console-logs.html"); 54 | 55 | List> logMessages = seleniumJupiter.getLogs(); 56 | 57 | assertThat(logMessages).hasSize(5); 58 | 59 | logMessages.forEach(map -> log.debug("[{}] [{}] {}", 60 | map.get("datetime"), 61 | String.format("%1$-14s", 62 | map.get("source").toString().toUpperCase() + "." 63 | + map.get("type").toString().toUpperCase()), 64 | map.get("message"))); 65 | } 66 | 67 | } 68 | //end::snippet-in-doc[] 69 | -------------------------------------------------------------------------------- /src/test/java/io/github/bonigarcia/seljup/test/watcher/GatherLogsFirefoxTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2022 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup.test.watcher; 18 | 19 | //tag::snippet-in-doc[] 20 | import static java.lang.invoke.MethodHandles.lookup; 21 | import static org.assertj.core.api.Assertions.assertThat; 22 | import static org.slf4j.LoggerFactory.getLogger; 23 | 24 | import java.util.List; 25 | import java.util.Map; 26 | 27 | import org.junit.jupiter.api.Test; 28 | import org.junit.jupiter.api.extension.RegisterExtension; 29 | import org.openqa.selenium.firefox.FirefoxDriver; 30 | import org.slf4j.Logger; 31 | 32 | import io.github.bonigarcia.seljup.SeleniumJupiter; 33 | import io.github.bonigarcia.seljup.Watch; 34 | 35 | class GatherLogsFirefoxTest { 36 | 37 | static final Logger log = getLogger(lookup().lookupClass()); 38 | 39 | @RegisterExtension 40 | static SeleniumJupiter seleniumJupiter = new SeleniumJupiter(); 41 | 42 | @Test 43 | void test(@Watch FirefoxDriver driver) { 44 | driver.get( 45 | "https://bonigarcia.dev/selenium-webdriver-java/console-logs.html"); 46 | 47 | List> logMessages = seleniumJupiter.getLogs(); 48 | 49 | assertThat(logMessages).hasSize(5); 50 | 51 | logMessages.forEach(map -> log.debug("[{}] [{}] {}", 52 | map.get("datetime"), 53 | String.format("%1$-14s", 54 | map.get("source").toString().toUpperCase() + "." 55 | + map.get("type").toString().toUpperCase()), 56 | map.get("message"))); 57 | } 58 | 59 | } 60 | //end::snippet-in-doc[] 61 | -------------------------------------------------------------------------------- /src/test/java/io/github/bonigarcia/seljup/test/watcher/RecordChromeTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * (C) Copyright 2022 Boni Garcia (https://bonigarcia.github.io/) 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | * 16 | */ 17 | package io.github.bonigarcia.seljup.test.watcher; 18 | 19 | //tag::snippet-in-doc[] 20 | import static java.lang.invoke.MethodHandles.lookup; 21 | import static org.assertj.core.api.Assertions.assertThat; 22 | import static org.slf4j.LoggerFactory.getLogger; 23 | 24 | import java.nio.file.Path; 25 | import java.time.Duration; 26 | 27 | import org.junit.jupiter.api.Test; 28 | import org.junit.jupiter.api.extension.RegisterExtension; 29 | import org.openqa.selenium.By; 30 | import org.openqa.selenium.chrome.ChromeDriver; 31 | import org.openqa.selenium.support.ui.ExpectedConditions; 32 | import org.openqa.selenium.support.ui.WebDriverWait; 33 | import org.slf4j.Logger; 34 | 35 | import io.github.bonigarcia.seljup.SeleniumJupiter; 36 | import io.github.bonigarcia.seljup.Watch; 37 | 38 | class RecordChromeTest { 39 | 40 | static final Logger log = getLogger(lookup().lookupClass()); 41 | 42 | @RegisterExtension 43 | static SeleniumJupiter seleniumJupiter = new SeleniumJupiter(); 44 | 45 | @Test 46 | void test(@Watch ChromeDriver driver) { 47 | driver.get( 48 | "https://bonigarcia.dev/selenium-webdriver-java/slow-calculator.html"); 49 | 50 | seleniumJupiter.startRecording(); 51 | 52 | // 1 + 3 53 | driver.findElement(By.xpath("//span[text()='1']")).click(); 54 | driver.findElement(By.xpath("//span[text()='+']")).click(); 55 | driver.findElement(By.xpath("//span[text()='3']")).click(); 56 | driver.findElement(By.xpath("//span[text()='=']")).click(); 57 | 58 | // ... should be 4, wait for it 59 | WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10)); 60 | wait.until(ExpectedConditions.textToBe(By.className("screen"), "4")); 61 | 62 | seleniumJupiter.stopRecording(); 63 | 64 | Path recordingPath = seleniumJupiter.getRecordingPath(); 65 | assertThat(recordingPath).exists(); 66 | 67 | log.debug("Recording available at {}", recordingPath); 68 | } 69 | 70 | } 71 | //end::snippet-in-doc[] -------------------------------------------------------------------------------- /src/test/resources/browsers-caps.json: -------------------------------------------------------------------------------- 1 | { 2 | "browsers": [ 3 | [ 4 | { 5 | "type": "chrome-in-docker", 6 | "arguments" : [ 7 | "--use-fake-device-for-media-stream", 8 | "--use-fake-ui-for-media-stream" 9 | ], 10 | "capabilities" : { 11 | "custom:cap-1": "custom-value-1", 12 | "custom:cap-2": "custom-value-2", 13 | "custom:cap-3": true 14 | } 15 | } 16 | ], 17 | [ 18 | { 19 | "type": "firefox-in-docker", 20 | "preferences" : [ 21 | "media.navigator.permission.disabled=true", 22 | "media.navigator.streams.fake=true" 23 | ] 24 | } 25 | ] 26 | ] 27 | } 28 | -------------------------------------------------------------------------------- /src/test/resources/browsers-mini.json: -------------------------------------------------------------------------------- 1 | { 2 | "browsers": [ 3 | [ 4 | { 5 | "type": "chrome" 6 | } 7 | ] 8 | ] 9 | } 10 | -------------------------------------------------------------------------------- /src/test/resources/browsers-selenide.json: -------------------------------------------------------------------------------- 1 | { 2 | "browsers": [ 3 | [ 4 | { 5 | "type": "chrome-in-selenide" 6 | } 7 | ], 8 | [ 9 | { 10 | "type": "firefox-in-selenide" 11 | } 12 | ], 13 | [ 14 | { 15 | "type": "chrome-in-selenide-in-docker" 16 | } 17 | ] 18 | ] 19 | } -------------------------------------------------------------------------------- /src/test/resources/browsers-two.json: -------------------------------------------------------------------------------- 1 | { 2 | "browsers": [ 3 | [ 4 | { 5 | "type": "chrome-in-docker" 6 | }, 7 | { 8 | "type": "firefox-in-docker" 9 | } 10 | ] 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /src/test/resources/browsers.json: -------------------------------------------------------------------------------- 1 | { 2 | "browsers": [ 3 | [ 4 | { 5 | "type": "chrome-in-docker", 6 | "version": "latest" 7 | } 8 | ], 9 | [ 10 | { 11 | "type": "chrome-in-docker", 12 | "version": "latest-1" 13 | } 14 | ], 15 | [ 16 | { 17 | "type": "chrome-in-docker", 18 | "version": "beta" 19 | } 20 | ], 21 | [ 22 | { 23 | "type": "chrome-in-docker", 24 | "version": "dev", 25 | "arguments": [ 26 | "--disable-gpu", 27 | "--no-sandbox" 28 | ] 29 | } 30 | ] 31 | ] 32 | } 33 | -------------------------------------------------------------------------------- /src/test/resources/dark-bg.crx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bonigarcia/selenium-jupiter/dd202cf2d62f3e5ba09b8a77212222f6ed7841ff/src/test/resources/dark-bg.crx -------------------------------------------------------------------------------- /src/test/resources/dark-bg.xpi: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bonigarcia/selenium-jupiter/dd202cf2d62f3e5ba09b8a77212222f6ed7841ff/src/test/resources/dark-bg.xpi -------------------------------------------------------------------------------- /src/test/resources/logback-test.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | %d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36}.%M\(%line\) -- %msg%n 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | --------------------------------------------------------------------------------