Chrome浏览器无法导航到appium中的任何网站 [英] Chrome browser is not able to navigate to any site in appium

查看:94
本文介绍了Chrome浏览器无法导航到appium中的任何网站的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚在android模拟器中安装了chrome.apk文件,并且似乎安装成功.但是,当我尝试执行以下脚本时,它会在模拟器设备中打开chrome浏览器,但未显示google主页.并且简单地退出驱动程序.

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.

示例代码:似乎是在启动浏览器,但没有导航到Google主页

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驱动程序

之后,下载合适的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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