public static class WDLibrary.WD_XMLHttpRequest extends XMLHttpRequest
XMLHttpRequest
, through WDLibrary
to execute javascript
JavaScriptFunctions.sendHttpRequest(Map)
to handle HTTP Request. If the execution
is asynchronous, some value of IHttpRequest.Key
will be stored in javascript global variables,
and they can be retrieved later.XMLHttpRequest
XMLHttpRequest.AjaxReadyState
IHttpRequest.HttpCommand, IHttpRequest.HttpHeader, IHttpRequest.HttpResponseStatus, IHttpRequest.Key
VARIABLE_READY_STATE, VARIABLE_RESPONSE_HEADERS, VARIABLE_RESPONSE_TEXT, VARIABLE_RESPONSE_XML, VARIABLE_STATUS, VARIABLE_STATUS_TEXT
Constructor and Description |
---|
WD_XMLHttpRequest() |
Modifier and Type | Method and Description |
---|---|
java.util.Map<java.lang.String,java.lang.Object> |
execute(IHttpRequest.HttpCommand command,
java.lang.String url,
boolean async,
java.util.Map<java.lang.String,java.lang.String> headers,
java.lang.String data)
Implementation: through
WDLibrary , execute JavaScriptFunctions.sendHttpRequest(Map) .For synchronous execution, all results will be stored in the returned Map result with one value of IHttpRequest.Key ;For asynchronous execution, except IHttpRequest.Key.READY_STATE , the other values will not be in the returned Map result,
they will be stored in javascript global variables: |
java.lang.String |
getHttpStatus()
Get javascript global variable
XMLHttpRequest.VARIABLE_STATUS . |
java.lang.String |
getHttpStatusText()
Get javascript global variable
XMLHttpRequest.VARIABLE_STATUS_TEXT . |
java.lang.String |
getReadyState()
Get javascript global variable
XMLHttpRequest.VARIABLE_READY_STATE . |
java.lang.Object |
getResponseHeaders()
Get javascript global variable
XMLHttpRequest.VARIABLE_RESPONSE_HEADERS . |
java.lang.String |
getResponseText()
Get javascript global variable
XMLHttpRequest.VARIABLE_RESPONSE_TEXT . |
java.lang.Object |
getResponseXml()
Get javascript global variable
XMLHttpRequest.VARIABLE_RESPONSE_XML . |
public java.util.Map<java.lang.String,java.lang.Object> execute(IHttpRequest.HttpCommand command, java.lang.String url, boolean async, java.util.Map<java.lang.String,java.lang.String> headers, java.lang.String data) throws SeleniumPlusException
WDLibrary
, execute JavaScriptFunctions.sendHttpRequest(Map)
.IHttpRequest.Key
;IHttpRequest.Key.READY_STATE
, the other values will not be in the returned Map result,
they will be stored in javascript global variables:XMLHttpRequest.VARIABLE_STATUS
: HTTP response status numberXMLHttpRequest.VARIABLE_STATUS_TEXT
: HTTP response status textXMLHttpRequest.VARIABLE_RESPONSE_HEADERS
: HTTP response headersXMLHttpRequest.VARIABLE_RESPONSE_TEXT
: HTTP response as stringXMLHttpRequest.VARIABLE_RESPONSE_XML
: HTTP response as XML data
command
- HttpCommand, the method to execute, such as 'GET', 'POST', 'PUT' etc.url
- String, the URL to requestasync
- boolean, if the HTTP request will be executed asynchronously.headers
- Mapdata
- String, the data to send with the request.IHttpRequest.Key.READY_STATE
: ready state, changes from 0 to 4, ONLY for AJAX XMLHttpRequest execution.
IHttpRequest.Key.RESPONSE_STATUS
: HTTP response status number
IHttpRequest.Key.RESPONSE_STATUS_TEXT
: HTTP response status text
IHttpRequest.Key.RESPONSE_HEADERS
: HTTP response headers
IHttpRequest.Key.RESPONSE_TEXT
: HTTP response as string
IHttpRequest.Key.RESPONSE_XML
: HTTP response as XML data
IHttpRequest.Key.READY_STATE
: ready state, changes from 0 to 4, ONLY for AJAX XMLHttpRequest execution. for other values, they are not in the Map result, we can get them from following methods:#getReadyState()
IHttpRequest.getHttpStatus()
IHttpRequest.getHttpStatusText()
IHttpRequest.getResponseText()
IHttpRequest.getResponseXml()
IHttpRequest.getResponseHeaders()
SeleniumPlusException
#getReadyState()}
public java.lang.String getReadyState()
XMLHttpRequest.VARIABLE_READY_STATE
.getReadyState
in class XMLHttpRequest
Key#READY_STATE
.IHttpRequest.execute(HttpCommand, String, boolean, Map, String)
public java.lang.Object getResponseHeaders()
XMLHttpRequest.VARIABLE_RESPONSE_HEADERS
.IHttpRequest.Key.RESPONSE_HEADERS
.IHttpRequest.execute(HttpCommand, String, boolean, Map, String)
public java.lang.String getResponseText()
XMLHttpRequest.VARIABLE_RESPONSE_TEXT
.IHttpRequest.Key.RESPONSE_TEXT
.IHttpRequest.execute(HttpCommand, String, boolean, Map, String)
public java.lang.Object getResponseXml()
XMLHttpRequest.VARIABLE_RESPONSE_XML
.IHttpRequest.Key.RESPONSE_XML
.IHttpRequest.execute(HttpCommand, String, boolean, Map, String)
public java.lang.String getHttpStatus()
XMLHttpRequest.VARIABLE_STATUS
.IHttpRequest.Key.RESPONSE_STATUS
.IHttpRequest.execute(HttpCommand, String, boolean, Map, String)
public java.lang.String getHttpStatusText()
XMLHttpRequest.VARIABLE_STATUS_TEXT
.IHttpRequest.Key.RESPONSE_STATUS_TEXT
.IHttpRequest.execute(HttpCommand, String, boolean, Map, String)
Copyright © SAS Institute. All Rights Reserved.