Foreword
Selenium is an open source framework for automated testing of UI Web page, the browser can drive to simulate user actions. You can browse analog control operations, common browsers: Open the page, close the page, refresh, forward, backward, maximized. . .
1. Open & Close
selenium supports analog open / close the page on the browser. There is also a similar operation closed - closed the browser process. Each time the selenium test cases will open a browser process, so the need to close the browser process at the end of the test case.
driver.get ( " url " ) # Open Page driver.close () # Close driver.quit () # close the browser process
Example:
2, refresh & forward & backward
selenim supports analog browser refresh, go back, go to the next operation.
driver.refresh () # refresh driver.back () # Back driver.forward () # next page
3, to obtain property page (title & address & source)
selenium Support for title, url, source code and other attributes of the current page.
driver.title # get the page title
driver.current_url # Get the current page url
driver.page_source # get the page source
Example:
4, the browser location & size operation
selenium Support for browser size position, set the size, maximized.
driver.get_window_size () # Get size
driver.set_window_size (height, width) # sized
driver.get_window_position () # acquires position coordinates driver.set_window_position (X, Y) # Set the browser location driver.maximize_window () # Browser Maximum of
Example: