Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/powerbi/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
有没有办法从Selenium触发SOAP请求并将响应返回到任何文件_Selenium_Soap - Fatal编程技术网

有没有办法从Selenium触发SOAP请求并将响应返回到任何文件

有没有办法从Selenium触发SOAP请求并将响应返回到任何文件,selenium,soap,Selenium,Soap,在我正在自动化的应用程序中,以下是要求 需要在SOAPUI中运行请求 这将为提供的请求生成令牌响应 我们需要在构建URL以打开应用程序时使用此令牌。令牌由时间戳驱动。所以每次触发都会改变 请告诉我是否有办法从Selenium启动SOAP请求并将响应返回或任何文件。我只是在SOAP请求中使用Java代码。为了编辑XML中的数据,我使用了DOM解析器。以下是我为此使用的代码: @When("^Soap call is made") public void soap_call_is_m

在我正在自动化的应用程序中,以下是要求

  • 需要在SOAPUI中运行请求
  • 这将为提供的请求生成令牌响应
  • 我们需要在构建URL以打开应用程序时使用此令牌。令牌由时间戳驱动。所以每次触发都会改变

  • 请告诉我是否有办法从Selenium启动SOAP请求并将响应返回或任何文件。

    我只是在SOAP请求中使用Java代码。为了编辑XML中的数据,我使用了DOM解析器。以下是我为此使用的代码:

        @When("^Soap call is made")
        public void soap_call_is_made() throws Exception {
        XMLHandling xml = new XMLHandling();
        String url = "URL here";
    
        String xmlPath = getClass().getResource("location/of/file.xml").getPath();
        Document document = xml.getXMLFile(xmlPath);
        SOAPMessage soapResponse =xml.makeSoapCall(document, url);
    
        // print SOAP Response
        System.out.print("Response SOAP Message:");
        soapResponse.writeTo(System.out);
    
    }
    
    最后一行将获得响应中的令牌

    编辑: 要从响应中获取特定数据,请使用:

    String tagName = "tagnameYouNeed"
    String value = xml.getValueByTagName(soapResponse, tagName);
    

    不,Selenium不处理SOAP/REST请求。相反,您可以使用java或cURL来处理这种情况。或者,您也可以对此进行检查。

    谢谢您的回复。请提供更多关于XMLHandling类和makeSoapCall()函数的信息。