def setUpClass(cls):
     cls.driver = webdriver.Firefox()
     cls.driver.get(login_url)
     #先登录
     a = Login(cls.driver)  #起始位置
     a.login()
     cls.student = AddStudentInfo(cls.driver)
     cls.student.gengduo()
Exemple #2
0
 def setUp(self):
     global driver, check, user
     browser = Browsers(browserType)
     driver = webdriver.Chrome(browser.select_browser())
     #登录
     user = Login(driver)
     user.login(address, account, password)
     check = AssertFunction()
     self.assertTrue(check.isElementExist(driver, e_personalDetails))
     self.assertIn('homepage', driver.current_url)
Exemple #3
0
class TestLogin(unittest.TestCase):
    """测试注册/登录功能"""
    def setUp(self):
        self.driver = webdriver.Firefox()
        self.driver.get(login_url)
        self.a = Login(self.driver)

    def tearDown(self):
        self.driver.quit()

    @ddt.data(*test_datas)
    def test_login(self, data):
        """测试数据-成功 testvera1,123456"""
        print("测试数据:%s" % data)

        self.a.login(data["user"], data["psw"])
        result = self.a.is_login_success("登录成功")
        print("登录的实际结果: %s" % result)
        self.assertTrue(result == data["expect"])
Exemple #4
0
 def setUp(self):
     global driver, check, sip, group, user
     browser = Browsers(browserType)
     driver = webdriver.Chrome(browser.select_browser())
     #登录
     user = Login(driver)
     user.login(address, account, password)
     check = AssertFunction()
     self.assertTrue(check.isElementExist(driver, e_personalDetails))
     self.assertIn('homepage', driver.current_url)
     #添加线路
     sip = SipPage(driver)
     sip.into_sip()
     #添加线路
     sip.add_sip(sipAccount, sipPassword, sipIp, sipPort, city)
     #断言
     self.assertTrue(check.isElementExist(driver, e_assertSip, sipAccount))
     #添加客户组导入号码
     group = cusManage(driver)
     group.cus_manage()
     group.add_group(groupName, number)
     self.assertTrue(check.isElementExist(driver, e_deleteGroup, groupName))
Exemple #5
0
    def is_add_student_success(self, text):
        #判断text“学生名称”在列表里 包含 00:43
        #“学生名称”在当前页
        #t = self.driver.page_source #获取当前页整个html源码, 方法1
        body = ("tag name", "body") #获取当前页所有tag的名字
        t2 = self.find(body).text
        #print(t2)
        return text in t2

    def is_add_success(self,s_id):
        #第二种判断 学号,判断方法是多种多样的
        t = self.get_text(self.loc_r)
        print("获取的学号:%s" %t)
        return s_id == t #此时可以看下网页代码,如果不是纯文本,包含空格和其他时,可以用包含

if __name__ == '__main__':
    from selenium import webdriver
    driver = webdriver.Firefox()
    driver.get("http://47.104.190.48:8000/login")
    a = Login(driver)
    a.login()  #先登录
    b = AddStudentInfo(driver) #到添加学生页面
    b.gengduo()
    b.add_student("20000008", "zzzsss")

    result = b.is_add_student_success("zzzsss")
    print("结果: %s"%result)

    t3 = b.is_add_success("20000008")
    print(t3)
Exemple #6
0
 def setUpClass(cls):
     cls.driver = webdriver.Chrome()
     cls.add_free = FreeBuy(cls.driver)
     a = Login(cls.driver)
     a.login()