Appium Chrome浏览器。如何禁用缓存重置选项

时间:2018-07-01 17:34:10

标签: c# appium selenium-chromedriver appium-android

DesiredCapabilities appCapabilities = new DesiredCapabilities();
appCapabilities.SetCapability(MobileCapabilityType.NoReset, true);
appCapabilities.SetCapability(MobileCapabilityType.PlatformName, MobilePlatform.Android);
appCapabilities.SetCapability(MobileCapabilityType.DeviceName, "0");
appCapabilities.SetCapability(MobileCapabilityType.Udid, device);
appCapabilities.SetCapability(MobileCapabilityType.BrowserName, MobileBrowserType.Chrome);
appCapabilities.SetCapability(MobileCapabilityType.NewCommandTimeout, 10000);
driver = new AndroidDriver<IWebElement>(new Uri("http://127.0.0.1:4723/wd/hub"), appCapabilities);

这是我的代码。

[JSONWP Proxy] Got response with status 200: {"sessionId":"494892b985b37b1e9aa0c949d73dfc8e","status":0,"value":{"acceptInsecureCerts":false,"acceptSslCerts":false,"applicationCacheEnabled":false,"browserConnectionEnabled":false,"browserName":"chrome","chrome":{"chromedriverVersion":"2.38.552522 (437e6fbedfa8762dec75e2c5b3ddb86763dc9dcb)"},"cssSelectorsEnabled":true,"databaseEnabled":false,"handlesAlerts":true,"hasTouchScreen":true,"javascriptEnabled":true,"locationContextEnabled":true,"mobileEmulationEnabled":false,"nativeEvents":true,"pageLoadStrategy":"normal","platform":"ANDROID","rotatable":false,"setWindowRect":false,"takesHeapSnapshot":true,"takesScreenshot":true,"unexpectedAlertBehaviour":"","version":"67.0.3396.87","webStorageEnabled":true}}

这是鸦片日志。

我认为[ "applicationCacheEnabled" : false ]正在制造问题。

我要设置applicationCacheEnabled : true

未设置重置Chrome缓存。

我搜索选项并找到“ NoReset”

但不适用于Chrome浏览器。

仅工作执行应用。

我需要帮助。 C#或Java代码,等等...

2 个答案:

答案 0 :(得分:0)

自我回答。

DesiredCapabilities appCapabilities = new DesiredCapabilities();
appCapabilities.SetCapability(MobileCapabilityType.PlatformName, "Android");
appCapabilities.SetCapability(MobileCapabilityType.DeviceName, device);
appCapabilities.SetCapability(MobileCapabilityType.Udid, device);
appCapabilities.SetCapability(AndroidMobileCapabilityType.AndroidDeviceReadyTimeout, 300);
appCapabilities.SetCapability(AndroidMobileCapabilityType.AppWaitDuration, 30);
appCapabilities.SetCapability(AndroidMobileCapabilityType.ChromedriverExecutable, string.Format("{0}\\chromedriver.exe", DirectoryPath.Library));
appCapabilities.SetCapability(MobileCapabilityType.BrowserName, "");
appCapabilities.SetCapability(AndroidMobileCapabilityType.AppPackage, "com.android.chrome");
appCapabilities.SetCapability(AndroidMobileCapabilityType.AppActivity, "com.google.android.apps.chrome.Main");

driver = new AndroidDriver<IWebElement>(service.ServiceUrl, appCapabilities, new TimeSpan(0, 5, 0));
driver.Context = "WEBVIEW_chrome";
  1. 设置uiautomator和chromedriver。
  2. 更改上下文。

答案 1 :(得分:0)

DesiredCapabilities cap = new DesiredCapabilities(); 

cap.SetCapability("noReset", "true");       
cap.SetCapability("fullReset", "False");

noReset设置为true,它对我有用。