# coding=utf-8 import time import unittest from framework.browser_engine import BrowserEngine from pageobjects.bird_homepage import HomePage class BaiduSearch(unittest.TestCase): @classmethod def setUpClass(cls): browse = BrowserEngine(cls) cls.driver = browse.open_browser(cls) @classmethod def tearDownClass(cls): cls.driver.quit() def test_baidu_search(self): homepage = HomePage(self.driver) homepage.type_search('xx', 'xxx') # homepage.send_submit_btn() self.driver.find_element_by_xpath("/html/body/div/div[2]/form/input[3]").click() tempUrl = self.driver.find_element_by_link_text( self.driver.find_element_by_xpath("/html/body/div[1]/div[2]/a[1]").text).get_attribute('href') # print self.driver.find_element_by_xpath("/html/body/div[1]/div[2]/a[1]").text # tempUrl=self.driver.current_url L = tempUrl.split('u=')[0] usernameOpen = 14852 openUrl = L + "u=" + str(usernameOpen) self.driver.get(openUrl) print tempUrl time.sleep(35) if __name__ == '__main__': unittest.main()