060web测试实战

# -*- coding:utf-8 -*-
from selenium import webdriver
import unittest                       #导入测试模块
from time import sleep
class shizhan(unittest.TestCase):
    def setUp(self):
        self.driver=webdriver.Chrome()
        self.driver.implicitly_wait(10)
        self.driver.get('https://www.baidu.com/')
    def test_baidu(self):
        driver=self.driver
        driver.find_element_by_id('kw').clear()
        driver.find_element_by_id('kw').send_keys('阿里巴巴')
        driver.find_element_by_id('su').click()
        driver.find_element_by_link_text('找阿里巴巴1688网站_上阿里巴巴').click()
        title=driver.title
        self.assertEqual(title,'阿里巴巴_百度搜索',msg='错误,找不到标题')
        sleep(4)
    def tearDown(self):
        self.driver.quit()
if __name__ == '__main__':
    shizhan.main()

 

你可能感兴趣的:(python,selenium)