问题
someone please help me to resolve this issue. Thanks in advance. While running java code to open chrome browser in Emulator, I am getting "Failed to start Chromedriver session: A new session could not be created. Details: session not created: This version of ChromeDriver only supports Chrome version 83" error message.
public class ChromeBrowserLaunch {
AppiumDriver driver;
public static void main(String[] args) throws MalformedURLException {
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability(MobileCapabilityType.DEVICE_NAME, "Pixel");
cap.setCapability(MobileCapabilityType.VERSION, "8.0");
cap.setCapability(MobileCapabilityType.PLATFORM_NAME, "Android");
cap.setCapability(MobileCapabilityType.BROWSER_NAME, "Chrome");
cap.setCapability("chromedriverExecutable", "D:\\chromedriver\\chromedriver\\chromedriver.exe");
driver = new AndroidDriver<MobileElement>(new URL("http://127.0.0.1:4723/wd/hub"), cap);
driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
driver.get("http://facebook.com");
driver.findElementByXPath("//*[@id=\"m_login_email\"]").sendKeys("geeta");
driver.findElementByXPath("//*[@id='m_login_password']").sendKeys("geeta");
driver.hideKeyboard();
driver.findElement(By.id("signup-button")).click();
}
}
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Unable to create a new remote session. Please check the server log for more details. Original error: An unknown server-side error occurred while processing the command. Original error: A new session could not be created. Details: session not created: This version of ChromeDriver only supports Chrome version 83 Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03' System info: host: 'DESKTOP-R5U0RRK', ip: '192.168.0.106', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_231' Driver info: driver.version: AndroidDriver remote stacktrace: UnknownError: An unknown server-side error occurred while processing the command. Original error: A new session could not be created. Details: session not created: This version of ChromeDriver only supports Chrome version 83 at getResponseForW3CError (C:\Users\admin\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\appium-base-driver\lib\protocol\errors.js:804:9) at asyncHandler (C:\Users\admin\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\appium-base-driver\lib\protocol\protocol.js:388:37) at process._tickCallback (internal/process/next_tick.js:68:7) Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03' System info: host: 'DESKTOP-R5U0RRK', ip: '192.168.0.106', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_231'
回答1:
Chrome browser on Android has the package name com.android.chrome
and the name of the activity com.google.android.apps.chrome.Main
In Appium you don't need a browser executable to open a browser like Selenium, so just add .APP_PACKAGE
and .APP_ACTIVITY
in your capability, like this:
cap.setCapability(AndroidMobileCapabilityType.APP_PACKAGE, "com.android.chrome");
cap.setCapability(AndroidMobileCapabilityType.APP_ACTIVITY, "com.google.android.apps.chrome.Main");
Following import:
import io.appium.java_client.remote.AndroidMobileCapabilityType;
Remove this line from your code:
cap.setCapability("chromedriverExecutable", "D:\\chromedriver\\chromedriver\\chromedriver.exe");
Note: Make sure the chrome browser is installed on the device.
Reference : How to find appPackage and appActivity name of your App
来源:https://stackoverflow.com/questions/62078372/chrome-browser-fails-to-launch-in-appium-using-java