51Testing软件测试论坛

标题: 脚本中有重复的代码有什么方法可以让它不冲突 [打印本页]

作者: 15889369825    时间: 2016-10-12 10:34
标题: 脚本中有重复的代码有什么方法可以让它不冲突
      driver = self.driver
        driver.get(self.base_url + "/")
        driver.find_element_by_id("submit").click()
        driver.find_element_by_id("email").clear()
        driver.find_element_by_id("email").send_keys("15889369825")
        driver.find_element_by_id("submit").click()
        driver.find_element_by_id("email").clear()
        driver.find_element_by_id("email").send_keys("@163.com")
        driver.find_element_by_id("submit").click()
        driver.find_element_by_id("email").clear()
        driver.find_element_by_id("email").send_keys("158893698256393@163.com")
        driver.find_element_by_id("submit").click()
        driver.find_element_by_id("password").clear()
        driver.find_element_by_id("password").send_keys("123456")
        driver.find_element_by_id("submit").click()
        driver.find_element_by_id("check").clear()
        driver.find_element_by_id("check").send_keys("1011")
        driver.find_element_by_id("submit").click()
        driver.find_element_by_css_selector("img.captcha-img").click()
        driver.find_element_by_id("email").clear()
        driver.find_element_by_id("email").send_keys("15889369825@163.com")
        driver.find_element_by_id("password").clear()
        driver.find_element_by_id("password").send_keys("123456789")
        driver.find_element_by_id("submit").click()
        driver.find_element_by_css_selector("img.captcha-img").click()
        driver.find_element_by_id("password").clear()
        driver.find_element_by_id("password").send_keys("123456")
        driver.find_element_by_id("submit").click()
        driver.find_element_by_link_text(u"安全退出").click()
        driver.find_element_by_css_selector("button.btn.btn-blue").click()
        driver.find_element_by_id("rember").click()
        driver.find_element_by_id("other").click()
        driver.find_element_by_id("email").clear()
        driver.find_element_by_id("email").send_keys("15889369825@163.com")
        driver.find_element_by_id("password").clear()
        driver.find_element_by_id("password").send_keys("123456")
        driver.find_element_by_id("check").clear()
        driver.find_element_by_id("check").send_keys("1111")
        driver.find_element_by_id("submit").click()
        driver.find_element_by_link_text(u"安全退出").click()
        driver.find_element_by_css_selector("button.btn.btn-blue").click()
作者: 梦想家    时间: 2016-10-12 11:27
重复的地方用循环?
作者: 15889369825    时间: 2016-10-12 11:38
梦想家 发表于 2016-10-12 11:27
重复的地方用循环?

需要怎么循环?
作者: 二二恶    时间: 2016-10-13 15:44
建议设置一下等待时间
作者: jingzizx    时间: 2017-5-8 19:57
学习




欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2