Python自动化测试执行用例
#-*-coding:utf-8-*- from selenium import webdriver import time import unittest class Function(unittest.TestCase): def setUp(self): self.driver = webdriver.Chrome() self.driver.maximize_window() def login(self,username,password): url = 'http://ics.chinasoftosg.com' self.driver.get(url) self.driver.find_element_by_name('userName').clear() self.driver.find_element_by_name('userName').send_keys(username) self.driver.find_element_by_id('password').click() self.driver.find_element_by_id('password').send_keys(password) self.driver.find_element_by_css_selector('.button').click() def test_01(self): print('test_01开始执行') self.login('******','********') self.assertEqual(self.driver.find_element_by_css_selector('.css12').text,'退出') print('test_01执行完成') def test_02(self): print('test_02开始执行') self.login('*****','******') self.assertIn('错误',self.driver.find_element_by_css_selector('#errorBox').text) print('test_02执行完成') def tearDown(self): print("测试完成!") self.driver.quit() if __name__ == '__main__': unittest.main()
钟声敲响了日落,柏油路跃过山坡,一直通向北方的是我们想象,长大后也未曾经过~