- Selenium is a set of tools for automating browsers
- Selenium IDE: This is a Firefox add-in used to record and play back the Selenium scripts with Firefox.
- Selenium WebDriver: This is a programming interface for developing advanced Selenium scripts using programming languages.
- Installing the Seleniun package: pip install -U selenium
- The selenium.webdriver module implements the browser driver classes that are supported by Selenium, including Firefox, Chrome, Interne Explorer, Safari, and various other browsers, and RemoteWebDriver to test on browsers that are hosted on remote machines
- Test Fixture: By using a test fixture, we can define the prepartion needed to perform one or more tests and any associated clean-up actions
- Test Case: A test case is the smallest unit of testing in unittest. It checks for a specific response to a particular set of actions and inputs using various assert methods provided by the unitest library. The unittest library provides a base class called TestCase that may be used to create new test cases.
- Test Suite: A test suite is a collection of multiple tests or test cases to create groups of tests representing specific functionality or modules of the application under test, which will be executed together.
- The starting point for test cases is the setUp() method, which we can use to perform some tasks at the start of each test or all the tests that will be defined in the class. The method takes no arguments and doesn't return anything. When a setUp() method is defined, the test runner will run that method prior to each test method.
- For each test method that the test runner finds, it executes the setUp() method before executing the test method.
- How about sharing a single Firefox instance between the methods instead of creating a new instance every time? This can be done by using the setUpClass() and tearDownClass() methods and using the @classmethod decorator. These methods allow us to initialize values at the classes level instead of the method level and then share these values between hte test methods.
- Using the TestSuites feature of unittest, we can collect various tests into logical groups and then into a unified test suite that can be run with a single command
- Selenium provides various find_element_by methods to find elements on a web page. These methods search for an element based on the criteria supplied to them. If a matching element is found, an instance of WebElement is returned or the NoSuchElementException exception is thrown if Selenium is not able to find any element matching the search criteria
- To create a data-driven test we need to use the @ddt decorator for the test class and use the @data decorator on the data-driven test methods.
- The @data decorator takes as many arguments as we have values that we want to feed to the test.
- The page object pattern is making tests separate from low-level actions, and providing a high-level abstraction.
- The page object pattern offers creating an object representing each web page from the application under test. We can define classes for each page, modeling all attributes and actions for that page.
<Learning Selenium Testing Tools with Python>
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- 1.整体效果首先看下android5.0以上的转场动画用共享元素实现以及配合补间动画和圆形缩放动画实现的activ...