Skip to content

Commit

Permalink
[wdc] Sync wdc:2.1.0 for Selenium 3
Browse files Browse the repository at this point in the history
  • Loading branch information
ngoanh2n committed Aug 20, 2022
1 parent 9f8ce69 commit eb0ecbf
Show file tree
Hide file tree
Showing 9 changed files with 369 additions and 132 deletions.
27 changes: 21 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,19 @@
[![License: MIT](https://img.shields.io/badge/License-MIT-blueviolet.svg)](https://opensource.org/licenses/MIT)

# WebDriverChecker
You are writing automation test scripts for multiple browsers such as:
- Chrome, Safari.. on PC
- Safari & native app on iOS
- Chrome & native app on Android

And somewhere, you have to check type of browser or platform to navigate your scripts.

Use WebDriverChecker to make it more convenient!

## Gradle Project
Add to `build.gradle`
```gradle
implementation("com.github.ngoanh2n:webdriverchecker:1.2.0")
implementation("com.github.ngoanh2n:webdriverchecker:1.3.0")
```

## Maven Project
Expand All @@ -21,15 +30,15 @@ Add to `pom.xml`
<dependency>
<groupId>com.github.ngoanh2n</groupId>
<artifactId>webdriverchecker</artifactId>
<version>1.2.0</version>
<version>1.3.0</version>
</dependency>
```

# WebDriverChecker for Selenide
## Gradle Project
Add to `build.gradle`
```gradle
implementation("com.github.ngoanh2n:webdriverchecker-selenide:1.2.0")
implementation("com.github.ngoanh2n:webdriverchecker-selenide:1.3.0")
```

## Maven Project
Expand All @@ -38,12 +47,14 @@ Add to `pom.xml`
<dependency>
<groupId>com.github.ngoanh2n</groupId>
<artifactId>webdriverchecker-selenide</artifactId>
<version>1.2.0</version>
<version>1.3.0</version>
</dependency>
```

# Usages
```java
WebDriverChecker.isAlive()

WebDriverChecker.isChrome()
WebDriverChecker.isSafari()
WebDriverChecker.isFirefox()
Expand All @@ -65,9 +76,13 @@ WebDriverChecker.isMobile()
WebDriverChecker.isMobileWeb()
WebDriverChecker.isMobileNative()

WebDriverChecker.isPC()
WebDriverChecker.isPCWeb()
WebDriverChecker.isPCNative()

WebDriverChecker.isMacOSNative()
WebDriverChecker.isWindowsNative()

WebDriverChecker.isEdgeLegacy()
WebDriverChecker.isFirefoxLegacy()

WebDriverChecker.isAlive()
```
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.codeborne.selenide.Configuration;
import com.codeborne.selenide.Selenide;
import com.codeborne.selenide.WebDriverRunner;
import com.github.ngoanh2n.ExecuteOnTarget;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
Expand All @@ -19,11 +20,13 @@
"ios-native",
"ios-safari",
"android-native",
"android-chrome"
"android-chrome",
"mac-native"
})
public class AppiumTest {
@BeforeEach
void openDriver() {
System.setProperty("ngoanh2n.caps", "macos-native.yml");
Configuration.timeout = 10 * 1000;
Configuration.pollingInterval = 500;
Configuration.browserSize = null;
Expand All @@ -33,12 +36,14 @@ void openDriver() {

@AfterEach
void closeDriver() {
Selenide.closeWebDriver();
WebDriverRunner.closeWebDriver();
}

@Test
@ExecuteOnTarget("ios-native")
void iosNative() {
assertTrue(WebDriverChecker.isAlive());

assertFalse(WebDriverChecker.isChrome());
assertFalse(WebDriverChecker.isSafari());
assertFalse(WebDriverChecker.isFirefox());
Expand All @@ -60,14 +65,22 @@ void iosNative() {
assertFalse(WebDriverChecker.isMobileWeb());
assertTrue(WebDriverChecker.isMobileNative());

assertFalse(WebDriverChecker.isPC());
assertFalse(WebDriverChecker.isPCWeb());
assertFalse(WebDriverChecker.isPCNative());

assertFalse(WebDriverChecker.isMacOSNative());
assertFalse(WebDriverChecker.isWindowsNative());

assertFalse(WebDriverChecker.isEdgeLegacy());
assertFalse(WebDriverChecker.isFirefoxLegacy());
}

@Test
@ExecuteOnTarget("ios-safari")
void iosSafari() {
assertTrue(WebDriverChecker.isAlive());

assertFalse(WebDriverChecker.isChrome());
assertTrue(WebDriverChecker.isSafari());
assertFalse(WebDriverChecker.isFirefox());
Expand All @@ -89,14 +102,22 @@ void iosSafari() {
assertTrue(WebDriverChecker.isMobileWeb());
assertFalse(WebDriverChecker.isMobileNative());

assertFalse(WebDriverChecker.isPC());
assertFalse(WebDriverChecker.isPCWeb());
assertFalse(WebDriverChecker.isPCNative());

assertFalse(WebDriverChecker.isMacOSNative());
assertFalse(WebDriverChecker.isWindowsNative());

assertFalse(WebDriverChecker.isEdgeLegacy());
assertFalse(WebDriverChecker.isFirefoxLegacy());
}

@Test
@ExecuteOnTarget("android-native")
void androidNative() {
assertTrue(WebDriverChecker.isAlive());

assertFalse(WebDriverChecker.isChrome());
assertFalse(WebDriverChecker.isSafari());
assertFalse(WebDriverChecker.isFirefox());
Expand All @@ -118,14 +139,22 @@ void androidNative() {
assertFalse(WebDriverChecker.isMobileWeb());
assertTrue(WebDriverChecker.isMobileNative());

assertFalse(WebDriverChecker.isPC());
assertFalse(WebDriverChecker.isPCWeb());
assertFalse(WebDriverChecker.isPCNative());

assertFalse(WebDriverChecker.isMacOSNative());
assertFalse(WebDriverChecker.isWindowsNative());

assertFalse(WebDriverChecker.isEdgeLegacy());
assertFalse(WebDriverChecker.isFirefoxLegacy());
}

@Test
@ExecuteOnTarget("android-chrome")
void androidChrome() {
assertTrue(WebDriverChecker.isAlive());

assertTrue(WebDriverChecker.isChrome());
assertFalse(WebDriverChecker.isSafari());
assertFalse(WebDriverChecker.isFirefox());
Expand All @@ -147,7 +176,50 @@ void androidChrome() {
assertTrue(WebDriverChecker.isMobileWeb());
assertFalse(WebDriverChecker.isMobileNative());

assertFalse(WebDriverChecker.isPC());
assertFalse(WebDriverChecker.isPCWeb());
assertFalse(WebDriverChecker.isPCNative());

assertFalse(WebDriverChecker.isMacOSNative());
assertFalse(WebDriverChecker.isWindowsNative());

assertFalse(WebDriverChecker.isEdgeLegacy());
assertFalse(WebDriverChecker.isFirefoxLegacy());
}

@Test
@ExecuteOnTarget("macos-native")
void macOSNative() {
assertTrue(WebDriverChecker.isAlive());

assertFalse(WebDriverChecker.isChrome());
assertFalse(WebDriverChecker.isSafari());
assertFalse(WebDriverChecker.isFirefox());
assertFalse(WebDriverChecker.isEdge());
assertFalse(WebDriverChecker.isOpera());
assertFalse(WebDriverChecker.isIE());

assertFalse(WebDriverChecker.isIOS());
assertFalse(WebDriverChecker.isIOSWeb());
assertFalse(WebDriverChecker.isIOSSafari());
assertFalse(WebDriverChecker.isIOSNative());

assertFalse(WebDriverChecker.isAndroid());
assertFalse(WebDriverChecker.isAndroidWeb());
assertFalse(WebDriverChecker.isAndroidChrome());
assertFalse(WebDriverChecker.isAndroidNative());

assertFalse(WebDriverChecker.isMobile());
assertFalse(WebDriverChecker.isMobileWeb());
assertFalse(WebDriverChecker.isMobileNative());

assertTrue(WebDriverChecker.isPC());
assertFalse(WebDriverChecker.isPCWeb());
assertTrue(WebDriverChecker.isPCNative());

assertTrue(WebDriverChecker.isMacOSNative());
assertFalse(WebDriverChecker.isWindowsNative());

assertFalse(WebDriverChecker.isEdgeLegacy());
assertFalse(WebDriverChecker.isFirefoxLegacy());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ void closeDriver() {
@Test
@ExecuteOnTarget("chrome")
void isChrome() {
assertTrue(WebDriverChecker.isAlive());

assertTrue(WebDriverChecker.isChrome());
assertFalse(WebDriverChecker.isSafari());
assertFalse(WebDriverChecker.isFirefox());
Expand All @@ -52,14 +54,22 @@ void isChrome() {
assertFalse(WebDriverChecker.isMobileWeb());
assertFalse(WebDriverChecker.isMobileNative());

assertTrue(WebDriverChecker.isPC());
assertTrue(WebDriverChecker.isPCWeb());
assertFalse(WebDriverChecker.isPCNative());

assertFalse(WebDriverChecker.isMacOSNative());
assertFalse(WebDriverChecker.isWindowsNative());

assertFalse(WebDriverChecker.isEdgeLegacy());
assertFalse(WebDriverChecker.isFirefoxLegacy());
}

@Test
@ExecuteOnTarget("safari")
void isSafari() {
assertTrue(WebDriverChecker.isAlive());

assertFalse(WebDriverChecker.isChrome());
assertTrue(WebDriverChecker.isSafari());
assertFalse(WebDriverChecker.isFirefox());
Expand All @@ -81,14 +91,22 @@ void isSafari() {
assertFalse(WebDriverChecker.isMobileWeb());
assertFalse(WebDriverChecker.isMobileNative());

assertTrue(WebDriverChecker.isPC());
assertTrue(WebDriverChecker.isPCWeb());
assertFalse(WebDriverChecker.isPCNative());

assertFalse(WebDriverChecker.isMacOSNative());
assertFalse(WebDriverChecker.isWindowsNative());

assertFalse(WebDriverChecker.isEdgeLegacy());
assertFalse(WebDriverChecker.isFirefoxLegacy());
}

@Test
@ExecuteOnTarget("firefox")
void isFirefox() {
assertTrue(WebDriverChecker.isAlive());

assertFalse(WebDriverChecker.isChrome());
assertFalse(WebDriverChecker.isSafari());
assertTrue(WebDriverChecker.isFirefox());
Expand All @@ -110,14 +128,22 @@ void isFirefox() {
assertFalse(WebDriverChecker.isMobileWeb());
assertFalse(WebDriverChecker.isMobileNative());

assertTrue(WebDriverChecker.isPC());
assertTrue(WebDriverChecker.isPCWeb());
assertFalse(WebDriverChecker.isPCNative());

assertFalse(WebDriverChecker.isMacOSNative());
assertFalse(WebDriverChecker.isWindowsNative());

assertFalse(WebDriverChecker.isEdgeLegacy());
assertFalse(WebDriverChecker.isFirefoxLegacy());
}

@Test
@ExecuteOnTarget("edge")
void isEdge() {
assertTrue(WebDriverChecker.isAlive());

assertFalse(WebDriverChecker.isChrome());
assertFalse(WebDriverChecker.isSafari());
assertFalse(WebDriverChecker.isFirefox());
Expand All @@ -139,14 +165,22 @@ void isEdge() {
assertFalse(WebDriverChecker.isMobileWeb());
assertFalse(WebDriverChecker.isMobileNative());

assertTrue(WebDriverChecker.isPC());
assertTrue(WebDriverChecker.isPCWeb());
assertFalse(WebDriverChecker.isPCNative());

assertFalse(WebDriverChecker.isMacOSNative());
assertFalse(WebDriverChecker.isWindowsNative());

assertFalse(WebDriverChecker.isEdgeLegacy());
assertFalse(WebDriverChecker.isFirefoxLegacy());
}

@Test
@ExecuteOnTarget("opera")
void isOpera() {
assertTrue(WebDriverChecker.isAlive());

assertFalse(WebDriverChecker.isChrome());
assertFalse(WebDriverChecker.isSafari());
assertFalse(WebDriverChecker.isFirefox());
Expand All @@ -168,14 +202,22 @@ void isOpera() {
assertFalse(WebDriverChecker.isMobileWeb());
assertFalse(WebDriverChecker.isMobileNative());

assertTrue(WebDriverChecker.isPC());
assertTrue(WebDriverChecker.isPCWeb());
assertFalse(WebDriverChecker.isPCNative());

assertFalse(WebDriverChecker.isMacOSNative());
assertFalse(WebDriverChecker.isWindowsNative());

assertFalse(WebDriverChecker.isEdgeLegacy());
assertFalse(WebDriverChecker.isFirefoxLegacy());
}

@Test
@ExecuteOnTarget("ie")
void isIE() {
assertTrue(WebDriverChecker.isAlive());

assertFalse(WebDriverChecker.isChrome());
assertFalse(WebDriverChecker.isSafari());
assertFalse(WebDriverChecker.isFirefox());
Expand All @@ -197,7 +239,13 @@ void isIE() {
assertFalse(WebDriverChecker.isMobileWeb());
assertFalse(WebDriverChecker.isMobileNative());

assertTrue(WebDriverChecker.isPC());
assertTrue(WebDriverChecker.isPCWeb());
assertFalse(WebDriverChecker.isPCNative());

assertFalse(WebDriverChecker.isMacOSNative());
assertFalse(WebDriverChecker.isWindowsNative());

assertFalse(WebDriverChecker.isEdgeLegacy());
assertFalse(WebDriverChecker.isFirefoxLegacy());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ log4j.appender.STDOUT.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n

# Redirect log messages to a log file, support file rolling.
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=build/csv-comparator.log
log4j.appender.file.File=build/wdc.log
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{dd-MM-yyyy HH:mm:ss} %-5p %c{1}:%L - %m%n
3 changes: 3 additions & 0 deletions webdriverchecker-selenide/src/test/resources/macos-native.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
platformName: mac
deviceName: mac
app: Activity Monitor
Loading

0 comments on commit eb0ecbf

Please sign in to comment.