WebDriver命令编程手册(英文版).doc

上传人:暗伤 文档编号:96105124 上传时间:2023-09-08 格式:DOC 页数:65 大小:727.50KB
返回 下载 相关 举报
WebDriver命令编程手册(英文版).doc_第1页
第1页 / 共65页
WebDriver命令编程手册(英文版).doc_第2页
第2页 / 共65页
点击查看更多>>
资源描述

《WebDriver命令编程手册(英文版).doc》由会员分享,可在线阅读,更多相关《WebDriver命令编程手册(英文版).doc(65页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。

1、JsonWireProtocolLuke Inman-Semerau edited this pageon 26 Feb 20166 revisionsThe WebDriver Wire ProtocolStatus:OBSOLETESee current W3C specification for WebDriverIntroductionAll implementations of WebDriver that communicate with the browser, or a RemoteWebDriver server shall use a common wire protoco

2、l. This wire protocol defines aRESTful web serviceusingJSONover HTTP.The protocol will assume that the WebDriver API has been flattened, but there is an expectation that client implementations will take a more Object-Oriented approach, as demonstrated in the existing Java API. The wire protocol is i

3、mplemented in request/response pairs of commands and responses.Basic Terms and ConceptsClientThe machine on which the WebDriver API is being used.ServerThe machine running the RemoteWebDriver. This term may also refer to a specific browser that implements the wire protocol directly, such as the Fire

4、foxDriver or IPhoneDriver.SessionThe server should maintain one browser per session. Commands sent to a session will be directed to the corresponding browser.WebElementAn object in the WebDriver API that represents a DOM element on the page.WebElement JSON ObjectThe JSON representation of a WebEleme

5、nt for transmission over the wire. This object will have the following properties:KeyTypeDescriptionELEMENTstringThe opaque ID assigned to the element by the server. This ID should be used in all subsequent commands issued against the element.Capabilities JSON ObjectNot all server implementations wi

6、ll support every WebDriver feature. Therefore, the client and server should use JSON objects with the properties listed below when describing which features a session supports.KeyTypeDescriptionbrowserNamestringThe name of the browser being used; should be one ofchrome|firefox|htmlunit|internet expl

7、orer|iphone.versionstringThe browser version, or the empty string if unknown.platformstringA key specifying which platform the browser is running on. This value should be one ofWINDOWS|XP|VISTA|MAC|LINUX|UNIX. When requesting a new session, the client may specifyANYto indicate any available platform

8、 may be used.javascriptEnabledbooleanWhether the session supports executing user supplied JavaScript in the context of the current page.takesScreenshotbooleanWhether the session supports taking screenshots of the current page.handlesAlertsbooleanWhether the session can interact with modal popups, su

9、ch aswindow.alertandwindow.confirm.databaseEnabledbooleanWhether the session can interact database storage.locationContextEnabledbooleanWhether the session can set and query the browsers location context.applicationCacheEnabledbooleanWhether the session can interact with the application cache.browse

10、rConnectionEnabledbooleanWhether the session can query for the browsers connectivity and disable it if desired.cssSelectorsEnabledbooleanWhether the session supports CSS selectors when searching for elements.webStorageEnabledbooleanWhether the session supports interactions withstorage objects.rotata

11、blebooleanWhether the session can rotate the current pages current layout between portrait and landscape orientations (only applies to mobile platforms).acceptSslCertsbooleanWhether the session should accept all SSL certs by default.nativeEventsbooleanWhether the session is capable of generating nat

12、ive events when simulating user input.proxyproxy objectDetails of any proxy to use. If no proxy is specified, whatever the systems current or default state is used. The format is specified under Proxy JSON Object.Desired CapabilitiesA Capabilities JSON Object sent by the client describing the capabi

13、lities a new session created by the server should possess. Any omitted keys implicitly indicate the corresponding capability is irrelevant. More atDesiredCapabilities.Actual CapabilitiesA Capabilities JSON Object returned by the server describing what features a session actually supports. Any omitte

14、d keys implicitly indicate the corresponding capability is not supported.Cookie JSON ObjectA JSON object describing a Cookie.KeyTypeDescriptionnamestringThe name of the cookie.valuestringThe cookie value.pathstring(Optional) The cookie path.1domainstring(Optional) The domain the cookie is visible to

15、.1secureboolean(Optional) Whether the cookie is a secure cookie.1httpOnlyboolean(Optional) Whether the cookie is an httpOnly cookie.1expirynumber(Optional) When the cookie expires, specified in seconds since midnight, January 1, 1970 UTC.11When returning Cookie objects, the server should only omit a

16、n optional field if it is incapable of providing the information.Log Entry JSON ObjectA JSON object describing a log entry.KeyTypeDescriptiontimestampnumberThe timestamp of the entry.levelstringThe log level of the entry, for example, INFO (seelog levels).messagestringThe log message.Log LevelsLog l

17、evels in order, with finest level on top and coarsest level at the bottom.LevelDescriptionALLAll log messages. Used for fetching of logs and configuration of logging.DEBUGMessages for debugging.INFOMessages with user information.WARNINGMessages corresponding to non-critical problems.SEVEREMessages c

18、orresponding to critical errors.OFFNo log messages. Used for configuration of logging.Log TypeThe table below lists common log types. Other log types, for instance, forperformance logging may also be available.Log TypeDescriptionclientLogs from the client.driverLogs from the webdriver.browserLogs fr

19、om the browser.serverLogs from the server.Proxy JSON ObjectA JSON object describing a Proxy configuration.KeyTypeDescriptionproxyTypestring(Required) The type of proxy being used. Possible values are:direct- A direct connection - no proxy in use,manual- Manual proxy settings configured, e.g. setting

20、 a proxy for HTTP, a proxy for FTP, etc,pac- Proxy autoconfiguration from a URL,autodetect- Proxy autodetection, probably with WPAD,system- Use system settingsproxyAutoconfigUrlstring(Required if proxyType =pac, Ignored otherwise) Specifies the URL to be used for proxy autoconfiguration. Expected fo

21、rmat example:1234/pacfileftpProxy, httpProxy, sslProxy, socksProxystring(Optional, Ignored if proxyType !=manual) Specifies the proxies to be used for FTP, HTTP, HTTPS and SOCKS requests respectively. Behaviour is undefined if a request is made, where the proxy for the particular protocol is undefin

22、ed, if proxyType ismanual. Expected format example: :1234socksUsernamestring(Optional, Ignored if proxyType !=manualand socksProxy is not set) Specifies SOCKS proxy username.socksPasswordstring(Optional, Ignored if proxyType !=manualand socksProxy is not set) Specifies SOCKS proxy password.noProxyst

23、ring(Optional, Ignored if proxyType !=manual) Specifies proxy bypass addresses. Format is driver specific.MessagesCommandsWebDriver command messages should conform to theHTTP/1.1 request specification. Although the server may be extended to respond to other content-types, the wire protocol dictates

24、that all commands accept a content-type ofapplication/json;charset=UTF-8. Likewise, the message bodies for POST and PUT request must use anapplication/json;charset=UTF-8content-type.Each command in the WebDriver service will be mapped to an HTTP method at a specific path. Path segments prefixed with

25、 a colon (:) indicate that segment is a variable used to further identify the underlying resource. For example, consider an arbitrary resource mapped as:GET /favorite/color/:nameGiven this mapping, the server should respond to GET requests sent to /favorite/color/Jack and /favorite/color/Jill, with

26、the variable:nameset to Jack and Jill, respectively.ResponsesCommand responses shall be sent asHTTP/1.1 response messages. If the remote server must return a 4xx response, the response body shall have a Content-Type of text/plain and the message body shall be a descriptive message of the bad request

27、. For all other cases, if a response includes a message body, it must have a Content-Type of application/json;charset=UTF-8 and will be a JSON object with the following properties:KeyTypeDescriptionsessionIdstringnullstatusnumberA status code summarizing the result of the command. A non-zero value i

28、ndicates that the command failed.value*The response JSON value.Response Status CodesThe wire protocol will inherit its status codes from those used by the InternetExplorerDriver:CodeSummaryDetail0SuccessThe command executed successfully.6NoSuchDriverA session is either terminated or not started7NoSu

29、chElementAn element could not be located on the page using the given search parameters.8NoSuchFrameA request to switch to a frame could not be satisfied because the frame could not be found.9UnknownCommandThe requested resource could not be found, or a request was received using an HTTP method that

30、is not supported by the mapped resource.10StaleElementReferenceAn element command failed because the referenced element is no longer attached to the DOM.11ElementNotVisibleAn element command could not be completed because the element is not visible on the page.12InvalidElementStateAn element command

31、 could not be completed because the element is in an invalid state (e.g. attempting to click a disabled element).13UnknownErrorAn unknown server-side error occurred while processing the command.15ElementIsNotSelectableAn attempt was made to select an element that cannot be selected.17JavaScriptError

32、An error occurred while executing user supplied JavaScript.19XPathLookupErrorAn error occurred while searching for an element by XPath.21TimeoutAn operation did not complete before its timeout expired.23NoSuchWindowA request to switch to a different window could not be satisfied because the window c

33、ould not be found.24InvalidCookieDomainAn illegal attempt was made to set a cookie under a different domain than the current page.25UnableToSetCookieA request to set a cookies value could not be satisfied.26UnexpectedAlertOpenA modal dialog was open, blocking this operation27NoAlertOpenErrorAn attem

34、pt was made to operate on a modal dialog when one was not open.28ScriptTimeoutA script did not complete before its timeout expired.29InvalidElementCoordinatesThe coordinates provided to an interactions operation are invalid.30IMENotAvailableIME was not available.31IMEEngineActivationFailedAn IME eng

35、ine could not be started.32InvalidSelectorArgument was an invalid selector (e.g. XPath/CSS).33SessionNotCreatedExceptionA new session could not be created.34MoveTargetOutOfBoundsTarget provided for a move action is out of bounds.The client should interpret a 404 Not Found response from the server as

36、 an Unknown command response. All other 4xx and 5xx responses from the server that do not define a status field should be interpreted as Unknown error responses.Error HandlingThere are two levels of error handling specified by the wire protocol: invalid requests and failed commands.Invalid RequestsA

37、ll invalid requests should result in the server returning a 4xx HTTP response. The response Content-Type should be set to text/plain and the message body should be a descriptive error message. The categories of invalid requests are as follows:Unknown CommandsIf the server receives a command request

38、whose path is not mapped to a resource in the REST service, it should respond with a404 Not Foundmessage.Unimplemented CommandsEvery server implementing the WebDriver wire protocol must respond to every defined command. If an individual command has not been implemented on the server, the server shou

39、ld respond with a501 Not Implementederror message. Note this is the only error in the Invalid Request category that does not return a4xxstatus code.Variable Resource Not FoundIf a request path maps to a variable resource, but that resource does not exist, then the server should respond with a404 Not

40、 Found. For example, if IDmy-sessionis not a valid session ID on the server, and a command is sent toGET /session/my-session HTTP/1.1, then the server should gracefully return a404.Invalid Command MethodIf a request path maps to a valid resource, but that resource does not respond to the request met

41、hod, the server should respond with a405 Method Not Allowed. The response must include an Allows header with a list of the allowed methods for the requested resource.Missing Command ParametersIf a POST/PUT command maps to a resource that expects a set of JSON parameters, and the response body does n

42、ot include one of those parameters, the server should respond with a400 Bad Request. The response body should list the missing parameters.Failed CommandsIf a request maps to a valid command and contains all of the expected parameters in the request body, yet fails to execute successfully, then the s

43、erver should send a 500 Internal Server Error. This response should have a Content-Type ofapplication/json;charset=UTF-8and the response body should be a well formed JSON response object.The response status should be one of the defined status codes and the response value should be another JSON objec

44、t with detailed information for the failing command:KeyTypeDescriptionmessagestringA descriptive message for the command failure.screenstring(Optional) If included, a screenshot of the current page as a base64 encoded string.classstring(Optional) If included, specifies the fully qualified class name

45、 for the exception that was thrown when the command failed.stackTracearray(Optional) If included, specifies an array of JSON objects describing the stack trace for the exception that was thrown when the command failed. The zeroeth element of the array represents the top of the stack.Each JSON object

46、 in the stackTrace array must contain the following properties:KeyTypeDescriptionfileNamestringThe name of the source file containing the line represented by this frame.classNamestringThe fully qualified class name for the class active in this frame. If the class name cannot be determined, or is not

47、 applicable for the language the server is implemented in, then this property should be set to the empty string.methodNamestringThe name of the method active in this frame, or the empty string if unknown/not applicable.lineNumbernumberThe line number in the original source file for the frame, or 0 if unknown.Resource MappingResources in the WebDriver REST service are mapped to individual URL pa

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 技术资料 > 技术方案

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知淘文阁网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号© 2020-2023 www.taowenge.com 淘文阁