问题
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.
回答1:
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 driver for respective browser version
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
In my case it is:
C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-chromedriver\chromedriver
来源:https://stackoverflow.com/questions/33891287/chrome-browser-is-not-able-to-navigate-to-any-site-in-appium