#coding=utf-8
import time
import unittest
from selenium import webdriver

class BaiduSearch(unittest.TestCase):
    def setUp(self):
        self.driver=webdriver.Chrome()
        self.driver.maximize_window()
        self.driver.implicitly_wait(8)
        self.driver.get('https://www.baidu.com')

    def tearDown(self):
        self.driver.quit()

    def test_baidu_search(self):
        self.driver.find_element_by_id('kw').send_keys('selenium')
        time.sleep(1)
        self.driver.find_element_by_id('su').click()
        time.sleep(1)
        try:
            assert 'selenium' in self.driver.title
            print('Test Pass.')

        except Exception as e:
            print('Test Fail.',format(e))

if __name__=='__main__':
    unittest.main()
