以编程方式启动时,Appium不会初始化驱动程序

编程入门 行业动态 更新时间:2024-10-24 12:29:36
本文介绍了以编程方式启动时,Appium不会初始化驱动程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在使用Java和Selenium通过命令行初始化Appium,以便在Android chrome浏览器上运行测试. 但是,该进程将运行无限长的时间,并且不会执行"DesiredCapabilities"行中的代码. 代码:

I am initializing Appium through command line using Java and Selenium for running test on Android chrome browser. However, the process runs for infinite time and the code from "DesiredCapabilities" line doesn't get executed.. Code :

Process proc; String path_to_appium = System.getenv("APPIUM_HOME") + File.separator + "node_modules" + File.separator + "appium" + File.separator + "bin" + File.separator + "appium.js"; String path_to_node = System.getenv("APPIUM_HOME") + File.separator + "node.exe"; proc = Runtime.getRuntime().exec("\"" + path_to_node + "\"" + " " + "\"" + path_to_appium + "\"" + " " + "--address 127.0.0.1 --browser-name Chrome --platform-name Android --platform-version 17 --automation-name Appium --chromedriver-port 9516 --bootstrap-port 4724 --no-reset --local-timezone --log appium_log.log"); System.out.println("Android Chrome driver would be used"); DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setCapability("platformName","Android"); capabilities.setCapability("deviceName", "HTC One X"); capabilities.setCapability("platformVersion", "4.2.2"); capabilities.setCapability("device", "android"); capabilities.setCapability("browserName", MobileBrowserType.CHROME); Thread.sleep(2000); driver = new RemoteWebDriver(new URL("127.0.0.1:4723/wd/hub"), capabilities); driver.get("test");

控制台上没有任何输出.

I don't get any output in console.

什么都没发生.该过程不会在下一行进行(即设置DesiredCapabilities). chrome无法在设备上启动.

Nothing happens. The process doesn't go on next line (i.e. setting DesiredCapabilities). The chrome doesn't get launched on the device.

注意:当我从命令行执行命令,然后从DesiredCapabilities行开始测试时,测试运行良好,并且chrome成功初始化.

Note : When i execute the command from command line, and then start test from DesiredCapabilities line, the test runs fine and chrome is initialized successfully.

代码有什么问题?

推荐答案

最新的appium版本(即1_4_16_1)中存在问题.

The problem was there in the latest appium version i.e. 1_4_16_1.

appium服务器以编程方式启动时,它正在创建死锁,因此未初始化驱动程序.

When the appium server was launched programatically, it was creating a deadlock because of which the driver was not being initialized.

使用Appium的ServerArguments并替换行后,问题得到解决

The issue got solved after using ServerArguments of Appium and replacing the line

proc = Runtime.getRuntime().exec("\"" + path_to_node + "\"" + " " + "\"" + path_to_appium + "\"" + " " + "--address 127.0.0.1 --browser-name Chrome --platform-name Android --platform-version 17 --automation-name Appium --chromedriver-port 9516 --bootstrap-port 4724 --no-reset --local-timezone --log appium_log.log");

具有以下代码:

ServerArguments serverArguments = new ServerArguments(); serverArguments.setArgument("--address","127.0.0.1"); serverArguments.setArgument("--chromedriver-port", 9516); serverArguments.setArgument("--bootstrap-port", 4724); serverArguments.setArgument("--browser-name", "Chrome"); serverArguments.setArgument("--no-reset", true); serverArguments.setArgument("--local-timezone", true); AppiumServer appiumServer = new AppiumServer(appium_folder, serverArguments); appiumServer.startServer(); driver = new RemoteWebDriver(new URL("127.0.0.1:4723/wd/hub"), capabilities); driver.get("test");

更多推荐

以编程方式启动时,Appium不会初始化驱动程序

本文发布于:2023-11-07 05:15:14,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1565645.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:初始化   启动时   驱动程序   方式   Appium

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!