class Sousuo(): def __init__(self): self.driver = Login().driver def sousuo(self,a): self.driver.find_element_by_name("keywords").clear() self.driver.find_element_by_name("keywords").send_keys(a) self.driver.find_element_by_class_name("fm_hd_btm_shbx_bttn").click()
class Denglu(): def __init__(self): self.driver = Login().driver def denglu(self, a, b): self.driver.find_element_by_xpath( "//*[@id=\"ECS_MEMBERZONE\"]/a[1]").click() time.sleep(2) self.driver.find_element_by_name("username").send_keys(a) self.driver.find_element_by_name("password").send_keys(b) self.driver.find_element_by_name("submit").click() def alert(self): return self.driver.switch_to.alert def guanbi(self): self.driver.quit()
class Gouwuche(): def __init__(self): self.driver = Login().driver def xiugai1(self): self.driver.find_elements_by_class_name("f6")[0].click() def xiugai2(self, mingzi, dizhi, tel, email, youbian, shoujihao): self.driver.find_elements_by_name("f6")[1].click() self.driver.find_element_by_name("consignee").send_keys(mingzi) self.driver.find_element_by_name("address").send_keys(dizhi) self.driver.find_element_by_name("tel").send_keys(tel) self.driver.find_element_by_name("email").send_keys(email) self.driver.find_element_by_name("zipcode").send_keys(youbian) self.driver.find_element_by_name("mobile").send_keys(shoujihao) self.driver.find_elements_by_class_name("bnt_blue_2")[0].click() def shiyongyue(self, a): self.driver.find_element_by_name("surplus").send_keys(a) def shiyongjifen(self, a): self.driver.find_element_by_name("integral").send_keys(a) def shiyonghongbao(self, a): self.driver.find_element_by_name("bonus_sn").send_keys(a) self.driver.find_element_by_name("validate_bonus").click() def dingdanfuyan(self, a): self.driver.find_element_by_name("postscript").send_keys(a) def peisongshifou(self): self.driver.find_element_by_name("need_insure").click() def tijiaodingdan(self): self.driver.find_element_by_xpath( "//*[@id=\"theForm\"]/div[11]/div[2]/input[1]").click()
class ZHUCE(unittest.TestCase): @classmethod def setUpClass(self): #所有用例执行前 self.driver=Login().driver pass @classmethod def tearDownClass(self): Denglu().guanbi() pass def setUp(self): #每次用例执行前执行一次 Zhuce().zhuce001() pass def tearDown(self): # Denglu().guanbi() pass #用例按照ascii顺序执行, 0-9 A-Z a-z def test_001(self): Zhuce().zhuce("dasds","*****@*****.**","123456","","","","","18410178656","dalian") Zhuce().question(6) Zhuce().submit() time.sleep(2) self.msg=Denglu().alert() shiji=self.msg.text yuqi=u"两次输入密码不一致" print (shiji) #点击确定按钮 Denglu().alert().accept() self.assertIn(yuqi,shiji,msg=u"对比失败") pass def test_002(self): Zhuce().zhuce("dasds", "*****@*****.**", "", "", "", "", "", "18410178656", "dalian") Zhuce().question(6) Zhuce().submit() time.sleep(2) self.msg = Denglu().alert() shiji = self.msg.text yuqi = u"登录密码不能为空" print(shiji) # 点击确定按钮 Denglu().alert().accept() self.assertIn(yuqi, shiji, msg=u"对比失败") pass def test_003(self): # Zhuce().zhuce("", "", "", "", "", "", "", "", "") # Zhuce().question(6) Zhuce().submit() time.sleep(2) self.msg = Denglu().alert() shiji = self.msg.text yuqi = u"登录密码不能为空" print(shiji) # 点击确定按钮 Denglu().alert().accept() self.assertIn(yuqi, shiji, msg=u"对比失败") pass def test_004(self): # Zhuce().question(6) self.driver.find_element_by_name("username").send_keys("123456") Zhuce().submit() time.sleep(2) self.msg = Denglu().alert() shiji = self.msg.text yuqi = u"登录密码不能为空" print(shiji) # 点击确定按钮 Denglu().alert().accept() self.assertIn(yuqi, shiji, msg=u"对比失败") pass
class Zhuce(): def __init__(self): self.driver = Login().driver def zhuce001(self): self.driver.find_element_by_xpath( "//*[@id=\"ECS_MEMBERZONE\"]/a[2]").click() time.sleep(2) pass def zhuce(self, name, email, password, password2, qq, bangong, jiating, shoujihao, wenti): self.driver.find_element_by_name("username").send_keys(name) self.driver.find_element_by_name("email").send_keys(email) self.driver.find_element_by_name("password").send_keys(password) self.driver.find_element_by_name("confirm_password").send_keys( password2) self.driver.find_element_by_name("extend_field2").send_keys(qq) self.driver.find_element_by_name("extend_field3").send_keys(bangong) self.driver.find_element_by_name("extend_field4").send_keys(jiating) self.driver.find_element_by_name("extend_field5").send_keys(shoujihao) self.driver.find_element_by_name("passwd_answer").send_keys(wenti) def question(self, a=None): if a != None: self.driver.find_element_by_name("sel_question").click() time.sleep(2) self.driver.find_element_by_xpath( "/html/body/div[3]/div[3]/div[1]/form/table/tbody/tr[10]/td[2]/select/option[" + str(a) + "]").click() def submit(self): self.driver.find_element_by_name("Submit").click()