我想使用c#和appium测试我的混合应用程序。我知道混合应用程序需要切换到“ WEBVIEW”,但是它不起作用,并且出现错误-
Error: Failed to start Chromedriver session: An unknown server-side error occurred while processing the command. (Original error: unknown error: unable to discover open pages
。
当我用Google搜索问题并加以解决时,它仍然无法正常工作。我希望有人分享他们的经验。谢谢。
Appium version: v1.8.0
Android Version: 7.0
Device API: 24
Device:Geny Motion emulator
Chrome driver: 2.37
Chrome version : 67.0
这是我的能力
app: F:\EMSD\App\CCePJM-unsigned.apk
platformVersion: 7.0
deviceName: Android Emulator
platformName: Android
noReset: true
appPackage: hk.gov.emsd.ccepjmstage
appActivity: hk.gov.emsd.ccepjmstage.MainActivity
autoWebview: true
用于设置的部分代码
public void SetUp()
{
capabilities = CapsHelper.GetAndroidCaps();
//get error mentioned above after 120 seconds
driver = new AndroidDriver<IWebElement>(new Uri(MobileCapabilityConfigs.LOCAL_URI), capabilities, TimeSpan.FromSeconds(120));
IList<String> contextNames = driver.Contexts;
driver.Context = contextNames.FirstOrDefault(c => c.Contains("WEBVIEW_"));
}
这是我的日志,供您参考
[ADB][39m Found package: 'hk.gov.emsd.ccepjmstage' and fully qualified activity name : 'hk.gov.emsd.ccepjmstage.MainActivity'
[AndroidDriver][39m Setting auto webview to context 'WEBVIEW_hk.gov.emsd.ccepjmstage' with timeout 2000ms
[AndroidDriver][39m Getting a list of available webviews
[ADB][39m Getting connected devices...
[ADB][39m 1 device(s) connected
[AndroidDriver][39m Getting process name for webview
[AndroidDriver][39m Parsed pid: '6393' pkg: 'hk.gov.emsd.ccepjmstage' from
[AndroidDriver][39m USER PID PPID VSIZE RSS WCHAN PC NAME
[AndroidDriver][39m u0_a184 6393 269 1119584 191252 futex_wait edebabb9 S hk.gov.emsd.ccepjmstage
[AndroidDriver][39m Returning process name: 'hk.gov.emsd.ccepjmstage'
[AndroidDriver][39m Found webviews: ["WEBVIEW_hk.gov.emsd.ccepjmstage"]
[AndroidDriver][39m Available contexts: ["NATIVE_APP","WEBVIEW_hk.gov.emsd.ccepjmstage"]
[AndroidDriver][39m Connecting to chrome-backed webview context 'WEBVIEW_hk.gov.emsd.ccepjmstage'
[AndroidDriver][39m A port was not given, using random port: 8000
[Chromedriver][39m Changed state to 'starting'[debug] [35m[Chromedriver][39m The following Chromedriver executables were found:
[Chromedriver][39m C:/Program Files (x86)/Appium/resources/app/node_modules/appium-chromedriver/chromedriver/win/chromedriver.exe (minimum Chrome version '64.0.3282')
[ADB][39m Getting package info for 'com.android.chrome'
[HTTP][39m [90m{"desiredCapabilities":{"app":"F:\\EMSD\\App\\CCePJM-unsigned.apk","platformVersion":"7.0","deviceName":"Android Emulator","platformName":"Android","noReset":true,"autoWebview":true}}[39m
[ADB][39m List forwarding ports
[ADB][39m Running 'C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe -P 5037 -s 192.168.15.101\:5555 forward --list'
[ADB][39m Removing forwarded port socket connection: 12518
[ADB][39m Running 'C:\Program Files (x86)\Android\android-sdk\platform-tools\adb.exe -P 5037 -s 192.168.15.101\:5555 forward --remove tcp\:12518'[info] [35m[Chromedriver][39m Spawning chromedriver with: C:/Program Files (x86)/Appium/resources/app/node_modules/appium-chromedriver/chromedriver/win/chromedriver.exe --url-base=wd/hub --port=8002 --adb-port=5037 --verbose
[Chromedriver][39m Chromedriver version: '2.37.544315'
[JSONWP Proxy][39m Proxying [GET /status] to [GET http://127.0.0.1:8002/wd/hub/status] with no body[debug] [35m[JSONWP Proxy][39m Got response with status 200: "{\"sessionId\":\"\",\"status\":0,\"value\":{\"build\":{\"version\":\"alpha\"},\"os\":{\"arch\":\"x86_64\",\"name\":\"Windows NT\",\"version\":\"6.1.7601 SP1\"}}}"
[JSONWP Proxy][39m Proxying [POST /session] to [POST http://127.0.0.1:8002/wd/hub/session] with body: {"desiredCapabilities":{"chromeOptions":{"androidPackage":"hk.gov.emsd.ccepjmstage","androidUseRunningApp":true,"androidDeviceSerial":"192.168.15.101:5555"}}}[debug] [35m[Chromedriver][39m Webview version: 'Chrome/67.0.3396.87'[info] [35m[HTTP][39m [37m<-- POST /wd/hub/session
[HTTP]35m[JSONWP Proxy][39m Got response with status 200: {"sessionId":"1744e3d93db86562e4da730073e1cc98","status":13,"value":{"message":"unknown error: unable to discover open pages\n (Driver info: chromedriver=2.37.544315 (730aa6a5fdba159ac9f4c1e8cbc59bf1b5ce12b7),platform=Windows NT 6.1.7601 SP1 x86_64)"}}
[Chromedriver][39m Error: Failed to start Chromedriver session: An unknown server-side error occurred while processing the command. (Original error: unknown error: unable to discover open pages
[Chromedriver][39m (Driver info: chromedriver=2.37.544315 (730aa6a5fdba159ac9f4c1e8cbc59bf1b5ce12b7),platform=Windows NT 6.1.7601 SP1 x86_64))
[Chromedriver][39m at Object.wrappedLogger.errorAndThrow (C:\Program Files (x86)\Appium\resources\app\node_modules\appium-support\lib\logging.js:78:13)
[Chromedriver][39m at Chromedriver.callee$2$0$ (C:\Program Files (x86)\Appium\resources\app\node_modules\appium-chromedriver\lib\chromedriver.js:357:13)
[Chromedriver][39m at tryCatch (C:\Program Files (x86)\Appium\resources\app\node_modules\appium-chromedriver\node_modules\babel-runtime\regenerator\runtime.js:67:40)
[Chromedriver][39m at GeneratorFunctionPrototype.invoke [as _invoke] (C:\Program Files (x86)\Appium\resources\app\node_modules\appium-chromedriver\node_modules\babel-runtime\regenerator\runtime.js:315:22)
[Chromedriver][39m at GeneratorFunctionPrototype.prototype.(anonymous function) [as throw] (C:\Program Files (x86)\Appium\resources\app\node_modules\appium-chromedriver\node_modules\babel-runtime\regenerator\runtime.js:100:21)
[Chromedriver][39m at GeneratorFunctionPrototype.invoke (C:\Program Files (x86)\Appium\resources\app\node_modules\appium-chromedriver\node_modules\babel-runtime\regenerator\runtime.js:136:37)
[Chromedriver][39m at <anonymous>[debug] [35m[JSONWP Proxy][39m Proxying [POST /session] to [POST http://127.0.0.1:8000/wd/hub/session] with body: {"desiredCapabilities":{"chromeOptions":{"androidPackage":"hk.gov.emsd.ccepjmstage","androidUseRunningApp":true,"androidDeviceSerial":"192.168.15.101:5555"}}}[debug] [35m[Chromedriver][39m Webview version: 'Chrome/67.0.3396.87'