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:
- 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
- Cross-platform Support Windows/linux/mac OS
- Support Grid
- 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