Created
September 2, 2018 23:17
-
-
Save kool79/6b3cd40b473eaa3123a8f5e8be95c9e0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package qa.ok.fw.test; | |
import java.net.MalformedURLException; | |
import java.net.URL; | |
import java.time.Duration; | |
import java.time.LocalTime; | |
import org.openqa.selenium.Platform; | |
import org.openqa.selenium.WebDriver; | |
import org.openqa.selenium.remote.BrowserType; | |
import org.openqa.selenium.remote.CapabilityType; | |
import org.openqa.selenium.remote.DesiredCapabilities; | |
import org.openqa.selenium.remote.RemoteWebDriver; | |
import org.testng.annotations.Test; | |
public class AppuimW3cBug { | |
private final URL hubUrl = new URL("http://ta-mac-01:4724/wd/hub"); | |
private static final Duration NEW_COMMAND_TIMEOUT = Duration.ofSeconds(80); | |
public AppuimW3cBug() throws MalformedURLException {} | |
@Test | |
public void connectionTest() throws InterruptedException { | |
WebDriver wd = startDriver("http://the-internet.herokuapp.com/"); | |
try { | |
log("Open URL... http://the-internet.herokuapp.com/"); | |
wd.get("http://the-internet.herokuapp.com/"); | |
log("wait until session expired on appium side ( param newCommandTimeout)"); | |
Thread.sleep(NEW_COMMAND_TIMEOUT.toMillis() + 5000); | |
String title = wd.getTitle(); //must fail with "no such session" but prints appium's stacktrace as title | |
log("Get title:" + title); | |
log("ERROR!!! : Test must be terminated on previous command"); | |
} finally { | |
wd.quit(); | |
} | |
} | |
private WebDriver startDriver(String url) { | |
DesiredCapabilities dc = new DesiredCapabilities(); | |
dc.setCapability(CapabilityType.PLATFORM_NAME, Platform.IOS); | |
dc.setCapability(CapabilityType.BROWSER_NAME, BrowserType.SAFARI); | |
dc.setCapability("appium:automationName", "XCUITest"); | |
dc.setCapability("appium:platformVersion", "11.4"); | |
dc.setCapability("appium:deviceName", "iPhone 7"); | |
dc.setCapability("appium:shutdownOtherSimulators", true); | |
dc.setCapability("appium:useNewWDA", false); | |
dc.setCapability("appium:fullReset", false); | |
dc.setCapability("appium:noReset", false); | |
dc.setCapability("appium:resetOnSessionStartOnly", false); | |
dc.setCapability("appium:newCommandTimeout", NEW_COMMAND_TIMEOUT.toSeconds()); | |
log("Starting driver..."); | |
return new RemoteWebDriver(hubUrl, dc); | |
} | |
private static void log(Object... args) { | |
StringBuilder s = new StringBuilder(LocalTime.now() + ": "); | |
for (Object arg : args) s.append(" ").append(arg); | |
System.out.println(s); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Line 35: wait until appium expire session (due expiration of newCommandTimeout)
Line 37: try to get title of window from the session. Instead of failed test we had content of appium stacktrace as 'title'.
Execution log ( note that test is marked as passed. Stacktrace below is NOT an error. It is content of
title
variable):