Пример #1
0
 def add_admin(self, account, nickname, name):
     # 添加管理员
     find_element(self.driver, self.add_bt).click()
     find_element(self.driver, self.add_account).send_keys(account)
     find_element(self.driver, self.add_nickname).send_keys(nickname)
     find_element(self.driver, self.add_name).send_keys(name)
     find_element(self.driver, self.a_confirm).click()
Пример #2
0
 def update_specs(self, price):
     # 修改商品价格
     find_element(self.driver, self.click_specs).click()
     find_element(self.driver, self.update_spe).click()
     find_element(self.driver, self.price).clear()
     find_element(self.driver, self.price).send_keys(price)
     find_element(self.driver, self.p_confirm).click()
Пример #3
0
 def test_03_buy(self):
     huaweishouji = ('xpath',
                     '//*[@id="floor1"]/div[2]/div[2]/div[5]/div/div/a')
     find_element(self.driver, huaweishouji).click()
     self.driver.switch_to_window(self.driver.window_handles[-1])
     buy = ('xpath',
            '/html/body/div[4]/div[2]/div[2]/div[3]/div[2]/div/button')
     find_element(self.driver, buy).click()
Пример #4
0
 def test_03_sousuo(self):
     sousuokuang = ('xpath', '//*[@id="search-input"]')
     find_element(self.driver, sousuokuang).send_keys('连衣裙')
     button = ('xpath', '//*[@id="ai-topsearch"]')
     find_element(self.driver, button).click()
     self.driver.switch_to_window(self.driver.window_handles[-1])
     assert self.driver.find_element_by_xpath(
         '/html/body/div[4]/div/ul/li[1]/div/a/p'
     ).text == "ZK星星绣花雪纺连衣裙中长款sukol裙少女心温柔超仙女chic裙子夏"
Пример #5
0
 def Mbuser(self, p, a1, a2, a3):
     # def Mbuser(self, p,q1, a1,q2,a2,q3,a3):
     """ 
     提交个人资料代码
     """
     find_element(self.driver, self.password).send_keys(p)  # 原有密码
     # find_element(self.driver, self.q1).send_keys(q1)        # 问题1
     find_element(self.driver, self.a1).send_keys(a1)  # 答案1
     # find_element(self.driver, self.q2).send_keys(q2)        # 问题2
     find_element(self.driver, self.a2).send_keys(a2)  # 答案2
     # find_element(self.driver, self.q3).send_keys(q3)        # 问题3
     find_element(self.driver, self.a3).send_keys(a3)  # 答案3
     find_element(self.driver, self.mbbutton).click()  # 点击修改
Пример #6
0
 def question(self,  content, icon, ximg):
     """ 
     添加;灵感代码
     """
     find_element(self.driver, self.content).send_keys(content)  # 内容
     find_element(self.driver, self.icon).send_keys(icon)      # 标签
     find_element(self.driver, self.ximg).send_keys(ximg)        # 图片
     find_element(self.driver, self.getinspirercommit).click()      # 点击问题提交
Пример #7
0
    def setUp(self):
        """ 业务逻辑, 首页--->登陆-->个人信息页面 """
        print("测试用例开始!")
        self.driver.get('http://49.232.185.181:8080/ljindex/index.html')
        auto_login(self.driver)
        time.sleep(3)
        # 调用判断自动登陆
        # 主页点击用户头像跳转个人信息页面
        self.driver.find_element_by_id('personal').click()

        login_status1 = ('link text', '登录')
        # 元素存在没有
        if assert_element_exist(self.driver, login_status1) == True:
            find_element(self.driver, login_status1).click()
            # 实例化登录页面
            loginpage = LoginPage(self.driver)
            loginpage.login("zhangsan", "12345678")
Пример #8
0
 def test_02_login1_fail(self):
     login1 = ("xpath", '//*[@id="unlogin"]/div[1]/a')
     user = ("id", "username")
     password = ("id", "password")
     userlogin = ("id", "userLogin")
     find_element(self.driver, login1).click()
     find_element(self.driver, user).send_keys("yangyng12")
     find_element(self.driver, password).send_keys("12345678")
     find_element(self.driver, userlogin).click()
     try:
         assertNotEqual(driver.title, "测谈网")
     except:
         return False
Пример #9
0
 def login(self, u, p):
     """ 
     登陆代码
     """
     find_element(self.driver, self.username).send_keys(u)
     find_element(self.driver, self.password).send_keys(p)
     find_element(self.driver, self.userLogin).click()
Пример #10
0
 def Newps(self, p, newpwd):
     """ 
     设置密保代码
     """
     find_element(self.driver, self.password).send_keys(p)  # 原有密码
     find_element(self.driver, self.newpassword).send_keys(newpwd)  # 新密码
     find_element(self.driver, self.mbbutton).click()  # 点击重置密码
