current position:Home>Python UI automated testing

Python UI automated testing

2022-02-02 15:07:36 Panda code

selenium+unittest package , To do it ui automated testing . API/DEMO:selenium-python Chinese document (opens new window) | seleniumbase( be based on selenium encapsulation ) (opens new window) | demo project (opens new window)

# understand

Similar to reptiles , adopt html The way of source code , Snap to corresponding label , Then click through the browser event 、 Input box input 、 Double click and so on , Finalized Open the browser - Auto click / Input operation - Close the browser , This series of operations .

# demo

# coding=utf-8

from selenium import webdriver
import unittest, time
from utils.log import logger

class BaiduTest(unittest.TestCase):
    def setUp(self):
        self.driver = webdriver.Chrome("/Library/work/workspace-my/python/chromedriver")
        self.driver.implicitly_wait(30) # The implicit waiting time is 30 second 
        self.base_url = ""
    def test_baidu(self):
        driver = self.driver
        driver.get(self.base_url + "/")
        driver.find_element_by_id("kw").clear()"Input search str")#Print input unittest
        self.assertEqual(title, "unittest_ Baidu search ") 

    def tearDown(self):

if __name__ == "__main__":

copyright notice
author[Panda code],Please bring the original link to reprint, thank you.

Random recommended