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
test_auto_unittest
最新推荐文章于 2024-11-02 16:28:26 发布