Postdata()返回NULL-JAVA+;硒+;浏览器代理

Postdata()返回NULL-JAVA+;硒+;浏览器代理,java,Java,我目前正在使用Selenium来自动化web测试框架 对于HTTP流量,我使用browsermob代理 我得到了职位,通过har类获得正确的命令 但是,对于具有正确post数据的post命令,我无法跟踪post数据,它返回NULL 我正在为此使用getPostData() 你能帮我一下吗 Will getPostData()返回实际的post数据 代码段: System.out.println("getting the HAR data"); har = server.getHa

我目前正在使用Selenium来自动化web测试框架 对于HTTP流量,我使用browsermob代理 我得到了职位,通过har类获得正确的命令

但是,对于具有正确post数据的post命令,我无法跟踪post数据,它返回NULL

我正在为此使用getPostData() 你能帮我一下吗 Will getPostData()返回实际的post数据

代码段:

    System.out.println("getting the HAR data");
    har = server.getHar();
    if(har==null){
    System.out.println("Har is NULL");
    }
    HarLog harLog = har.getLog(); 
    List<HarEntry> logEntries = harLog.getEntries(); 
    System.out.println("getting the HAR data");
    String httpgetMethod =null;
    String posttext=null,postFileName=null,postContentType=null,postName=null,postValue=null;
    harRequest = new HarRequest();

    for (HarEntry harEntry : logEntries){ 
        //Retrieve the Request values
        org.browsermob.core.har.HarResponse response = harEntry.getResponse();   

        org.browsermob.core.har.HarRequest harRequest = harEntry.getRequest();
        if (response == null){ 
            System.out.println("Null response - "+harRequest.getUrl()); 
                continue; 
        } 


        int status = response.getStatus(); 
        httpgetMethod  = harRequest.getMethod();
        System.out.println(harRequest.getUrl()+" - "+status); 
        System.out.println("Method = "+httpgetMethod);

        if (httpgetMethod.equals("POST"))
            {
            postdata1 = harRequest.getPostData(); //HERE I AM GETTING NULL INSTEAD:-(
            if (postdata1!=null){
            System.out.println("Hurray!!!!!!!!!!!!!!!!postdata!=null");
            }
            else{
                System.out.println("postdata is null");
            }
        }

        if (httpgetMethod.equals(postcommand) && (postdata1!=null)){

            try{
            posttext =postdata1.getText();
            }

            catch(Exception e){
            e.printStackTrace();
            }

            if (posttext == null){ 
                System.out.println("Post Data NULL"); 
                //continue; 
            } 
            else{
            System.out.println("postdata text = "+posttext);
            }


            if (((HarPostDataParam) postdata1.getParams()).getFileName() != null)
            System.out.println("postFileName = "+((HarPostDataParam) postdata1.getParams()).getFileName());
            if (((HarPostDataParam) postdata1.getParams()).getContentType() != null)
                System.out.println("getContentType = "+((HarPostDataParam) postdata1.getParams()).getContentType());
            if (((HarPostDataParam) postdata1.getParams()).getName() != null)
                System.out.println("getName = "+((HarPostDataParam) postdata1.getParams()).getName());
            if (((HarPostDataParam) postdata1.getParams()).getValue() != null)
            System.out.println("getValue = "+((HarPostDataParam) postdata1.getParams()).getValue());
             List<HarPostDataParam> postdataparams = postdata1.getParams();
            for(HarPostDataParam posdatap : postdataparams)
            {
                 postFileName=posdatap.getFileName();
                 postContentType = posdatap.getContentType();
                 postName = posdatap.getName();
                 postValue=posdatap.getValue();
                 if ((postFileName) != null){ 
                    System.out.println("postFileName = "+postFileName); 

                 } 
                 else{
                    System.out.println("postFileNameis NULL");
                    }
                 if ((postContentType) != null){ 
                    System.out.println("postContentType = "+postContentType); 
                 }
                 else{
                    System.out.println("postContentType  is NULL");
                    } 
                 if ((postName) != null){ 
                    System.out.println("postName = "+postName); 

                   } 
                 else{
                    System.out.println("postName  is NULL");
                    } 
                 if ((postValue) != null){ 
                        System.out.println("postValue = "+postValue); 

                    } 
                 else{
                        System.out.println("postValue  is NULL");
                     } 
            }


} }
System.out.println(“获取HAR数据”);
har=server.getHar();
如果(har==null){
System.out.println(“Har为空”);
}
HarLog HarLog=har.getLog();
List logEntries=harLog.getEntries();
System.out.println(“获取HAR数据”);
字符串httpgetMethod=null;
字符串posttext=null,postFileName=null,postContentType=null,postName=null,postValue=null;
harRequest=新的harRequest();
对于(HarEntry-HarEntry:logEntries){
//检索请求值
org.browsermob.core.har.HarResponse response=harEntry.getResponse();
org.browsermob.core.har.HarRequest-HarRequest=harEntry.getRequest();
如果(响应==null){
System.out.println(“空响应-”+harRequest.getUrl());
继续;
} 
int status=response.getStatus();
httpgetMethod=harRequest.getMethod();
System.out.println(harRequest.getUrl()+“-”+状态);
System.out.println(“Method=“+httpgetMethod”);
if(httpgetMethod.equals(“POST”))
{
postdata1=harRequest.getPostData();//这里我得到的是NULL:-(
if(postdata1!=null){
System.out.println(“万岁!!!!!!!!!!!!!!!!!postdata!=null”);
}
否则{
System.out.println(“postdata为空”);
}
}
if(httpgetMethod.equals(postcommand)&&(postdata1!=null)){
试一试{
posttext=postdata1.getText();
}
捕获(例外e){
e、 printStackTrace();
}
如果(posttext==null){
System.out.println(“Post数据为空”);
//继续;
} 
否则{
System.out.println(“postdata text=“+posttext”);
}
if(((HarPostDataParam)postdata1.getParams()).getFileName()!=null)
System.out.println(“postFileName=“+((HarPostDataParam)postdata1.getParams()).getFileName());
if(((HarPostDataParam)postdata1.getParams()).getContentType()!=null)
System.out.println(“getContentType=“+((HarPostDataParam)postdata1.getParams()).getContentType());
if(((HarPostDataParam)postdata1.getParams()).getName()!=null)
System.out.println(“getName=“+((HarPostDataParam)postdata1.getParams()).getName());
if(((HarPostDataParam)postdata1.getParams()).getValue()!=null)
System.out.println(“getValue=“+((HarPostDataParam)postdata1.getParams()).getValue());
List postdataparams=postdata1.getParams();
for(HarPostDataParam posdatap:postdataparams)
{
postFileName=posdatap.getFileName();
postContentType=posdatap.getContentType();
postName=posdatap.getName();
postValue=posdatap.getValue();
如果((postFileName)!=null){
System.out.println(“postFileName=“+postFileName”);
} 
否则{
System.out.println(“PostFileName为空”);
}
如果((postContentType)!=null){
System.out.println(“postContentType=“+postContentType”);
}
否则{
System.out.println(“postContentType为空”);
} 
如果((postName)!=null){
System.out.println(“postName=“+postName”);
} 
否则{
System.out.println(“postName为空”);
} 
如果((postValue)!=null){
System.out.println(“postValue=“+postValue”);
} 
否则{
System.out.println(“postValue为NULL”);
} 
}
} }

谢谢,我昨天已经解决了这个问题。
从存储库下载了Browsermob代理的最新来源,并构建了它们,发布数据现在包含所有发布的参数:-)

有人可以对此进行回复吗,请harRequest.getMethod();提供POST命令,但harRequest.getPostData()始终提供NULL instead在POST命令期间,postdataparams的大小为零,这意味着它不包含任何有效的数据postdataparams.size()=0对此plz有什么见解吗?大家好,有人在java中将har库与webdriver集成,并成功获得POST命令的POSTDATA吗?我尝试直接将数据转储到.har文件中。尽管如此,我仍然可以看到只有POST命令被发送,但是随它一起发送的数据在har文件中丢失了。我的代码是har-har=server.getHar();请尝试{har.writeTo(新文件(“c:\\test1.har”);}catch(IOException e){e.printStackTrace();}希望有人能回复,谢谢