diff --git a/appium/src/main/java/eu/tsystems/mms/tic/testframework/appium/AppiumCapabilityHelper.java b/appium/src/main/java/eu/tsystems/mms/tic/testframework/appium/AppiumCapabilityHelper.java new file mode 100644 index 0000000..23660f1 --- /dev/null +++ b/appium/src/main/java/eu/tsystems/mms/tic/testframework/appium/AppiumCapabilityHelper.java @@ -0,0 +1,15 @@ +package eu.tsystems.mms.tic.testframework.appium; + +/** + * Created on 2024-06-11 + * + * The Appium client convert all Appium specific capabilities and adds the prefix 'appium:'. + * This should help to read a capability. + */ +public interface AppiumCapabilityHelper { + + default String getAppiumCap(final String capabilityName) { + return "appium:" + capabilityName; + } + +} diff --git a/appium/src/main/java/eu/tsystems/mms/tic/testframework/mobile/driver/MobileOsChecker.java b/appium/src/main/java/eu/tsystems/mms/tic/testframework/mobile/driver/MobileOsChecker.java index 09e92bb..e407109 100644 --- a/appium/src/main/java/eu/tsystems/mms/tic/testframework/mobile/driver/MobileOsChecker.java +++ b/appium/src/main/java/eu/tsystems/mms/tic/testframework/mobile/driver/MobileOsChecker.java @@ -20,6 +20,7 @@ */ package eu.tsystems.mms.tic.testframework.mobile.driver; +import eu.tsystems.mms.tic.testframework.appium.AppiumCapabilityHelper; import eu.tsystems.mms.tic.testframework.appium.Browsers; import eu.tsystems.mms.tic.testframework.common.Testerra; import eu.tsystems.mms.tic.testframework.report.model.context.SessionContext; @@ -39,24 +40,24 @@ * * @author mgn */ -public class MobileOsChecker { +public class MobileOsChecker implements AppiumCapabilityHelper { public Platform getPlatform(WebDriverRequest webDriverRequest) { Capabilities capabilities = webDriverRequest.getCapabilities(); if (webDriverRequest.getBrowser().equals(Browsers.mobile_chrome) - || "Espresso".equals(capabilities.getCapability(MobileCapabilityType.AUTOMATION_NAME)) - || "UiAutomator2".equals(capabilities.getCapability(MobileCapabilityType.AUTOMATION_NAME)) - || "UiAutomator".equals(capabilities.getCapability(MobileCapabilityType.AUTOMATION_NAME)) - || capabilities.getCapability(AndroidMobileCapabilityType.APP_PACKAGE) != null - || capabilities.getCapability(AndroidMobileCapabilityType.APP_ACTIVITY) != null + || "Espresso".equals(capabilities.getCapability(getAppiumCap(MobileCapabilityType.AUTOMATION_NAME))) + || "UiAutomator2".equals(capabilities.getCapability(getAppiumCap(MobileCapabilityType.AUTOMATION_NAME))) + || "UiAutomator".equals(capabilities.getCapability(getAppiumCap(MobileCapabilityType.AUTOMATION_NAME))) + || capabilities.getCapability(getAppiumCap(AndroidMobileCapabilityType.APP_PACKAGE)) != null + || capabilities.getCapability(getAppiumCap(AndroidMobileCapabilityType.APP_ACTIVITY)) != null ) { return Platform.ANDROID; } if (webDriverRequest.getBrowser().equals(Browsers.mobile_safari) - || "XCUITest".equals(capabilities.getCapability(MobileCapabilityType.AUTOMATION_NAME)) - || "UIAutomation".equals(capabilities.getCapability(MobileCapabilityType.AUTOMATION_NAME)) - || capabilities.getCapability(IOSMobileCapabilityType.BUNDLE_ID) != null + || "XCUITest".equals(capabilities.getCapability(getAppiumCap(MobileCapabilityType.AUTOMATION_NAME))) + || "UIAutomation".equals(capabilities.getCapability(getAppiumCap(MobileCapabilityType.AUTOMATION_NAME))) + || capabilities.getCapability(getAppiumCap(IOSMobileCapabilityType.BUNDLE_ID)) != null ) { return Platform.IOS; } diff --git a/appium/src/main/java/eu/tsystems/mms/tic/testframework/webdrivermanager/AppiumDriverRequest.java b/appium/src/main/java/eu/tsystems/mms/tic/testframework/webdrivermanager/AppiumDriverRequest.java index 01d55e6..824f087 100644 --- a/appium/src/main/java/eu/tsystems/mms/tic/testframework/webdrivermanager/AppiumDriverRequest.java +++ b/appium/src/main/java/eu/tsystems/mms/tic/testframework/webdrivermanager/AppiumDriverRequest.java @@ -21,6 +21,7 @@ package eu.tsystems.mms.tic.testframework.webdrivermanager; +import eu.tsystems.mms.tic.testframework.appium.AppiumCapabilityHelper; import eu.tsystems.mms.tic.testframework.appium.Browsers; import eu.tsystems.mms.tic.testframework.utils.AppiumProperties; import io.appium.java_client.remote.MobileCapabilityType; @@ -30,7 +31,7 @@ import java.net.URL; import java.util.Optional; -public class AppiumDriverRequest extends SeleniumWebDriverRequest { +public class AppiumDriverRequest extends SeleniumWebDriverRequest implements AppiumCapabilityHelper { public static final String DEVICE_QUERY = "deviceQuery"; public static final String ACCESS_KEY = "accessKey"; @@ -72,7 +73,7 @@ public void setAppiumEngine(String engine) { } public String getAppiumEngine() { - return this.getMutableCapabilities().getCapability(MobileCapabilityType.AUTOMATION_NAME).toString(); + return this.getMutableCapabilities().getCapability(getAppiumCap(MobileCapabilityType.AUTOMATION_NAME)).toString(); } public void setDeviceName(String deviceName) { @@ -80,7 +81,7 @@ public void setDeviceName(String deviceName) { } public String getDeviceName() { - return this.getMutableCapabilities().getCapability(MobileCapabilityType.DEVICE_NAME).toString(); + return this.getMutableCapabilities().getCapability(getAppiumCap(MobileCapabilityType.DEVICE_NAME)).toString(); } public void setPlatformVersion(String platformVersion) { @@ -88,7 +89,7 @@ public void setPlatformVersion(String platformVersion) { } public String getPlatformVersion() { - return this.getMutableCapabilities().getCapability(MobileCapabilityType.PLATFORM_VERSION).toString(); + return this.getMutableCapabilities().getCapability(getAppiumCap(MobileCapabilityType.PLATFORM_VERSION)).toString(); } public void setDeviceId(String id) { @@ -96,6 +97,6 @@ public void setDeviceId(String id) { } public String getDeviceId() { - return this.getMutableCapabilities().getCapability(MobileCapabilityType.UDID).toString(); + return this.getMutableCapabilities().getCapability(getAppiumCap(MobileCapabilityType.UDID)).toString(); } } diff --git a/appium/src/test/java/eu/tsystems/mms/tic/testframework/mobile/test/driver/TesterraAppiumDriverTest.java b/appium/src/test/java/eu/tsystems/mms/tic/testframework/mobile/test/driver/TesterraAppiumDriverTest.java index 0b60723..5cf89d9 100644 --- a/appium/src/test/java/eu/tsystems/mms/tic/testframework/mobile/test/driver/TesterraAppiumDriverTest.java +++ b/appium/src/test/java/eu/tsystems/mms/tic/testframework/mobile/test/driver/TesterraAppiumDriverTest.java @@ -77,7 +77,7 @@ public void testT03_startRequestSession() { final String device = "Apple iPhone X"; request.setBrowser(Browsers.mobile_safari); request.setDeviceQuery(String.format("contains(@name, '%s')", device)); - request.getMutableCapabilities().setCapability("appium:appiumVersion", "2.2.2"); + request.getMutableCapabilities().setCapability("appiumVersion", "2.2.2"); final WebDriver driver = WEB_DRIVER_MANAGER.getWebDriver(request); diff --git a/appium/src/test/resources/test.properties b/appium/src/test/resources/test.properties index d7b1190..4a2af29 100644 --- a/appium/src/test/resources/test.properties +++ b/appium/src/test/resources/test.properties @@ -1,5 +1,5 @@ -#tt.browser=mobile_chrome +tt.browser=mobile_chrome #tt.browser=mobile_safari #tt.baseurl=https://the-internet.herokuapp.com/