Preface:
Selenium supports Web browser automation , it provides a set of test functions to support Web automation testing . The functions are very flexible and can be used to locate interface elements, jump windows, compare results and so on. Support for multiple browsers , multiple programming languages (Java, C#, Python, Ruby, PHP , etc.), support for multiple operating systems (Windows, Linux, IOS, Android , etc.), open source and free.
It consists of three main tools:WebDriver、IDE、Grid。
Selenium Architecture:
The Selenium scripting is done on the client, and the script is passed to the Selenium server, which uses a browser driver to interact with the browser.
Selenium core components:
- WebDriver uses the api provided by the browser to control the browser, as if the user is operating the browser, and is not intrusive.
- IDE is a Chrome and Firefox extension plugin that records user actions in the browser.
- Grid for Selenium Distributed, you can run test cases in multiple browsers and operating systems.
Methodology Introduction:
- () can be used to get the current time, can format the time as a string, etc.
- WebDriver provides a screenshot method get_screenshot_as_file() to capture the current page.
- get_screenshot_as_file() is generally used for automated test pages to throw exceptions and to save test information.
I. Time-date formatting notation in python
- %y Two-digit year indication (00-99)
- %Y Four-digit year indication (000-9999)
- %m Month (01-12)
- %d Day of the month (0-31)
- %H 24-hour clock hours (0-23)
- %I 12-hour clock hours (0-12)
- %M minutes (0-59)
- %S seconds (00-59)
II. Steps for use
1. import time module, webdriver class
The code is as follows:
import time from selenium import webdriver
2. Actual code operation
Summary:
This article on Python automation testing selenium specified screenshot filename method is introduced to this article, more related Python automation testing content please search for my previous articles or continue to browse the following related articles I hope you will support me in the future more!