Example #1
0
import ddt
from time import sleep
import xlrd
from selenium import webdriver
import unittest
from pages.login_page import LoginPage
from common.read_excel import ExcelUtil

path = xlrd.open_workbook(
    'D:\\all_test_dir\\my_test_for_web_1\\common\\databases.xls')
datas = ExcelUtil(path)
testdatas = datas.dict_data()


@ddt.ddt
class Test_login(unittest.TestCase):
    def login_case(self, user, password, expect):
        self.login.send_user(user)
        self.login.send_password(password)
        self.login.click_submit()
        result = self.login.get_user_name()
        print(result)
        self.assertTrue(result == expect)

    @classmethod
    def setUpClass(cls):
        cls.driver = webdriver.Firefox()
        cls.login = LoginPage(cls.driver)

    def setUp(self):
        self.driver.get('https://leisongwei.5upm.com/my/')
Example #2
0
from common.login_page import LoginPage
from common.read_excel import ExcelUtil
import unittest
import ddt
import os
login_url = "http://127.0.0.1:81/zentao/user-login-L3plbnRhby8=.html"
# '''测试的数据'''
# testdates = [
#     {"user": "******", "psw": "123456", "expect": "admin"},
#     {"user": "******", "psw": "", "expect": ""},
#     {"user": "******", "psw": "123456", "expect": ""},
# ]
propath = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))  # 工程路径
filepath = os.path.join(propath, "common", "datas.xlsx")
data = ExcelUtil(filepath)
testdates = data.dict_data()
print(filepath)
print(testdates)

# filepath = "D:\\web_d\\common\\datas.xlsx"


@ddt.ddt
class LoginPageCase(unittest.TestCase):
    @classmethod
    def setUpClass(cls):
        cls.driver = webdriver.Firefox()
        cls.loginp = LoginPage(cls.driver)
        cls.driver.get(login_url)

    def setUp(self):
Example #3
0
# -*- coding: utf-8 -*-
from selenium import webdriver
from common.read_excel import ExcelUtil
from page.zentaopage import LoginBug
from page.login import Login
import os
import unittest
import ddt
#用excle表格传入
propath = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
print(propath)
filepath = os.path.join(propath,"common","data_excel.xlsx")
print(filepath)
data = ExcelUtil(filepath)
datadict = data.dict_data()
print (datadict)
@ddt.ddt
class TestE(unittest.TestCase):
    """登录页面测试案例"""
    def setUp(self):
        self.driver = webdriver.Firefox()
        self.linken = LoginBug(self.driver)
        self.linken1 = Login(self.driver)
        self.linken.is_alert()
        self.driver.delete_all_cookies()
        self.driver.refresh()
    def login_case(self,user,pswd,expect):
        """登录流程"""
        self.linken.loginpage(user,pswd)
        result = self.linken1.duanyan()
        print(result)
Example #4
0
from selenium import webdriver
from page.loginpage import LoginPage
import unittest
import ddt
from common.read_excel import ExcelUtil

# d1 = [
#     {"usr": "******", "psw": "666666", "except": True},
#     {"usr": "******", "psw": "123456", "except": False}
# ]

file_path = r"D:\autopro\testcase\testdata.xlsx"
sheet_name = "Sheet1"
data = ExcelUtil(file_path, sheet_name)
d1 = data.dict_data()


@ddt.ddt
class TestLogin(unittest.TestCase):
    """登录测试用例"""
    def setUp(self):
        self.driver = webdriver.Firefox()
        self.driver.maximize_window()
        self.stg = LoginPage(self.driver)

    @ddt.data(*d1)
    def test_login(self, test_data):
        """不同条件下的登录"""
        usr = test_data["usr"]
        psw = test_data["psw"]
        exp = test_data["except"]
Example #5
0
#encoding=utf_8
from selenium import webdriver
from pages.loginpage import Logini4u
from common.read_excel import ExcelUtil
import unittest
import os
import ddt

dirpath = os.path.realpath(__file__)
curpath = os.path.dirname(dirpath)
print(curpath)

excelpath = os.path.join(curpath,'testdata.xlsx')
print(excelpath)
data = ExcelUtil(excelpath,sheetName='Sheet1')
testdata = data.dict_data()
print(testdata)


@ddt.ddt
class LoginDdt(unittest.TestCase):
    def setUp(self):
        self.driver =webdriver.Firefox()
        self.driver.get('http://dev.i4u.net.cn/Business/login.html')
        self.i4u = Logini4u(self.driver)

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

    @ddt.data(*testdata)
    def test_login(self,data):