Selenium - HTTP request deatails for Selenium command

分享一个大牛的人工智能教程。零基础!通俗易懂!风趣幽默!希望你也加入到人工智能的队伍中来!请点击http://www.captainbed.net 

For each Selenium command of the automation script, a http request with a specific path is created.

When the automation script is executed, the first http request generates a new session that is specific to the browser where the automation scripts run. The session id will be used for the http requests that correspond to all other Selenium commands from the automation script.

The details of the Create New Session http request are below:

POST /session

Create a new session. The server should attempt to create a session that most closely matches the desired and required capabilities. Required capabilities have higher priority than desired capabilities and must be set for the session to be created.

JSON Parameters:

    -  An object describing the session's desired capabilities.

    -  An object describing the session's required capabilities (Optional).

Returns:

    An object describing the session's capabilities.

 

1. HTTP REQUEST TYPES

 HTTP requests are GET or POST requests

  • GET requests; get requests are generated usually for Selenium interrogation commands (commands that get information from web elements) such as

EXAMPLE

http request for checking if an element is displayed

    URL: GET /session/:sessionId/element/:id/displayed

    Purpose: Determine if an element is currently displayed.

    URL Parameters

        :sessionId - ID of the session to route the command to.

        :id - ID of the element to route the command to.

    Returns: {boolean} Whether the element is displayed.  

  • POST requests; post requests are generated usually for Selenium manipulation commands (commands that interact with web elements) such as

EXAMPLE

http request for clicking an element:

    URL: POST /session/:sessionId/element/:id/click

    Purpose: Click on an element.

    URL Parameters

        :sessionId - ID of the session to route the command to.

        :id - ID of the element to route the command to.

The communication between the client (computer that runs the test automation scripts) and the browser driver uses the HTTP and JSON wire protocol.

 

2. HTTP REQUEST PARAMETERS

 The HTTP requests use the following types of parameters:

  • URL parameters

EXAMPLE

http request for clicking an element

    URL:  POST /session/:sessionId/element/:id/click

    URL Parameters:

        :sessionId - ID of the session to route the command to.

        :id - ID of the element to route the command to.

  • JSON parameters

EXAMPLE

http request for finding an element

    URL: POST /session/:sessionId/element

    URL Parameters:

        :sessionId - ID of the session to route the command to.

    JSON Parameters

        using - {string} The locator strategy to use.

        value - {string} The search target.

 

3. HTTP REQUEST RESULT

 The result of a HTTP request can be:

  • a value

EXAMPLE

http request for getting the title of the current page

    URL: GET /session/:sessionId/title

    URL Parameters

        :sessionId - ID of the session to route the command to.

    Returns:  {string} The current page title.

  • a JSON object

EXAMPLE

http request for finding an element

    URL: POST /session/:sessionId/element

    URL Parameters

        :sessionId - ID of the session to route the command to.

    JSON Parameters

        using - {string} The locator strategy to use.

        value - {string} The search target.

    Returns: A WebElement JSON object for the located element.

相关推荐
©️2020 CSDN 皮肤主题: 书香水墨 设计师:CSDN官方博客 返回首页