def test_login(self): driver = self.driver driver.get(self.base_url) time.sleep(2) wgj.wgj_login(self, "chenlu", "000000") time.sleep(2) self.assertEqual("CHENLU", driver.find_element_by_xpath("//*[@id=\"header\"]/header/div[4]/ul/li/a/span/span").text) self.driver.get_screenshot_as_file("F:\photo\o_1.jpg") wgj.wgj_logout(self) time.sleep(3) wgj.wgj_login(self,"chenlu",'000001') self.assertEqual(u"用户名或密码错误", driver.find_element_by_css_selector("div.toast-message").text) self.driver.get_screenshot_as_file("F:\photo\o_2.jpg") time.sleep(3) time.sleep(3) wgj.wgj_login(self,'chenlu','') self.assertEqual(u"密码不能为空", driver.find_element_by_xpath("//div[@id='content']/section/div/div/div/div/div/div/form/fieldset/span/font").text) self.driver.get_screenshot_as_file("F:\photo\o_3.jpg") time.sleep(3) wgj.wgj_login(self,'chenl','000000') self.assertEqual(u"账户不存在", driver.find_element_by_css_selector("div.toast-message").text) self.driver.get_screenshot_as_file("F:\photo\o_4.jpg") time.sleep(3) wgj.wgj_login(self,'','000000') self.assertEqual(u"用户名不能为空", driver.find_element_by_xpath("//div[@id='content']/section/div/div/div/div/div/div/form/fieldset/span/font").text) self.driver.get_screenshot_as_file("F:\photo\o_5.jpg") time.sleep(3)
def test_receiveorder(self): driver = self.driver driver.get(self.base_url) time.sleep(3) wgj.wgj_login(self,"feiziying","666666") time.sleep(3) driver.find_element_by_xpath(u"//a/span[contains(text(),'订单管理')]").click() time.sleep(3) driver.find_element_by_xpath("//a[contains(@href, '#/supplierOrderSystem/normalOrder/userServiceOrderList')]").click() time.sleep(3) driver.find_element_by_link_text(u"全部").click() time.sleep(3) driver.find_element_by_xpath(u"//div[@id='content']/section/div/div[2]/div/div/div/div[2]/div/div/ul/li/table/tbody/tr/td[9]/button/span[contains(text(),'接单')]").click() time.sleep(3) driver.find_element_by_xpath("//md-radio-button/div/div").click() time.sleep(3) driver.find_element_by_xpath("//md-dialog-actions/div/button/span").click() time.sleep(3) driver.find_element_by_xpath(u"//div[@id='content']/section/div/div[2]/div/div/div/div[2]/div/div/ul/li/table/tbody/tr/td[9]/button/span[contains(text(),'上门服务')]").click() time.sleep(3) driver.find_element_by_xpath("//md-dialog-actions/button").click() time.sleep(3) driver.find_element_by_xpath(u"//div[@id='content']/section/div/div[2]/div/div/div/div[2]/div/div/ul/li/table/tbody/tr/td[9]/button/span[contains(text(),'确认服务完成')]").click() time.sleep(5) driver.find_element_by_xpath("//md-dialog-actions/button[2]").click() time.sleep(5) driver.find_element_by_xpath("//md-dialog-actions/button").click() time.sleep(5) wgj.wgj_logout(self) time.sleep(5)
def test_user_error(self): driver = self.driver driver.get(self.base_url) time.sleep(2) wgj.wgj_login(self, 'chenl', '000000') self.assertEqual( u"账户不存在", driver.find_element_by_css_selector("div.toast-message").text) self.driver.get_screenshot_as_file("F:\photo\o_4.jpg") time.sleep(2)
def test_creatorder(self): driver = self.driver driver.get(self.base_url) time.sleep(3) wgj.wgj_login(self,"chenlu","000000") time.sleep(3) driver.find_element_by_xpath("//ul[@id='nav']/li[7]/a/span").click() driver.find_element_by_xpath("//li[7]/ul/li/a/span").click() driver.find_element_by_xpath("//input[@type='text']").click() driver.find_element_by_xpath("//input[@type='text']").clear() driver.find_element_by_xpath("//input[@type='text']").send_keys(u"测试渠道cl") driver.find_element_by_link_text(u"测试渠道cl").click() driver.find_element_by_xpath("(//input[@type='text'])[2]").click() driver.find_element_by_xpath("(//input[@type='text'])[2]").clear() driver.find_element_by_xpath("(//input[@type='text'])[2]").send_keys("1") driver.find_element_by_name("phone").click() driver.find_element_by_name("phone").clear() driver.find_element_by_name("phone").send_keys("13476006547") driver.find_element_by_xpath("//div[@id='content']/section/div/div/div[4]/form/div[2]/button/span").click() driver.find_element_by_xpath("//tr[9]/td/md-radio-button/div/div").click() driver.find_element_by_xpath("//div[@id='content']/section/div/div/div[5]/div[6]/button").click() driver.find_element_by_xpath("//div[@id='content']/section/div/div/div/div/md-input-container/input").click() driver.find_element_by_xpath("//div[@id='content']/section/div/div/div/div/md-input-container/input").clear() driver.find_element_by_xpath("//div[@id='content']/section/div/div/div/div/md-input-container/input").send_keys("cl") time.sleep(3) driver.find_element_by_xpath("//div[@id='content']/section/div/div/div/div[4]/md-input-container/button").click() time.sleep(3) driver.find_element_by_xpath(u"(//a[contains(text(),'购买')])[3]").click() driver.find_element_by_xpath(u"(//a[contains(text(),'购买')])[3]").click() driver.find_element_by_xpath(u"//a[contains(text(),'立即购买')]").click() time.sleep(3) driver.find_element_by_xpath("(//button[@type='button'])[2]").click() time.sleep(3) driver.find_element_by_xpath("//div[@id='content']/section/div/md-input-container[2]/button").click() time.sleep(5) driver.find_element_by_xpath("//md-dialog-actions/button/span").click() time.sleep(5) wgj.wgj_logout(self) time.sleep(5)
def test_user_null(self): driver = self.driver driver.get(self.base_url) time.sleep(2) wgj.wgj_login(self, '', '000000') self.assertEqual( u"用户名不能为空", driver.find_element_by_xpath( "//div[@id='content']/section/div/div/div/div/div/div/form/fieldset/span/font" ).text) self.driver.get_screenshot_as_file("F:\photo\o_5.jpg") time.sleep(2)
def test_login(self): driver = self.driver driver.get(self.base_url) time.sleep(2) wgj.wgj_login(self, 'chenlu', '000000') time.sleep(2) self.assertEqual( "CHENLU", driver.find_element_by_xpath( "//*[@id=\"header\"]/header/div[4]/ul/li/a/span/span").text) self.driver.get_screenshot_as_file("F:\photo\o_1.jpg") wgj.wgj_logout(self)