Пример #1
0
    def setUp(self) -> None:

        self.driver = browser_type("chr")
        self.driver.implicitly_wait(10)
        self.lp = LoginPage(self.driver, LoginPage.url)
        self.ip = UserCenterPage(self.driver, UserCenterPage.url)
        self.sp = SearchPage(self.driver, SearchPage.url)
        self.add = AddCart(self.driver, AddCart.url)
        self.shop = Shop(self.driver, Shop.url)
        self.r = Register(self.driver, Register.url)
Пример #2
0
 def test_ip_address_success(self):
     '''ip地址格式正确'''
     ipo = IPConfigPage(self.driver)
     lpo = LoginPage(self.driver)
     lpo.click_ip_btn()
     ipo.ipconfig_action("172.16.12.223")
     # print(lpo.login_title())
     # self.assertEqual(lpo.login_title(), u"帐号登录", msg=u"失败原因:校验元素失败")
     # print(u"IP配置成功")
     result = driverwait.find_toast(self.driver, "保存成功")
     print(u"配置IP信息结果为:%s" % result)
     function.insert_image(self.driver, "ip_address_success.jpg")
Пример #3
0
 def test_ip_address_error(self):
     '''ip地址格式错误'''
     ipo = IPConfigPage(self.driver)
     LoginPage(self.driver).click_ip_btn()
     ipo.open()
     ipo.ipconfig_action("172.16.12.22a")
     self.assertEqual(ipo.ip_setting_title(), u"配置信息", msg=u"失败原因:校验元素失败")
     print(u"IP配置失败")
     function.insert_image(self.driver, "ip_address_error.jpg")
Пример #4
0
 def test_ip_address_null(self):
     '''ip地址为空保存'''
     ipo = IPConfigPage(self.driver)
     ipo.open()
     LoginPage(self.driver).click_ip_btn()
     ipo.ipconfig_action(" ")
     self.assertEqual(ipo.ip_setting_title(), u"配置信息", msg=u"失败原因:校验元素失败")
     print(u"IP配置失败")
     function.insert_image(self.driver, "ip_address_null.jpg")
Пример #5
0
def login_env():
    driver = webdriver.Chrome()
    driver.maximize_window()
    driver.get(login_page_url)
    login_page = LoginPage(driver)

    yield [driver, login_page]

    driver.quit()
Пример #6
0
 def test_login_user_pwd_error(self):
     '''用户名或密码错误'''
     po = LoginPage(self.driver)
     po.open()
     character = random.choice('zyxwvutsrqponmlkjihgfedcba')
     username = "******" + character
     po.login_action(username, "$#%#")
     sleep(2)
     print(po.login_error_hint())
     self.assertEqual(po.login_error_hint(), '帐号或密码错误')
     function.insert_img(self.driver, "user_pwd_error.jpg")
Пример #7
0
 def test_login_pwd_null(self):
     '''密码为空登录'''
     po = LoginPage(self.driver)
     po.open()
     po.login_action('abc', '')
     sleep(2)
     self.assertEqual(po.login_error_hint(), '请输入密码')
     function.insert_img(self.driver, 'pwd_null.jpg')
Пример #8
0
 def test_login_user_pwd_null(self):
     '''用户名密码为空登录'''
     po = LoginPage(self.driver, self.url, u'网易')
     po.open()
     po.login_action('', '')
     sleep(2)
     self.assertEqual(po.login_error_hint(), u'请输入帐号')
     function.insert_img(self.driver, 'user_pwd_null.png')
Пример #9
0
 def test_login_success(self):
     '''用户名、密码正确,登录成功'''
     po = LoginPage(self.driver)
     po.open()
     user = "******"
     po.login_action(user, "qwer1234")
     sleep(2)
     po2 = MailPage(self.driver)
     print(po2.login_success_user())
     self.assertEqual(po2.login_success_user(), user + "@163.com")
     function.insert_img(self.driver, "success.jpg")
Пример #10
0
 def test_login_user_null(self):
     '''用户名为空'''
     #配置IP地址
     ipo = IPConfigPage(self.driver)
     lpo = LoginPage(self.driver)
     lpo.click_ip_btn()
     ipo.ipconfig_action("172.16.12.223")
     #配置登录信息
     lpo.login_action("", "")
     result = driverwait.find_toast(self.driver, u'账号为空')
     print(u"用户名和密码为空校验结果%s" % result)
     function.insert_image(self.driver, "login_user_null.jpg")
