有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

windows上的java Appium服务器正在抛出错误:向客户端响应我们未找到有效资源

我正在尝试使用一个简单的命令在我的Windows 7计算机上运行Appium Service:

D:\Appium\node。exe D:\Appium\node\u modules\Appium\bin\Appium。js-gc:\Users\vdopia\AppData\Local\Temp\applog\u 12232015\u 110310。txt—无重置

在命令提示符中,它显示Appium已启动。当我浏览urlhttp://127.0.0.1:4723时,我在命令提示符中得到下面的消息,因此我也无法初始化remotedriver。令人惊讶的是,同样的东西在MAC中也能很好地工作

        Logs:
            > info: --> GET / {}
            > info: [debug] Responding to client that we did not find a valid resource
            > info: <-- GET / 404 0.712 ms - 47 
            > info: <-- GET /favicon.ico 200 0.535 ms - 1150 

I am pasting code here to start appium server, first I am writing command in a sh or bat file then executing the bat file.

    public static boolean startAppiumServer() 
        {       
            //Kill any Existing Appium Before Starting new session
            logger.info("Stopping any running instance of appium. ");
            try{SDKCommonUtils.killAppiumServer();}catch(Exception  e){}

            boolean flag = false;
            File logFile = null;
            String commandFile = null;

            if(System.getProperty("os.name").matches("^Windows.*"))
            {
                //Getting temp dir
                String tempDir = System.getProperty("java.io.tmpdir").toString();
                logFile = new File(tempDir+"\\applog"+"_"+MobileTestClass_Methods.DateTimeStamp()+".txt");

                commandFile = System.getenv("AUTOMATION_HOME").concat("\\tpt\\appium_commands.bat");

                String appiumCmdLocation_Windows = MobileTestClass_Methods.propertyConfigFile.getProperty("appiumCmdLocationForWindows").toString();

                String nodeExe = appiumCmdLocation_Windows.concat("\\node.exe");
                String appiumJs = appiumCmdLocation_Windows.concat("\\node_modules\\appium\\bin\\Appium.js");

                String strText = "start /B " + nodeExe + "  " + appiumJs + " -g " + logFile.toString() + " --full-reset --command-timeout 60 ";
                FileLib.WriteTextInFile(commandFile, strText);
            }
            else
            {
                logFile = new File("/tmp/applog"+"_"+MobileTestClass_Methods.DateTimeStamp()+".txt");
                commandFile = System.getenv("AUTOMATION_HOME").concat("/tpt/appium_commands.sh");

                String strText = "export PATH=$PATH:/usr/local/bin; /usr/local/bin/appium -g " + logFile.toString() + " --full-reset --command-timeout 60 " ;
                FileLib.WriteTextInFile(commandFile, strText);
            }

            try
            {
                logger.info("Executing Command File: "+ commandFile +" to start appium service. ");
                Runtime.getRuntime().exec(commandFile);

                /** wait until appium server is started */
                flag = waitForAppiumServer();
            }
            catch(Exception e)
            {
                flag = false;
                logger.error("There were some issues while executing command to launch appium service. ",e);
            }

            return flag;
        }

共 (1) 个答案

  1. # 1 楼答案

    如果您不提供服务器地址,那么它将在windows as的命令提示符下用作0.0.0.0

    info: Appium REST http interface listener started on 0.0.0.0:4723

    请从命令行提供 address 127.0.0.1 port 4723参数,并在脚本中初始化驱动程序对象时尝试使用相同的地址和端口