#encoding:utf-8from selenium import webdriverimport time,unittest,osimport HTMLTestRunner class TigerWeb(unittest.TestCase): def setUp(self): self.verificationErrors=[] self.driver=webdriver.Firefox() self.driver.maximize_window() self.base_url="https://dev.tigerbrokers.com/" self.driver.implicitly_wait(3) def test_login(self): u'''老虎开户用例''' driver=self.driver driver.get(self.base_url) driver.find_element_by_class_name("nav_signup").click() driver.find_element_by_name("phone").send_keys("14900000031") driver.find_element_by_name("password").send_keys("qqqqq1") driver.find_element_by_css_selector("button.btn.btn-regular.btn-submit").click() time.sleep(2) driver.find_element_by_link_text("马上开户").click() time.sleep(3) # 填写资料 driver.find_element_by_css_selector(".input-text.full-size").send_keys(u"德玛西亚") driver.find_element_by_name("pinyin_first").send_keys("dema") driver.find_element_by_name("pinyin_last").send_keys("xiya") driver.find_element_by_name("id_no").send_keys("110101198005016639") driver.find_element_by_name("email").send_keys("87565512@qq.com") driver.find_element_by_name("family").click() time.sleep(1) driver.find_element_by_xpath("html/body/div[1]/div/div/div[3]/div[1]/form/div[5]/div/ul/li[2]").click() time.sleep(2) driver.find_element_by_name("marital").click() time.sleep(2) driver.find_element_by_xpath("html/body/div[1]/div/div/div[3]/div[1]/form/div[6]/div/ul/li[2]").click() time.sleep(2) driver.find_element_by_name("job").click() time.sleep(2) driver.find_element_by_xpath("html/body/div[1]/div/div/div[3]/div[1]/form/div[7]/div/ul/li[1]").click() time.sleep(2) driver.find_element_by_name("business").click() time.sleep(2) driver.find_element_by_xpath("html/body/div[1]/div/div/div[3]/div[1]/form/div[8]/div[1]/ul/li[1]").click() time.sleep(2) driver.find_element_by_name("companyName").send_keys(u'苹果的世界') time.sleep(2) driver.find_element_by_name("province").click() time.sleep(2) driver.find_element_by_xpath("html/body/div[1]/div/div/div[3]/div[1]/form/div[10]/div[1]/ul/li[2]").click() time.sleep(2) driver.find_element_by_name("city").click() time.sleep(2) driver.find_element_by_xpath("html/body/div[1]/div/div/div[3]/div[1]/form/div[10]/div[2]/ul/li[2]").click() time.sleep(2) driver.find_element_by_name("district").click() time.sleep(2) driver.find_element_by_xpath("html/body/div[1]/div/div/div[3]/div[1]/form/div[10]/div[3]/ul/li[2]").click() time.sleep(2) driver.find_element_by_name("detailAddress").send_keys(u'天津市河北区张自忠路') time.sleep(2) driver.find_element_by_css_selector("button.btn.btn-regular.btn-next").click() time.sleep(2) #投资信息 driver.find_element_by_name("net_assets").click() time.sleep(1) driver.find_element_by_xpath("html/body/div/div/div/div[3]/div[2]/form/div[1]/div[2]/ul/li[3]").click() time.sleep(1) driver.find_element_by_name("net_current_assets").click() time.sleep(1) driver.find_element_by_xpath("html/body/div/div/div/div[3]/div[2]/form/div[2]/div[2]/ul/li[2]").click() time.sleep(1) driver.find_element_by_name("net_year_income").click() time.sleep(1) driver.find_element_by_xpath("html/body/div/div/div/div[3]/div[2]/form/div[3]/div[2]/ul/li[2]").click() time.sleep(1) driver.find_element_by_name("total_assets").click() time.sleep(1) driver.find_element_by_xpath("html/body/div/div/div/div[3]/div[2]/form/div[4]/div[2]/ul/li[2]").click() time.sleep(1) checkboxes=driver.find_elements_by_tag_name("input") for checkbox in checkboxes: if checkbox.get_attribute("value")=='0': checkbox.click() break; driver.find_element_by_name("trade_years").click() time.sleep(1) driver.find_element_by_xpath("html/body/div/div/div/div[3]/div[2]/form/div[6]/div/ul/li[2]").click() time.sleep(1) driver.find_element_by_name("trade-count-per-year").click() time.sleep(1) driver.find_element_by_xpath("html/body/div/div/div/div[3]/div[2]/form/div[7]/div/ul/li[1]").click() time.sleep(1) driver.find_element_by_name("acknowledge-level").click() time.sleep(1) driver.find_element_by_xpath("html/body/div/div/div/div[3]/div[2]/form/div[8]/div/ul/li[1]").click() time.sleep(1) driver.find_element_by_name("has-us-stock-exp").click() time.sleep(1) driver.find_element_by_xpath("html/body/div/div/div/div[3]/div[2]/form/div[9]/div/ul/li[1]").click() time.sleep(1) driver.find_element_by_xpath("html/body/div/div/div/div[3]/div[2]/div/div[1]/button").click() time.sleep(1) driver.find_element_by_xpath("html/body/div/div/div/div[3]/div[3]/div/div[2]/button").click() time.sleep(2) driver.find_element_by_name("file").click() os.system("D:\upfile.exe") time.sleep(5) driver.find_element_by_xpath("/html/body/div/div/div/div[3]/div[4]/div/form[2]/input").click() os.system("D:\upfiles.exe") time.sleep(5) driver.find_element_by_xpath("html/body/div[1]/div/div/div[3]/div[4]/div[2]/div[1]/button").click() def tearDown(self): self.driver.quit() self.assertEqual([], self.verificationErrors) if __name__=="__main__": suite=unittest.TestSuite() suite.addTest(TigerWeb("test_login")) filename="d:\\result.html" fp=file(filename,'wb') runner=HTMLTestRunner.HTMLTestRunner(stream=fp,title='Result',description='Test_resport') runner.run(suite)
selenium+老虎前端开户用例
最新推荐文章于 2022-03-14 10:35:10 发布