# 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 ()
Selenium Python Automation note modify the link and open it based on the response property of the XPath find location