我想用Jython打开特定的浏览器。
我相信这是how it is done with Java:
Runtime rt = Runtime.getRuntime();
rt.exec(new String[]{"cmd", "/c","start chrome http://www.stackoverflow.com"});
我试图将Java转换为Jython:
from java.lang import Runtime
Runtime = Runtime.getRuntime()
Runtime.exec("start chrome http://www.stackoverflow.com");
但是,它失败了:
java.io.IOException: java.io.IOException: Cannot run program "start": CreateProcess error=2,
The system cannot find the file specified in <script> at line number 3
BMXAA7837E - An error occured that prevented the TESTURL script for the LP23 launch point from running.
java.io.IOException: java.io.IOException: Cannot run program "start": CreateProcess error=2, The system
cannot find the file specified in <script> at line number 3
是否可以使用Jython打开特定的浏览器?
您的问题的直接答案是“否”。
因为自动化脚本在服务器端(甚至在服务器端的服务器端)运行100%,所以它们对客户端/浏览器的直接控制为零。您可以将URL格式化为一个属性,然后将该属性用于“在上下文中启动”配置项,但这与操作客户端/浏览器差不多,除非您想进行更具侵入性的自定义。