WebDriver principle (thirty-two) WebDriver API's

Essays and records to facilitate their access to fellow travelers.

#------------------------------------------------I ------------------------------------------- dividing line is a shame

  Learning before selenium automation, it is best to learn HTML, CSS, JavaScript and other knowledge, help to understand the principles of operation and positioning elements. About python and selenium install their own search for other information,

Here do not introduced, all examples use python3.6 + selenium execution.

#------------------------------------------------I ------------------------------------------- dividing line is a shame

 

WebDriver principle

  WebDriver in accordance with the Server-Client classic design pattern design.

  Server -side is the Remote Server , it can be any browser. When our script to start the browser, the browser is the Remote Server , its duty is to wait for the client to send the request and make a response.

  Client -side is simply our test code. We tested the code of some of the acts, such as opening a browser, jump to a specific URL and other operations based on http request is sent to be tested the way the browser, which is Remote Sever . Romete Server accepts the request, perform the appropriate action, and Response returns execution status information return value and the like.

  (1) WebDriver start the target browser, and bound to the specified port. Start browser instance as WebDriver the Remote Server .

  (2) Client terminal by CommandExcuter sent HTTPRequest to Romete Server listening port (communication protocols: The The wedriver Wire Protocol ).

  (3) Romete Server need to rely on native browser components (such as: IEDriverServer.exe , chromedriver.exe ) to transform the browser's native call.

  Python provides a logging module provides information on a standard output interface to the running application. It provides basicConfig () method is used to define basic information. Open debug module can capture client sends a request to the server.

 

rom selenium import webdriver
import logging

logging.basicConfig(level=logging.DEBUG)
driver = webdriver.Chrome()
driver.get("http://www.baidu.com")

driver.find_element_by_id('kw').send_keys('selenium')
driver.find_element_by_id('su').click()
driver.quit()

 

  basicConfig () captured log information. But basicConfig () to open the debug mode only capture sent by the client to the server POST request, but can not get the response information returned by the server. We will learn in a later article Selenium Server , by Selenium Server can obtain more detailed request and response information.

 

 

Guess you like

Origin www.cnblogs.com/lirongyang/p/11459822.html