Пример #11
0
 def test_01_login_success(self):
     driver = webdriver.Chrome(executable_path="drivers\\chromedriver.exe")
     driver.get("http://132.232.44.158:8080/ljindex/")
     login1 = ("xpath", '//*[@id="unlogin"]/div[1]/a')
     user = ("id", "username")
     password = ("id", "password")
     userlogin = ("id", "userLogin")
     find_element(driver, login1).click()
     find_element(driver, user).send_keys("yangyang12")
     find_element(driver, password).send_keys("12345678")
     find_element(driver, userlogin).click()
     try:
         assert driver.title == "测谈网"
         print("成功!")
     except:
         print("失败!")
Пример #12
0
    def test_01_login_failed(self):
        driver = webdriver.Chrome(executable_path='./driver/chromedriver')
        driver.get("http://118.24.255.132:9090/shopxo/admin.php")

        username = ("name", "username")
        password = ("name", "login_pwd")
        loginbtn = ('xpath',
                    '/html/body/div[1]/div/div[2]/div/form/div/div[3]/button')
        find_element(driver, username).send_keys("admin")
        find_element(driver, password).send_keys("shopxo")
        find_element(driver, loginbtn).click()

        index = ('xpath', '//*[@id="admin-offcanvas"]/div/ul/li[1]/a/span[2]')
        assert find_element(driver, index).text == "首页"
Пример #13
0
    def test_selenium1(self):
        self.driver.get("http://132.232.44.158:8080/")
        search_element1 = ('xpath',
                           '//*[@id="J_wrap_pro_add"]/li[1]/div[1]/a/img')
        find_element(self.driver, search_element1).click()

        search_element2 = ('xpath', '//*[@id="J_mer_saleTag"]')
        find_element(self.driver, search_element2).click()

        search_element3 = ('xpath', '//*[@id="J_header_cart"]/div[1]/a[1]')
        find_element(self.driver, search_element3).click()

        search_element4 = ('xpath', '//*[@id="cart_item_2"]/td[6]/div/a')
        is_element_exist(self.driver, search_element4)
Пример #14
0
    def setUp(self):
        self.driver.get('http://118.24.255.132:9090/shopxo/admin.php')
        # 判断用户是否登陆,这种情况用于没有验证码的登陆,直接判断,如果没有登陆,那就执行登陆。
        curl = "http://118.24.255.132:9090/shopxo/admin.php?s=/admin/logininfo.html"
        if self.driver.current_url == curl:
            username = ('name', 'username')
            password = ('name', 'login_pwd')
            loginbtn = (
                'xpath',
                '/html/body/div[1]/div/div[2]/div/form/div/div[3]/button')
            find_element(self.driver, username).send_keys("admin")
            find_element(self.driver, password).send_keys("shopxo")
            find_element(self.driver, loginbtn).click()

        # 进入首页之后,切换到小网页
        eframe = find_element(self.driver, ('id', 'ifcontent'))
        self.driver.switch_to_frame(eframe)
        time.sleep(3)
Пример #15
0
    def test_01_tiwen(self):
        # 首先要登录

        # 这是一个问题,定位并点击进去
        q1 = ("xpath", '//*[@id="questsions"]/li/p')
        find_element(self.driver, q1).click()

        time.sleep(3)

        plk = ("id", 'question_comments_ctt')
        plan = ("id", 'question_comments_btn')
        # 定位评论框 并输入内容
        find_element(self.driver, plk).send_keys("来自动化测试的评论!")
        time.sleep(3)
        # 点击评论按钮
        find_element(self.driver, plan).click()
        time.sleep(3)
Пример #16
0
    def setUp(self):
        self.driver.get("http://118.24.255.132:9090/shopxo/admin.php")
        # 通过url来判断用户是否登录
        curl = "http://118.24.255.132:9090/shopxo/admin.php?s=/admin/logininfo.html"

        # 没有登录就自动登录,登录就不用管
        if self.driver.current_url == curl:  # 如果没有登录,就调用登录方法
            username = ('name', 'username')
            password = ('name', 'login_pwd')
            loginbtn = (
                'xpath',
                '/html/body/div[1]/div/div[2]/div/form/div/div[3]/button')

            find_element(self.driver, username).send_keys("admin")
            find_element(self.driver, password).send_keys("shopxo")
            find_element(self.driver, loginbtn).click()

        # 切换作用域(进入到首页之后,切换小网页)
        eframe = find_element(self.driver, ('id', 'ifcontent'))
        self.driver.switch_to_frame(eframe)

        time.sleep(3)  # 因为元素会变化
Пример #17
0
 def cashout_verify(self):
     # 审核提现申请
     find_element(self.driver, self.verify).click()
     find_element(self.driver, self.sel_status).click()
     find_element(self.driver, self.sel_verify).click()
     find_element(self.driver, self.v_confirm).click()
