Selenium Remote Server Implementation principle

Source: Internet
Author: User
Tags appium

Selenium as an excellent web automation framework, by more and more enterprises to use the reason, the framework design of the comparison remarkable,

As an open-source framework, it opens up a set of protocols that take the same strategy for app-tested Appium. You are using an extended version of Webdriver protocol.

Why is it that the framework is better designed? Where the hell is it?

Look at the surface first:

    1. The Selenium Automation framework supports multiple languages, Java, Python, C #, JavaScript, Perl, Ruby ... Is it not cool to support so many languages in the test tool? Qtp/uft only supports VBS
    2. Cross-platform Support Windows/linux/mac OS
    3. Support Grid
    4. Owns Page object model and page factory

Above, are rare design, then the question came again, why selenium support so many languages, how to achieve?

I think the answer I'm giving is the protocol, selenium remote server/webdriver/appium, and so fully follow Webdriver JSON protocol

Cross-language cross-platform through the JSON protocol. If you want to learn more about the JSON protocol for Webdriver, please refer to http://www.w3.org/TR/webdriver/

If you also want to use RESTful self test download use Restclient-ui-3.5-jar-with-dependencies.jar

Let's verify this, first you need a restful client and a Chromew Ebdriver,selenium-server-standalone-2.48.0.jar

At CMD start remote server

Java-dwebdriver.chrome.driver= "Chromedriver.exe"  

Start successfully, next open browser: Open http://localhost:4444/wd/hub/static/resource/hub.html

1. Create session

2. Open Baidu

3. Create

So how is this process going to be implemented?

Look at Webdriver's protocol.

The first step is to create Session:post http://127.0.0.1:4444/wd/hub/session

You can use the above method to get the session ID

Step Two: Open Baidu

Send Post Http://localhost:4444/wd/hub/session/85a32b0f-e617-449a-bcea-8c84ffa2c5f4/url

Body:

{"url": "Http://www.baidu.com"}

Step three: Findelement by ID

Send Post Http://localhost:4444/wd/hub/session/85a32b0f-e617-449a-bcea-8c84ffa2c5f4/element

{    "using": "id",    "value": "KW"}

You can also use XPath

{    "using": "XPath",    "value": "//input[@id = ' kw ']"}

Step three: Enter selenium to get element ID 1 from the previous step

Send Post Http://localhost:4444/wd/hub/session/935821aa-6074-4fc9-bd26-eedf483d6c9d/element/1/value

Body

{    "value": [        "Selenium"    ]}

Summarize:

Selenium remote sever is actually through Webdriver JSON and browser interaction, which also explains why selenium can support a variety of languages,

Both Java python and so on are translated into JSON and interacted with the browser via the Selenium API. Master Webdriver protocol can write the request directly by himself.

Implementing interaction with the browser

Selenium Remote Server Implementation principle

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.