Skip to content

Commit

Permalink
Merge pull request #21 from telekom/fix/minor-improvements
Browse files Browse the repository at this point in the history
Fix/minor improvements
  • Loading branch information
martingrossmann authored Dec 19, 2024
2 parents bdfe80b + 84d25c0 commit 9162967
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@

public class AppiumDriverRequest extends SeleniumWebDriverRequest implements AppiumCapabilityHelper {

private URL mobileServerUrl;

public AppiumDriverRequest() {
this.setAccessKey(AppiumProperties.MOBILE_GRID_ACCESS_KEY.asString());

Expand All @@ -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<URL> getServerUrl() {
if (!super.getServerUrl().isPresent()) {
Optional<URL> 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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<URL> seleniumUrl = desktopWebDriverRequest.getServerUrl();
Optional<URL> appiumUrl = appiumDriverRequest.getServerUrl();
Assert.assertNotEquals(seleniumUrl, appiumUrl);
Assert.assertEquals(seleniumUrl.get().toString(), seleniumUrlString);
Assert.assertEquals(appiumUrl.get().toString(), appiumUrlString);

}

}

0 comments on commit 9162967

Please sign in to comment.