天天看點

Android6可以安裝chrome版本,請教為什麼模拟器上安裝了最新版的 Chrome,運作時卻提示用的是舊版本的?(問題更新在 6 樓)...

新人剛開始學習用 C# 搭配 Appium 在移動端測試,但是一開始就被卡住了。遇到的問題是在 visual studio 裡運作測試的時候一直傳回下面的報錯

Message: System.InvalidOperationException : An unknown server-side error occurred while processing the command. Original error: Failed to start Chromedriver session: An unknown server-side error occurred while processing the command. Original error: unknown error: Failed to get sockets matching: @webview_devtools_remote_.*11524 (make sure the app has its WebView configured for debugging) (Driver info: chromedriver=2.46.628402 (536cd7adbad73a3783fdc2cab92ab2ba7ec361e1),platform=Windows NT 10.0.17134 x86_64)

在網上搜尋了很多,大多數都是說 chromedriver 的版本不對,然後我試過了好幾個版本的 chromedriver 還是一樣的報錯,根據 chromedriver 官網上的說明,我試過了支援 chrome v72 版本的 chromedriver 2.45, 2.46 和他們前後的好幾個版本都是一樣的報錯,現在就是卡在這裡進行不下去了。求大神幫忙看一下應該怎麼解決。

移動裝置:夜神 5.0.0.0 模拟器(不是最新版的,因為 5.0 版本以上的所有新版本夜神都不能在 chrome 浏覽器裡顯示 webview)

模拟器 Android 版本:4.4.2(已開啟 USB debug 模式)

Appium 版本: 1.10.0

電腦上安裝的 chrome 浏覽器版本:72.0.3626.96

夜神模拟器裡安裝的 chrome 浏覽器版本:72.0.3626.105

模拟器上測試的 app: Ionic

狀況大緻過程:在 visual studio 裡運作測試的代碼,系統能找到模拟器并打開所要測試的 app,但是再接下來就出現上面的報錯了。

C# 代碼

using NUnit.Framework;

using OpenQA.Selenium.Appium.Android;

using OpenQA.Selenium.Appium.Enums;

using OpenQA.Selenium.Chrome;

using OpenQA.Selenium.Remote;

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

namespace AppiumPractice

{

[TestFixture]

public class TestClass

{

[Test]

public void OpenAppium()

{

DesiredCapabilities desiredCapabilities = new DesiredCapabilities();

desiredCapabilities.SetCapability(MobileCapabilityType.PlatformName, "Android");

desiredCapabilities.SetCapability(MobileCapabilityType.DeviceName, "127.0.0.1:62001");

desiredCapabilities.SetCapability(MobileCapabilityType.App, @"K:\complete.apk");

desiredCapabilities.SetCapability("chromedriverExecutable", @"C:\Users\whuang\chromedriver_win32\chromedriver.exe");

ChromeOptions chromeOpt = new ChromeOptions();

chromeOpt.AddAdditionalCapability("androidPackage", "com.android.chrome");

AndroidDriver androidDriver = new AndroidDriver(desiredCapabilities);

var driv = androidDriver.Contexts.First(x => x.Contains("WEBVIEW_"));

androidDriver.Context = driv;

androidDriver.FindElementByXPath("//span[text()='About']").Click();

}

}

}

Android6可以安裝chrome版本,請教為什麼模拟器上安裝了最新版的 Chrome,運作時卻提示用的是舊版本的?(問題更新在 6 樓)...