Пример #11
0
 def test_login_user_pwd_error(self):
     '''用户名或者密码错误'''
     # 配置IP地址
     ipo = IPConfigPage(self.driver)
     lpo = LoginPage(self.driver)
     lpo.click_ip_btn()
     ipo.ipconfig_action("172.16.12.223")
     # 配置登录信息
     lpo.login_action("fourfd", "145278")
     result = driverwait.find_toast(self.driver, u'账号不存在')
     print(u"密码为空校验结果:%s" % result)
     function.insert_image(self.driver, "login_user_pwd_error.jpg")
Пример #12
0
 def test_login_sucess(self):
     '''用户名和密码正常'''
     # 配置IP地址
     ipo = IPConfigPage(self.driver)
     lpo = LoginPage(self.driver)
     lpo.click_ip_btn()
     ipo.ipconfig_action("172.16.12.223")
     # 配置登录信息
     lpo.login_action("fourf", "123456")
     result = driverwait.find_toast(self.driver, "会议列表")
     print(u"登录成功:%s" % result)
     function.insert_image(self.driver, "login_success.jpg")
Пример #13
0
 def test_login(self, data, browser):
     lg = LoginPage(browser)
     lg.login(data['user'], data['pwd'])
     print('这是一个登录的')
Пример #14
0
 def setUpClass(cls) -> None:
     cls.driver = webdriver.Chrome()
     cls.lp = LoginPage(cls.driver)
     cls.pg = Product(cls.driver)
Пример #15
0
 def test_login(self):
     lp = LoginPage(self.driver, LoginPage.url)
     self.assertTrue(lp.assert_text('liuxu', '111111'))
Пример #16
0
 def test_login(self, data, browser):
     lg = LoginPage(browser)
     lg.login(data['user'], data['pwd'])
     text = lg.assert_text()
     assert text == data['text']
Пример #17
0
class TestCase(unittest.TestCase):
    def setUp(self) -> None:

        self.driver = browser_type("chr")
        self.driver.implicitly_wait(10)
        self.lp = LoginPage(self.driver, LoginPage.url)
        self.ip = UserCenterPage(self.driver, UserCenterPage.url)
        self.sp = SearchPage(self.driver, SearchPage.url)
        self.add = AddCart(self.driver, AddCart.url)
        self.shop = Shop(self.driver, Shop.url)
        self.r = Register(self.driver, Register.url)

    def tearDown(self) -> None:
        self.driver.quit()

    @classmethod
    def setUpClass(cls) -> None:
        pass

    @classmethod
    def tearDownClass(cls) -> None:
        # 发送邮件
        Logger().log().info("--------------测试完成--------------")

    #登录
    @file_data("../config/login.yaml")
    def test_01_login(self, **kwargs):
        self.lp.login(kwargs["username"], kwargs["password"])
        self.assertTrue(
            self.lp.assert_text(kwargs["validata"]["type"],
                                kwargs["validata"]["value"],
                                kwargs["validata"]["expect"]))

    #注册
    @file_data("../config/register.yaml")
    def test_04_register(self, **kwargs):
        self.r.register(kwargs["username"], kwargs["password"])
        self.assertTrue(
            self.r.assert_text(kwargs["validata"]["type"],
                               kwargs["validata"]["value"],
                               kwargs["validata"]["expect"]))

    #搜索
    @file_data("../config/search.yaml")
    def test_02_search(self, **kwargs):
        self.sp.search_shop(kwargs["search_content"])
        #self.assertTrue(self.sp.assert_text(kwargs["validata"]["type"], kwargs["validata"]["value"], kwargs["validata"]["expect"]))

    #个人中心
    @file_data("../config/user_center.yaml")
    def test_03_user_center(self, **kwargs):
        #正常登录
        self.lp.login("666666", "111111")
        #搜索订单号
        self.ip.search_infor(kwargs['search_content'])

    #加入购物车
    def test_03_add_shop_cart(self):
        #正常登录
        self.lp.login("666666", "111111")
        #选择商品
        self.shop.click_shop()
        #切换句柄
        headle = self.driver.window_handles
        self.driver.close()
        self.driver.switch_to.window(headle[2])
        #选择规格加入购物车
        self.add.add_shop_cart()