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 ca6f75e..adc3cd1 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 @@ -32,6 +32,8 @@ public class AppiumDriverRequest extends SeleniumWebDriverRequest implements AppiumCapabilityHelper { + private URL mobileServerUrl; + public AppiumDriverRequest() { this.setAccessKey(AppiumProperties.MOBILE_GRID_ACCESS_KEY.asString()); @@ -41,16 +43,27 @@ public AppiumDriverRequest() { } + @Override + public void setServerUrl(String url) throws MalformedURLException { + mobileServerUrl = new URL(url); + } + + @Override + public void setServerUrl(URL url) { + this.mobileServerUrl = url; + } + @Override public Optional getServerUrl() { - if (!super.getServerUrl().isPresent()) { + Optional serverUrl = Optional.ofNullable(this.mobileServerUrl); + if (serverUrl.isEmpty()) { try { this.setServerUrl(AppiumProperties.MOBILE_GRID_URL.asString()); } catch (MalformedURLException e) { throw new RuntimeException("Unable to retrieve default Appium URL from properties", e); } } - return super.getServerUrl(); + return Optional.ofNullable(this.mobileServerUrl); } public void setDeviceQuery(String deviceQuery) { 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 5cf89d9..1cc2ec3 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 @@ -23,21 +23,27 @@ package eu.tsystems.mms.tic.testframework.mobile.test.driver; import eu.tsystems.mms.tic.testframework.appium.Browsers; +import eu.tsystems.mms.tic.testframework.common.PropertyManagerProvider; import eu.tsystems.mms.tic.testframework.mobile.test.AbstractAppiumTest; import eu.tsystems.mms.tic.testframework.report.model.context.Screenshot; import eu.tsystems.mms.tic.testframework.report.model.context.SessionContext; import eu.tsystems.mms.tic.testframework.testing.WebDriverManagerProvider; +import eu.tsystems.mms.tic.testframework.utils.AppiumProperties; import eu.tsystems.mms.tic.testframework.utils.AppiumUtils; import eu.tsystems.mms.tic.testframework.utils.JSUtils; import eu.tsystems.mms.tic.testframework.utils.UITestUtils; import eu.tsystems.mms.tic.testframework.utils.WebDriverUtils; import eu.tsystems.mms.tic.testframework.webdrivermanager.AppiumDriverRequest; +import eu.tsystems.mms.tic.testframework.webdrivermanager.DesktopWebDriverRequest; import org.openqa.selenium.Rectangle; import org.openqa.selenium.ScreenOrientation; import org.openqa.selenium.WebDriver; import org.testng.Assert; import org.testng.annotations.Test; +import java.net.URL; +import java.util.Optional; + /** * Date: 24.06.2020 * Time: 12:26 @@ -142,4 +148,22 @@ public void testT07_getViewport() { // Assert.assertNotNull(viewportRectangle, "WebDriver Viewport created"); } + @Test + public void testT10_Appium_and_desktop_driver() { + final String seleniumUrlString = "http://localhost:4444/wd/hub"; + final String appiumUrlString = AppiumProperties.MOBILE_GRID_URL.asString(); + PropertyManagerProvider.PROPERTY_MANAGER.setTestLocalProperty("tt.selenium.server.url", seleniumUrlString); + + DesktopWebDriverRequest desktopWebDriverRequest = new DesktopWebDriverRequest(); + AppiumDriverRequest appiumDriverRequest = new AppiumDriverRequest(); + + // Check server urls + Optional seleniumUrl = desktopWebDriverRequest.getServerUrl(); + Optional appiumUrl = appiumDriverRequest.getServerUrl(); + Assert.assertNotEquals(seleniumUrl, appiumUrl); + Assert.assertEquals(seleniumUrl.get().toString(), seleniumUrlString); + Assert.assertEquals(appiumUrl.get().toString(), appiumUrlString); + + } + }