def setUp(self):
self.url = "https://m.baidu.com/sf?top=%7B%22sfhs%22%3A1%7D&anchor=0811&pd=pl&word=%E8%87%AA%E7%94%B1%E4%BE%A0"
options = webdriver.ChromeOptions()
mobileEmulation = {'deviceName': 'Galaxy Note 3'}
options.add_experimental_option('mobileEmulation', mobileEmulation)
self.driver = webdriver.Chrome(executable_path='chromedriver.exe', chrome_options=options)
self.driver.implicitly_wait(10) #最多等待10秒,隐性等待对整个driver的周期都起作用,所以一次启动只要设置一次即可
self.driver.get(self.url)
self.assertTrue(ec.title_is(u"自由侠"))
self.assertTrue(ec.visibility_of_element_located(u"自由侠"))
def tearDown(self):
self.driver.quit()
def testCase1(self):
locator = self.driver.find_element_by_xpath('//span[contains(text(), "7寸液晶仪表")]')
locator.click()