test_auto_unittest

import unittest,time,random
from selenium import webdriver

class TestReg(unittest.TestCase):
    # 设置预置条件
    def setUp(self):
        url = 'http://localhost/index.php?m=member&c=public&a=login'
        self.dr = webdriver.Chrome()
        self.dr.get(url)
        self.dr.maximize_window()
        self.dr.implicitly_wait(10)

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

    def test_login_success(self):
        ele = self.dr.find_element_by_css_selector('[name="username"]')
        ele.send_keys('lgn1')
        ele1 = self.dr.find_element_by_css_selector('[name="password"]')
        ele1.send_keys('123456')
        self.dr.find_element_by_css_selector('#popup-submit').click()
        assert '会员中心' in self.dr.find_element_by_css_selector('.text-white.text-default').text

    def test_login_failed(self):
        ele = self.dr.find_element_by_css_selector('[name="username"]')
        ele.send_keys('lgn1')
        ele1 = self.dr.find_element_by_css_selector('[name="password"]')
        ele1.send_keys('12345')
        self.dr.find_element_by_css_selector('#popup-sub mit').click()
        assert '用户不存在或密码错误' in self.dr.find_element_by_css_selector(
            '.error').text

    def test_reg_success(self):
        self.dr.find_element_by_xpath('//*[text()="注册"]').click()
        ele = self.dr.find_element_by_css_selector('.cart-address').text
        assert '注册新会员' in ele

    def test_forget_password(self):
        self.dr.find_element_by_partial_link_text('忘记密码').click()
        ele = self.dr.find_element_by_css_selector('.text-default.margin-big-bottom').text
        assert '请选择验证方式:' in ele

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值