使用Appium在模拟器/真机启动Firefox时浏览器崩溃问题求助
安卓端Firefox启动崩溃解决方案
你的配置存在多处参数定义错误,导致驱动无法正确匹配目标测试设备环境,触发Firefox启动崩溃,按以下步骤修正即可解决:
- 修正核心配置参数
你错误将platformName设为windows(该参数指代测试目标设备的操作系统,而非执行脚本的宿主机系统),测试安卓设备时必须改为Android;同时移动端火狐测试的自动化引擎需指定为UiAutomator2,而非桌面端火狐使用的Gecko。 - 调整参数归属
安卓存储配置androidStorage属于火狐专属参数,需放到moz:firefoxOptions参数组内,不要直接作为全局capability配置。 - 校验基础环境
执行adb devices确认目标设备(模拟器/真机)已被正常识别,设备序列号与配置的androidDeviceSerial一致;确认Appium服务已正常启动,4723端口未被其他进程占用;测试前提前在安卓设备安装好对应版本的Firefox,避免驱动自动安装失败。 - 验证版本兼容性
确保核心组件版本匹配:- Appium服务器版本≥2.0,且已安装
appium-geckodriver驱动 - 电脑端Geckodriver版本与安卓端安装的Firefox版本适配
- 安卓系统版本≥8.0,可正常独立启动Firefox应用
- Appium服务器版本≥2.0,且已安装
修正后的配置示例如下:
DesiredCapabilities capabilities = new DesiredCapabilities(); JSONObject firefoxOptions = new JSONObject(); firefoxOptions.put("androidDeviceSerial", "emulator-5554"); firefoxOptions.put("androidPackage", "org.mozilla.firefox"); firefoxOptions.put("androidStorage", "internal"); // 核心参数修正 capabilities.setCapability("platformName", "Android"); capabilities.setCapability("browserName", "firefox"); capabilities.setCapability("automationName", "UiAutomator2"); capabilities.setCapability("moz:firefoxOptions", firefoxOptions); WebDriver driver= new RemoteWebDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
内容的提问来源于stack exchange,提问作者S S D
相关产品推荐
相关产品推荐