Пример #18
0
 def search_by_tel(self, tel):
     # 根据用户手机号搜索
     find_element(self.driver, self.search_tel).send_keys(tel)
     find_element(self.driver, self.s_confirm).click()
Пример #19
0
 def regist(self, username, password, confirpw, phonenum, emailnum):
     """
         用户注册的步骤
     """
     find_element(self.driver, self.username).send_keys(username)
     find_element(self.driver, self.phonenum).send_keys(phonenum)
     find_element(self.driver, self.password).send_keys(password)
     find_element(self.driver, self.confirpw).send_keys(confirpw)
     find_element(self.driver, self.emailnum).send_keys(emailnum)
     find_element(self.driver, self.useregis).click()
Пример #20
0
 def click_admin_role(self):
     # 点击角色管理
     find_element(self.driver, self.admin_role).click()
Пример #21
0
 def Updateuser(self, ximg, u, job, sex, phone, qq, weixin, email, address,
                userinfo):
     """ 
     提交个人资料代码
     """
     find_element(self.driver, self.ximg).send_keys(ximg)  # 头像
     time.sleep(3)
     # self.driver.switch_to_alert()
     dig_alert = self.driver.switch_to_alert()
     assert dig_alert.text == "修改成功!"
     self.driver.switch_to_alert().accept()
     time.sleep(3)
     find_element(self.driver, self.nickname).clear()  # 清空昵称
     find_element(self.driver, self.nickname).send_keys(u)  # 输入昵称
     find_element(self.driver, self.job).clear()  # 清空职业
     find_element(self.driver, self.job).send_keys(job)  # 职业
     find_element(self.driver, self.sex).clear()  # 清空性别
     find_element(self.driver, self.sex).send_keys(sex)  # 性别
     find_element(self.driver, self.phone).clear()  # 清空电话
     find_element(self.driver, self.phone).send_keys(phone)  # 电话
     find_element(self.driver, self.qq).clear()  # 清空qq号
     find_element(self.driver, self.qq).send_keys(qq)  # qq号
     find_element(self.driver, self.weixin).clear()  # 清空微信号
     find_element(self.driver, self.weixin).send_keys(weixin)  # 微信号
     find_element(self.driver, self.email).clear()  #清空邮箱
     find_element(self.driver, self.email).send_keys(email)  # 邮箱
     find_element(self.driver, self.address).clear()  # 清空地址
     find_element(self.driver, self.address).send_keys(address)  # 地址
     find_element(self.driver, self.userinfo).clear()  # 清空个性签名
     find_element(self.driver, self.userinfo).send_keys(userinfo)  # 个性签名
     find_element(self.driver, self.acommit1).click()  # 点击修改
Пример #22
0
 def reset_pass(self):
     # 重置密码
     find_element(self.driver, self.reset_pass).click()
     find_element(self.driver, self.reset_pass_confirm).click()
Пример #23
0
 def display_hide_sort(self):
     # 显示/隐藏分类
     find_element(self.driver, self.dis_hid_sort).click()
     find_element(self.driver, self.d_confirm).click()
Пример #24
0
 def click_admin_limit(self):
     # 点击管理员权限管理
     find_element(self.driver, self.admin_limit).click()
Пример #25
0
 def update_role(self, role_name):
     # 修改角色名
     find_element(self.driver, self.update_role_bt).click()
     find_element(self.driver, self.role_name).clear()
     find_element(self.driver, self.role_name).send_keys(role_name)
     find_element(self.driver, self.update_role_confirm).click()
Пример #26
0
 def mass_del(self):
     # 批量删除分类
     find_element(self.driver, self.mass_del_one).click()
     find_element(self.driver, self.mass_del_two).click()
     find_element(self.driver, self.mass_del_bt).click()
     find_element(self.driver, self.mass_del_confirm).click()
Пример #27
0
 def update_sort(self, sort):
     # 修改分类排序
     find_element(self.driver, self.update_bt).click()
     find_element(self.driver, self.update_sort_num).clear()
     find_element(self.driver, self.update_sort_num).send_keys(sort)
     find_element(self.driver, self.u_confirm).click()
Пример #28
0
 def add_role(self, role_name):
     # 新增角色
     find_element(self.driver, self.add_role_bt).click()
     find_element(self.driver, self.add_role_name).send_keys(role_name)
     find_element(self.driver, self.add_role_confirm).click()
Пример #29
0
 def go_login_page(self):
     """  
         进入登陆页面
    
     """
     find_element(self.driver, self.loginbtn).click()
Пример #30
0
 def set_limit(self):
     # 设置权限
     find_element(self.driver, self.set_limit_bt).click()
     find_element(self.driver, self.set_limit_one).click()
     find_element(self.driver, self.set_limit_two).click()
     find_element(self.driver, self.set_limit_confirm).click()