Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Appium client 8.0.0 #114

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion maqs-appium/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<MobileHubUrl>http://ondemand.saucelabs.com:80/wd/hub</MobileHubUrl>

<!-- Command time-out in milliseconds -->
<MobileCommandTimeout>122000</MobileCommandTimeout>
<MobileCommandTimeout>200000</MobileCommandTimeout>

<!-- Wait time in milliseconds - AKA how long do you wait for rechecking something -->
<MobileWaitTime>1000</MobileWaitTime>
Expand Down
20 changes: 10 additions & 10 deletions maqs-appium/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<appiumjavaclient.version>7.6.0</appiumjavaclient.version>
<appiumjavaclient.version>8.2.0</appiumjavaclient.version>
</properties>

<dependencies>
Expand All @@ -29,12 +29,17 @@
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-api</artifactId>
<version>${seleniumAppium.version}</version>
<version>${selenium.version}</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-remote-driver</artifactId>
<version>${seleniumAppium.version}</version>
<version>${selenium.version}</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>${selenium.version}</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
Expand All @@ -51,19 +56,14 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.32</version>
<version>${slf4j.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.32</version>
<version>${slf4j.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>${seleniumAppium.version}</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public static URL getMobileHubUrl() {
*/
public static Duration getCommandTimeout() {
String value = Config.getValueForSection(APPIUM_SECTION, "MobileCommandTimeout", "60000");
int timeoutValue;
long timeoutValue;
try {
timeoutValue = Integer.parseInt(value);
} catch (NumberFormatException ex) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@
import java.time.Duration;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;
import java.util.function.Supplier;
import org.openqa.selenium.WebDriverException;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;

Expand All @@ -39,7 +37,7 @@ private AppiumDriverFactory() {
*
* @return the default mobile driver
*/
public static AppiumDriver<WebElement> getDefaultMobileDriver() {
public static AppiumDriver getDefaultMobileDriver() {
return getDefaultMobileDriver(AppiumConfig.getDeviceType());
}

Expand All @@ -49,8 +47,8 @@ public static AppiumDriver<WebElement> getDefaultMobileDriver() {
* @param deviceType the device type
* @return the default mobile driver
*/
public static AppiumDriver<WebElement> getDefaultMobileDriver(PlatformType deviceType) {
AppiumDriver<WebElement> appiumDriver;
public static AppiumDriver getDefaultMobileDriver(PlatformType deviceType) {
AppiumDriver appiumDriver;
URL mobileHubUrl = AppiumConfig.getMobileHubUrl();
Duration duration = AppiumConfig.getCommandTimeout();
DesiredCapabilities capabilities = getDefaultMobileOptions();
Expand All @@ -71,8 +69,8 @@ public static AppiumDriver<WebElement> getDefaultMobileDriver(PlatformType devic
}

if (deviceType != PlatformType.WINDOWS) {
appiumDriver.manage().timeouts()
.implicitlyWait(AppiumConfig.getMobileTimeout().toMillis(), TimeUnit.MILLISECONDS);
appiumDriver.manage().timeouts().implicitlyWait(
Duration.ofMillis(AppiumConfig.getMobileTimeout().toMillis()));
}

return appiumDriver;
Expand Down Expand Up @@ -109,12 +107,10 @@ public static DesiredCapabilities getDefaultMobileOptions(Map<String, Object> ca
* @param timeout the timeout
* @return the android driver
*/
public static AppiumDriver<WebElement> getAndroidDriver(URL mobileHub, DesiredCapabilities options,
Duration timeout) {

public static AppiumDriver getAndroidDriver(URL mobileHub, DesiredCapabilities options, Duration timeout) {
return createDriver(() -> {
AppiumDriver<WebElement> driver = new AndroidDriver<>(mobileHub, options);
driver.manage().timeouts().implicitlyWait(timeout.toMillis(), TimeUnit.MILLISECONDS);
AppiumDriver driver = new AndroidDriver(mobileHub, options);
driver.manage().timeouts().implicitlyWait(Duration.ofMillis(timeout.toMillis()));
return driver;
});
}
Expand All @@ -127,10 +123,10 @@ public static AppiumDriver<WebElement> getAndroidDriver(URL mobileHub, DesiredCa
* @param timeout the timeout
* @return the ios driver
*/
public static AppiumDriver<WebElement> getIosDriver(URL mobileHub, DesiredCapabilities options, Duration timeout) {
public static AppiumDriver getIosDriver(URL mobileHub, DesiredCapabilities options, Duration timeout) {
return createDriver(() -> {
AppiumDriver<WebElement> driver = new IOSDriver<>(mobileHub, options);
driver.manage().timeouts().implicitlyWait(timeout.toMillis(), TimeUnit.MILLISECONDS);
AppiumDriver driver = new IOSDriver(mobileHub, options);
driver.manage().timeouts().implicitlyWait(Duration.ofMillis(timeout.toMillis()));
return driver;
});
}
Expand All @@ -143,11 +139,11 @@ public static AppiumDriver<WebElement> getIosDriver(URL mobileHub, DesiredCapabi
* @param timeout the timeout
* @return the Windows driver
*/
public static AppiumDriver<WebElement> getWindowsDriver(URL mobileHub, DesiredCapabilities options,
public static AppiumDriver getWindowsDriver(URL mobileHub, DesiredCapabilities options,
Duration timeout) {
return createDriver(() -> {
AppiumDriver<WebElement> driver = new WindowsDriver<>(mobileHub, options);
driver.manage().timeouts().implicitlyWait(timeout.toMillis(), TimeUnit.MILLISECONDS);
AppiumDriver driver = new WindowsDriver(mobileHub, options);
driver.manage().timeouts().implicitlyWait(Duration.ofMillis(timeout.toMillis()));
return driver;
});

Expand All @@ -162,9 +158,7 @@ public static AppiumDriver<WebElement> getWindowsDriver(URL mobileHub, DesiredCa
*/
public static DesiredCapabilities mergeCapabilities(DesiredCapabilities capabilities,
Map<String, Object> capabilitiesAsObjects) {

Consumer<String> mergeConsumer = (String s) -> capabilities
.setCapability(s, capabilitiesAsObjects.get(s));
Consumer<String> mergeConsumer = (String s) -> capabilities.setCapability(s, capabilitiesAsObjects.get(s));
capabilitiesAsObjects.keySet().iterator().forEachRemaining(mergeConsumer);
return capabilities;
}
Expand All @@ -175,9 +169,8 @@ public static DesiredCapabilities mergeCapabilities(DesiredCapabilities capabili
* @param createFunction the create function
* @return the appium driver
*/
public static AppiumDriver<WebElement> createDriver(
Supplier<AppiumDriver<WebElement>> createFunction) {
AppiumDriver<WebElement> appiumDriver = null;
public static AppiumDriver createDriver(Supplier<AppiumDriver> createFunction) {
AppiumDriver appiumDriver = null;

try {
appiumDriver = createFunction.get();
Expand All @@ -187,7 +180,7 @@ public static AppiumDriver<WebElement> createDriver(
throw e;
} else {
try {
Optional<AppiumDriver<WebElement>> driverOptional = Optional.ofNullable(appiumDriver);
Optional<AppiumDriver> driverOptional = Optional.ofNullable(appiumDriver);
driverOptional.ifPresent(AppiumDriver::quit);
} catch (Exception quitException) {
throw new WebDriverException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import com.cognizantsoftvision.maqs.utilities.logging.ILogger;
import io.appium.java_client.AppiumDriver;
import java.util.function.Supplier;
import org.openqa.selenium.WebElement;

/**
* The Appium Test Object class.
Expand All @@ -22,7 +21,7 @@ public class AppiumTestObject extends BaseTestObject implements IAppiumTestObjec
* @param logger the logger
* @param fullyQualifiedTestName the fully qualified test name
*/
public AppiumTestObject(AppiumDriver<WebElement> appiumDriver, ILogger logger,
public AppiumTestObject(AppiumDriver appiumDriver, ILogger logger,
String fullyQualifiedTestName) {
this(() -> appiumDriver, logger, fullyQualifiedTestName);
}
Expand All @@ -34,17 +33,17 @@ public AppiumTestObject(AppiumDriver<WebElement> appiumDriver, ILogger logger,
* @param logger the logger
* @param fullyQualifiedTestName the fully qualified test name
*/
public AppiumTestObject(Supplier<AppiumDriver<WebElement>> appiumDriverSupplier, ILogger logger,
public AppiumTestObject(Supplier<AppiumDriver> appiumDriverSupplier, ILogger logger,
String fullyQualifiedTestName) {
super(logger, fullyQualifiedTestName);
this.getManagerStore().put(MobileDriverManager.class.getCanonicalName(),
new MobileDriverManager(appiumDriverSupplier, this));
new MobileDriverManager(appiumDriverSupplier.get(), this));
}

/**
* {@inheritDoc}
*/
public AppiumDriver<WebElement> getAppiumDriver() {
public AppiumDriver getAppiumDriver() {
return this.getAppiumManager().getMobileDriver();
}

Expand All @@ -59,16 +58,16 @@ public MobileDriverManager getAppiumManager() {
/**
* {@inheritDoc}
*/
public void setAppiumDriver(AppiumDriver<WebElement> appiumDriver) {
public void setAppiumDriver(AppiumDriver appiumDriver) {
this.getManagerStore().put(MobileDriverManager.class.getCanonicalName(),
new MobileDriverManager((() -> appiumDriver), this));
}

/**
* {@inheritDoc}
*/
public void setAppiumDriver(Supplier<AppiumDriver<WebElement>> appiumDriverSupplier) {
public void setAppiumDriver(Supplier<AppiumDriver> appiumDriverSupplier) {
this.getManagerStore().put(MobileDriverManager.class.getCanonicalName(),
new MobileDriverManager(appiumDriverSupplier, this));
new MobileDriverManager(appiumDriverSupplier.get(), this));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import java.time.format.DateTimeFormatter;
import java.util.Locale;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.WebElement;

/**
* The Appium Utilities class.
Expand Down Expand Up @@ -51,7 +50,7 @@ private AppiumUtilities() {
* @param testObject The Test Object to associate the screenshot.
* @return True if the image was saved successfully, otherwise false.
*/
public static boolean captureScreenshot(AppiumDriver<WebElement> appiumDriver,
public static boolean captureScreenshot(AppiumDriver appiumDriver,
AppiumTestObject testObject) {
return captureScreenshot(appiumDriver, testObject, "");
}
Expand All @@ -64,7 +63,7 @@ public static boolean captureScreenshot(AppiumDriver<WebElement> appiumDriver,
* @param appendName The Name to append
* @return True if the image was saved successfully, otherwise false.
*/
public static boolean captureScreenshot(AppiumDriver<WebElement> appiumDriver,
public static boolean captureScreenshot(AppiumDriver appiumDriver,
AppiumTestObject testObject, String appendName) {
try {
// Check if we are using a file logger. If not, return false.
Expand Down Expand Up @@ -98,7 +97,7 @@ public static boolean captureScreenshot(AppiumDriver<WebElement> appiumDriver,
* @param fileNameWithoutExtension File Name Without Extension
* @return Path to Screenshot.
*/
public static String captureScreenshot(AppiumDriver<WebElement> appiumDriver,
public static String captureScreenshot(AppiumDriver appiumDriver,
AppiumTestObject testObject, String directory, String fileNameWithoutExtension) {
File tempFile = appiumDriver.getScreenshotAs(OutputType.FILE);
String path = Paths.get(directory, fileNameWithoutExtension + ".png").normalize().toString();
Expand Down Expand Up @@ -134,7 +133,7 @@ public static String captureScreenshot(AppiumDriver<WebElement> appiumDriver,
* @param testObject The Appium Test Object
* @return True if saving page source is successful, otherwise false
*/
public static boolean savePageSource(AppiumDriver<WebElement> appiumDriver,
public static boolean savePageSource(AppiumDriver appiumDriver,
AppiumTestObject testObject) {
return savePageSource(appiumDriver, testObject, "");
}
Expand All @@ -147,7 +146,7 @@ public static boolean savePageSource(AppiumDriver<WebElement> appiumDriver,
* @param appendName Appends a name to the end of a filename
* @return True if saving page source is successful, otherwise false
*/
public static boolean savePageSource(AppiumDriver<WebElement> appiumDriver,
public static boolean savePageSource(AppiumDriver appiumDriver,
AppiumTestObject testObject, String appendName) {
try {
String path;
Expand Down Expand Up @@ -188,7 +187,7 @@ public static boolean savePageSource(AppiumDriver<WebElement> appiumDriver,
* @param fileNameWithoutExtension File Name Without Extension
* @return Path to the log file
*/
public static String savePageSource(AppiumDriver<WebElement> appiumDriver,
public static String savePageSource(AppiumDriver appiumDriver,
AppiumTestObject testObject, String directory, String fileNameWithoutExtension) {
// Save the current page source into a string
String pageSource = appiumDriver.getPageSource();
Expand Down Expand Up @@ -225,7 +224,7 @@ public static String savePageSource(AppiumDriver<WebElement> appiumDriver,
*
* @param appiumDriver The Appium Driver
*/
public static void killDriver(AppiumDriver<WebElement> appiumDriver) {
public static void killDriver(AppiumDriver appiumDriver) {
try {
appiumDriver.close();
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import com.cognizantsoftvision.maqs.utilities.logging.LoggingEnabled;
import com.cognizantsoftvision.maqs.utilities.logging.MessageType;
import io.appium.java_client.AppiumDriver;
import org.openqa.selenium.WebElement;
import org.testng.ITestResult;

/**
Expand All @@ -29,7 +28,7 @@ public BaseAppiumTest() {
*
* @return the appium driver
*/
public AppiumDriver<WebElement> getAppiumDriver() {
public AppiumDriver getAppiumDriver() {
return this.getTestObject().getAppiumDriver();
}

Expand All @@ -38,7 +37,7 @@ public AppiumDriver<WebElement> getAppiumDriver() {
*
* @param mobileDriver the mobile driver
*/
public void setAppiumDriver(AppiumDriver<WebElement> mobileDriver) {
public void setAppiumDriver(AppiumDriver mobileDriver) {
this.getTestObject().setAppiumDriver(mobileDriver);
}

Expand All @@ -47,7 +46,7 @@ public void setAppiumDriver(AppiumDriver<WebElement> mobileDriver) {
*
* @return the mobile driver
*/
protected AppiumDriver<WebElement> getMobileDriver() {
protected AppiumDriver getMobileDriver() {
return AppiumDriverFactory.getDefaultMobileDriver();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import com.cognizantsoftvision.maqs.base.ITestObject;
import io.appium.java_client.AppiumDriver;
import java.util.function.Supplier;
import org.openqa.selenium.WebElement;

/**
* The Appium Test Object interface class.
Expand All @@ -19,21 +18,21 @@ public interface IAppiumTestObject extends ITestObject {
*
* @return the appium driver
*/
AppiumDriver<WebElement> getAppiumDriver();
AppiumDriver getAppiumDriver();

/**
* Sets appium driver.
*
* @param appiumDriver the appium driver
*/
void setAppiumDriver(AppiumDriver<WebElement> appiumDriver);
void setAppiumDriver(AppiumDriver appiumDriver);

/**
* Sets appium driver.
*
* @param appiumDriverSupplier the appium driver supplier
*/
void setAppiumDriver(Supplier<AppiumDriver<WebElement>> appiumDriverSupplier);
void setAppiumDriver(Supplier<AppiumDriver> appiumDriverSupplier);

/**
* Gets appium manager.
Expand Down
Loading