Chrome 浏览器无法导航到 appium 中的任何站点 [英] Chrome browser is not able to navigate to any site in appium
问题描述
我刚刚在android模拟器中安装了chrome.apk文件,好像安装成功了.但是当我尝试执行以下脚本时,它在模拟器设备中打开了 chrome 浏览器,但没有显示谷歌主页.和简单的驱动程序退出.
I just installed chrome.apk file in android emulator, and It seems to be installed successfully. But When I tried to execute the below script, Its open up the chrome browser in emulator device but not displayed google home page. And simple the driver is quit.
示例代码:似乎是启动浏览器,但没有导航到谷歌主页
Sample code: It seems to be launch the browser, but not navigate to google home page
public static WebDriver driver;
@BeforeSuite
public static void initalizeBrowser() throws Exception {
try {
DesiredCapabilities desired = DesiredCapabilities.android();
desired.setCapability(MobileCapabilityType.DEVICE_NAME,
"Android Emulator");
desired.setCapability(MobileCapabilityType.PLATFORM_NAME, "Android");
desired.setCapability(MobileCapabilityType.PLATFORM_VERSION,
"4.2.2");
desired.setCapability(MobileCapabilityType.BROWSER_NAME, "Chrome");
desired.setCapability(MobileCapabilityType.APP_PACKAGE,
"com.android.chrome");
desired.setCapability(MobileCapabilityType.APP_ACTIVITY,
"com.google.android.apps.chrome.Main");
driver = new RemoteWebDriver(
new URL("http://127.0.0.1:4723/wd/hub"), desired);
driver.get("http://www.google.com");
} catch (Exception ex) {
ex.printStackTrace();
}
}
@Test
public void testCase1() throws Exception {
try {
System.out.println(driver.getTitle());
} catch (Exception ex) {
ex.printStackTrace();
}
}
@AfterSuite
public static void tearDown() throws Exception {
try {
driver.quit();
} catch (Exception ex) {
ex.printStackTrace();
}
}
有人可以帮助我这种行为的原因是什么.
Can somebody assist me what could be the reason for this behavior.
推荐答案
其实我也遇到了同样的问题,经过一整天的搜索我才知道 chrome 驱动程序需要与现有的 chrome 浏览器兼容你的设备.在此处查看详细信息:
Actually I was also facing the same issue, after a long day search I came to know that the chrome driver need to be in compatible with the chrome browser present in your device. Check the details here:
然后下载合适的chrome驱动程序并将其替换为appium安装文件夹中的chrome驱动程序:
After that download the chrome driver which is suitable and replace it with the chrome driver present in the appium installed folder:
\Appium\node_modules\appium\node_modules\appium-chromedriver
就我而言是:
C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-chromedriver\chromedriver
这篇关于Chrome 浏览器无法导航到 appium 中的任何站点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!