Skip to content

Instantly share code, notes, and snippets.

@clample
Created May 16, 2019 14:20
Show Gist options
  • Save clample/3becb6623d3ceb3eed5da295ee67e4de to your computer and use it in GitHub Desktop.
Save clample/3becb6623d3ceb3eed5da295ee67e4de to your computer and use it in GitHub Desktop.
package org.testobject.appium.tests.android.basic;
import io.appium.java_client.android.AndroidDriver;
import org.junit.Test;
import org.openqa.selenium.remote.DesiredCapabilities;
import java.net.URL;
public class NoResetWebTest {
@Test
public void test() throws Exception {
AndroidDriver driver = createDriver();
System.out.println("usedCachedDevice: " + driver.getCapabilities().getCapability("usedCachedDevice"));
driver.get("https://saucelabs.com");
driver.get("chrome://history");
Thread.sleep(1000);
System.out.println(driver.getPageSource());
driver.quit();
System.out.println("Creating a new driver...");
AndroidDriver cachedDriver = createDriver();
System.out.println("usedCachedDevice: " + cachedDriver.getCapabilities().getCapability("usedCachedDevice"));
// The chrome://history should show https://saucelabs.com from the first test session
cachedDriver.get("chrome://history");
Thread.sleep(1000);
System.out.println(cachedDriver.getPageSource());
cachedDriver.quit();
}
public AndroidDriver createDriver() throws Exception {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("name", "Cache Test");
capabilities.setCapability("browserName", "Chrome");
capabilities.setCapability("platformName", "Android");
capabilities.setCapability("noReset", true);
capabilities.setCapability("deviceName", "device");
return new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment