Beispiel #1
0
    def favorite(self, username, password):
        # 打开浏览器
        driver = base.open_browser()
        # 输入网址
        driver.get(user_login_url)
        # 实例化
        lps = Login_page(driver)
        # 输入用户名
        lps.username(username)
        # 输入密码
        lps.password(password)
        # 点击登录
        lps.click_submit()
        # 点击首页
        lps.find_element(
            (By.CSS_SELECTOR,
             '#mainNav > div > ul > li:nth-child(1) > a')).click()

        # 点击商品
        lps.find_element((
            By.CSS_SELECTOR,
            'body > div.index-body > div > div > div:nth-child(2) > div.goods-right > div > a:nth-child(1) > div.img-box > img'
        )).click()
        # 点击收藏
        lps.find_element(
            (By.CSS_SELECTOR,
             '#ECS_FORMBUY > ul > li.padd > table > tbody > tr > td.td2 > a'
             )).click()
        # # 断言
        self.assertIn('收藏夹', base.Base(driver).get_alter())
 def setUp(self):
     # 打开浏览器
     driver = open_browser()
     # 实列化ShoopingCartpage
     self.shopping = ShoppingCart_page(driver)
     # 打开网址
     self.shopping.get_url("http://ecshop.itsoso.cn/index.php")
Beispiel #3
0
    def setUp(self):
        """打开浏览器进入网站"""
        driver = open_browser()
        driver.maximize_window()
        self.login = LoginPage(driver)
        self.login.open_url("http://localhost:8080/ecshop/index.php")
        """登录==>点击结算"""
        # 登录
        self.login.click_p_login()
        username = "******"
        self.login.input_username(username)
        # 输入密码
        password = "******"
        self.login.input_password(password)
        # 点击勾选框
        self.login.click_checkbox()
        # 点击登录
        self.login.click_submit()

        # 点击搜索
        self.pace_order = Pace_Oder_Page(driver)
        self.pace_order.search()
        # 选择商品
        self.pace_order.choose_goods_camera()
        # 点击购买
        self.pace_order.click_to_buy()
        # 点击去结算
        self.pace_order.settlement()
Beispiel #4
0
 def setUp(self):
     """打开浏览器"""
     driver = open_browser("chrome")
     driver.maximize_window()
     self.browse = Browse_all_goods_Page(driver)
     url = "http:\\172.16.10.96:8080/ecshop"
     self.browse.open_url(url)
Beispiel #5
0
 def setUp(self) -> None:
     # 用户前置条件
     # 打开浏览器
     driver = open_browser('firefox')
     # 浏览商品类实例化
     self.goodsview = GoodView(driver)
     # 输入网址
     self.goodsview.open_url(url)
 def setUp(self) -> None:
     # 打开浏览器到添加收货地址界面
     # 创建对象
     driver = open_browser()
     self.login = AddressPage(driver)
     # 准备数据,进入到添加收货地址界面
     url = "http://172.16.1.224/ecshop/"
     self.login.open_url(url)
     self.login.login_address("grj123456","grj123456")
 def setUp(self) -> None:
     """打开浏览器,打开被测网址"""
     driver = open_browser()
     self.login = LoginPage(driver)
     self.login.open_url(url)
     self.login.input_username("user1")
     self.login.input_password("123456")
     self.login.submit()
     self.shopaddress=ShopAddress(driver)
Beispiel #8
0
 def setUp(self) -> None:
     # 打开浏览器到添加收货地址界面
     # 创建对象
     driver = open_browser()
     self.login = AddressPage(driver)
     # 准备数据,进入到添加收货地址界面
     url = "http://172.16.1.224/ecshop/"
     self.login.open_url(url)
     self.login.login_address("grj123456", "grj123456")
     # 得到最后一个数据的索引,就可以进行添加操作了
     self.a = self.login.a_number()
     self.login.performance(self.a)
Beispiel #9
0
 def setUp(self):
     """用例执行前先打开浏览器连接ecshop"""
     driver = open_browser()
     driver.maximize_window()
     self.csif = ConsigneeInformation(driver)
     self.login = LoginPage(driver)
     self.login.open_url("http://localhost:8080/ecshop/index.php")  # 打开地址
     self.login.click_p_login()  # 请登录按钮
     self.username = "******"  # 输入用户名
     self.login.input_username(self.username)
     self.password = "******"  # 输入密码
     self.login.input_password(self.password)
     self.login.click_submit()  # 点击登录
     self.csif.consignee_user_center()  # 点击用户中心
     self.csif.click_welcome_address()  # 点击用户中心的收货地址
Beispiel #10
0
 def setUp(self):
     # 打开浏览器
     from page.loginpage import LoginPage
     driver = open_browser("chrome")
     register1 = LoginPage(driver)
     driver.maximize_window()
     self.login = Shopping(driver)
     url = "http://localhost:8080/ecshop/index.php"  # ecshop商城地址
     self.login.open_url(url)
     # 输入用户名
     register1.click_p_login()
     username = "******"
     register1.input_username(username)
     # 输入密码
     password = "******"
     register1.input_password(password)
     # 点击勾选框
     register1.click_checkbox()
     # 点击登录
     register1.click_submit()
     time.sleep(2)
Beispiel #11
0
    def login_data(self, username, password, num):
        # 打开浏览器
        driver = base.open_browser()
        # 输入网址
        driver.get(user_login_url)
        # 实例化
        lps = Login_page(driver)
        # 输入用户名
        lps.username(username)
        # 输入密码
        lps.password(password)
        # 点击登录
        lps.click_submit()
        # 点击首页
        lps.find_element(
            (By.CSS_SELECTOR,
             '#mainNav > div > ul > li:nth-child(1) > a')).click()
        # 点击商品
        lps.find_element((
            By.CSS_SELECTOR,
            'body > div.index-body > div > div > div:nth-child(2) > div.goods-right > div > a:nth-child(1) > div.img-box > img'
        )).click()
        # 点击立即购买
        lps.find_element((
            By.CSS_SELECTOR,
            '#ECS_FORMBUY > ul > li.padd > table > tbody > tr > td.td1 > a > img'
        )).click()

        # 实例化对象
        lp = Re_shopcar(driver)
        # 清空购物车数量
        lp.reset_nums()
        # 输入购物车数量
        lp.input_nums(num)
        # 刷新购物车
        lp.refresh_car()
        # 获取刷新后购物车数量
        lp.get_values()
        # 断言
        self.assertTrue(num == lp.get_values(), msg='数据没有更新成功')
Beispiel #12
0
        """随机收货地址"""
        add = fake.address()
        return add

    def faker_post(self):
        post = fake.postcode()
        return post


# def create_names():
# fake = Factory.create()
# print(dir(fake))

if __name__ == '__main__':
    from common.base import open_browser
    from page.registerpage import RegisterPage
    import time

    driver = open_browser("chrome")
    register = RegisterPage(driver)

    url = "http://localhost:8080/ecshop/index.php"  # ecshop商城地址
    register.open_url(url)
    time.sleep(2)

    print(Faker_data().faker_email())
    # print(Faker_data().faker_pro())
    # print(Faker_data().faker_qq())
    # print(Faker_data().faker_tel())
    # print(Faker_data().faker_user())
Beispiel #13
0
 def setUp(self) -> None:
     driver=open_browser()
     self.cart=CartPage(driver)
     self.cart.open_url(url)
Beispiel #14
0
 def setUp(self):
     """打开浏览器,打开被测网址"""
     driver = open_browser()
     self.login = LoginPage(driver)
     self.login.open_url(url)
Beispiel #15
0
    def empty(self):
        """清空购物车"""
        self.click_element(self.empty_loc)

    def homepage(self):
        """回到首页"""
        self.click_element(self.homepage_loc)

    def remove(self):
        """删除"""
        self.click_element(self.remove_loc)


if __name__ == '__main__':
    driver = open_browser()  #打开浏览器
    driver.get(url)  #打开网址
    ada = Additive(driver)
    time.sleep(3)
    ada.add()
    time.sleep(3)
    unm = 5
    ada.input_amend(unm)
    time.sleep(3)
    ada.update()
    time.sleep(3)
    ada.remove()
    ada.operation_alert()
    # tanchuang=driver.switch_to_alert()  #捕获弹窗
    # tanchuang.accept()  #弹窗确定
    #tanchuang.dismiss() #弹窗取消
Beispiel #16
0
 def setUp(self) -> None:
     self.driver = open_browser()
     self.login = LoginPage(self.driver)
     self.login.open_url(url1)
Beispiel #17
0
 def setUp(self):
     """打开浏览器,打开被测网址"""
     self.driver = open_browser()
     self.login = HomePageBrowse(self.driver)
     self.login.open_url(url)
Beispiel #18
0
    def input_username_admin(self, account='admin'):
        self.find_element(
            (By.CSS_SELECTOR, 'input[name="username"]')).send_keys(account)

    def input_password_admin(self, password='******'):
        self.find_element(
            (By.CSS_SELECTOR, 'input[name="password"]')).send_keys(password)

    def click_submit(self):
        self.find_element((By.CSS_SELECTOR, '.btn-a')).click()

    # def click_manageOfgoods_add(self):


if __name__ == '__main__':
    driver = base.open_browser()
    pl = PageLogin(driver)
    driver.get(url)
    pl.login_admin()
    pl.input_username_admin()
    pl.input_password_admin()
    pl.click_submit()
    driver.switch_to.frame('menu-frame')
    pl.find_element(
        (By.CSS_SELECTOR, 'li[data-key="01_goods_list"]')).click()  # 点击商品管理
    pl.find_element(
        (By.CSS_SELECTOR, 'a[href="goods.php?act=add"]')).click()  # 点击添加新商品
    driver.switch_to.parent_frame()
    driver.switch_to.frame('main-frame')
    pl.find_element(
        (By.CSS_SELECTOR,
Beispiel #19
0
 def setUp(self):
     driver = open_browser()  #打开浏览器
     self.logonpage = Logonpage(driver)  #实例化类
     self.logonpage.open_url(
         "http://ecshop.itsoso.cn/user.php?act=register")  #打开网页
Beispiel #20
0
        '''
        # 点击搜索按钮
        self.click(self.search_loc)
        # 定位页码总数
        page_num = self.find_elements(self.page_num_loc)
        # 页码索引变量
        j = 1
        # 最后页判断
        while j <= len(page_num):
            try:
                # 浏览当前页所有商品
                self.view_current_page()
                # 点击下一页
                self.click(self.next_loc)
                time.sleep(2)
                j += 1
            except:
                print('这是最后一页')
                break


# 测试代码
if __name__ == '__main__':
    driver = open_browser('firefox')
    goodview = GoodView(driver)
    goodview.open_url(url)
    # goodview.view_current_page()
    goodview.view_all()

    time.sleep(4)
    goodview.close()
Beispiel #21
0
 def setUpClass(cls):
     """执行用例前打开浏览器,并实例化MyOrderPage"""
     driver = open_browser()
     cls.my_order_page = MyOrderPage(driver)
Beispiel #22
0
 def setUp(self) -> None:
     # 用例前置条件
     driver = open_browser('firefox')
     self.register = Register(driver)
     self.register.open_url(url)
Beispiel #23
0
 def setUp(self):
     driver = open_browser("chrome")
     self.register = RegisterPage(driver)
     url = "http://localhost:8080/ecshop/user.php?act=register"  # 输入ecshop商城地址
     self.register.open_url(url)
Beispiel #24
0
 def setUp(self):
     driver = base.open_browser()
     self.lp = Login_page(driver)
     self.lp.get_url()
Beispiel #25
0
 def stepsk(self, goods_name, goods_ID):
     driver = base.open_browser()
     pl = PageLogin(driver)
     driver.get(url)
     pl.login_admin()
     pl.input_username_admin()
     pl.input_password_admin()
     pl.click_submit()
     driver.switch_to.frame('menu-frame')
     pl.find_element((By.CSS_SELECTOR,
                      'li[data-key="01_goods_list"]')).click()  # 点击商品管理
     pl.find_element((By.CSS_SELECTOR,
                      'a[href="goods.php?act=add"]')).click()  # 点击添加新商品
     driver.switch_to.parent_frame()
     driver.switch_to.frame('main-frame')
     pl.find_element(
         (By.CSS_SELECTOR, 'input[style="float:left;color:;"]')).send_keys(
             goods_name)  # 商品名称
     select1 = pl.find_element(
         (By.CSS_SELECTOR, 'select[name="goods_name_style"]'))
     Select(select1).select_by_value('strong')  # 字体样式
     pl.find_element(
         (By.CSS_SELECTOR,
          'input[name="goods_sn"]')).send_keys(str(goods_ID))  # 商品货号
     select2 = pl.find_element(
         (By.CSS_SELECTOR, 'select[onchange="hideCatDiv()"]'))
     Select(select2).select_by_value('18')
     # pl.find_element((By.CSS_SELECTOR, 'button[onclick="rapidCatAdd()"]')).click()  # 点击添加分类
     pl.find_element(
         (By.CSS_SELECTOR,
          'input[onclick="addOtherCat(this.parentNode)"]')).click()  # 点击扩展
     select3 = pl.find_element(
         (By.CSS_SELECTOR, 'select[name="other_cat[]"]'))  # 定位
     Select(select3).select_by_value('19')
     select4 = pl.find_element(
         (By.CSS_SELECTOR,
          'select[onchange="hideBrandDiv()"]'))  # 定位商品品牌select标签
     Select(select4).select_by_value('15')  # 选择value=15的品牌(仓品)
     select5 = pl.find_element(
         (By.CSS_SELECTOR, '#suppliers_id'))  # 定位选择供货商select标签
     Select(select5).select_by_value('2')  # 选择上海供货商
     pl.find_element((By.CSS_SELECTOR,
                      'input[onblur="priceSetted()"]')).clear()  # 清空本店售价文本
     pl.find_element(
         (By.CSS_SELECTOR,
          'input[onblur="priceSetted()"]')).send_keys('188')  # 本店售价188
     # pl.find_element((By.CSS_SELECTOR, '.rank_1')).clear()  # 清空 会员价格>注册用户
     # pl.find_element((By.CSS_SELECTOR, '.rank_1')).send_keys('888')  # 注册会员价格888
     pl.find_element(
         (By.CSS_SELECTOR,
          'input[name="volume_number[]"]')).send_keys('5')  # 优惠数量为5个
     pl.find_element(
         (By.CSS_SELECTOR,
          'input[name="volume_price[]"]')).send_keys('20')  # 当优惠梳理为5时,优惠20
     pl.find_element(
         (By.CSS_SELECTOR,
          'input[onclick="handlePromote(this.checked);"]')).click()  # 勾选促销价
     pl.find_element((By.CSS_SELECTOR,
                      'input[name="promote_price"]')).clear()  # 清空促销价文本
     pl.find_element(
         (By.CSS_SELECTOR,
          'input[name="promote_price"]')).send_keys('88')  # 促销价设置为88
     # 修改促销开始时间
     js = "document.getElementById('promote_start_date').value='2021-03-21'"
     driver.execute_script(js)
     # 修改促销结束时间
     js2 = "document.getElementById('promote_end_date').value='2021-04-21'"
     driver.execute_script(js2)
     #  上传商品图片
     pl.find_element(
         (By.CSS_SELECTOR, 'input[name="goods_img"]'
          )).send_keys(r'C:\3000soft\Red Spider\Language\logo.jpg')
     pl.find_element(
         (By.CSS_SELECTOR,
          'div.button-div>input[type="button"]')).click()  # 点击确定
     sleep(3)
     # with pymysql.connect(database='ecshop', port=3307, user='******', password='******', charset='utf8',
     #                      host='127.0.0.1') as cnn:
     #     with cnn.cursor(cursor=pymysql.cursors.DictCursor) as cur:
     #         sql = "select goods_name from ec_goods where goods_name=%s"
     #         args = ["苹果"]
     #         tiao = cur.execute(sql, args)
     #         print(tiao)
     #         koko = cur.fetchall()
     #         print(koko)
     sql = "select goods_name from ec_goods where goods_name=%s"
     args = [goods_name]
     sqlcheck = db.read_one(sql, args)
     jkjk = sqlcheck['goods_name']
     sleep(5)
     self.assertTrue(goods_name == jkjk, msg='没有添加成功')
     driver.quit()
Beispiel #26
0
 def setUp(self):
     self.driver = base.open_browser()
     self.rg = Register_page(self.driver)
     self.rg.open_url(self.url)
Beispiel #27
0
 def setUp(self):
     driver = open_browser("chrome")
     self.login = LoginPage(driver)
     url = "http://localhost:8080/ecshop/user.php"  # 输入ecshop商城登录地址
     self.login.open_url(url)
 def setUp(self):
     """打开浏览器,打开被测网址"""
     self.driver = open_browser()
     self.login = LoginPage(self.driver)
     self.login.open_url(url)
     self.cons = Constructdata()
Beispiel #29
0
    # order_payment.click_Wechat_pay()
    # time.sleep(2)
    # order_payment.click_no_package()
    # time.sleep(2)
    # order_payment.click_package()
    # time.sleep(2)
    # order_payment.click_no_card()
    # time.sleep(2)
    # order_payment.click_nedd_card()
    # time.sleep(2)
    # order_payment.click_submit_order()
    # time.sleep(2)
    # order_payment.get_order_num()
    #
    # order_payment.close()
    driver = open_browser()
    order_payment = OrderPayment(driver)
    order_payment.open_url(url)
    order_payment.click_login_submit()
    order_payment.input_username("诸葛亮_9")
    order_payment.input_password("Test123456")
    order_payment.click_login_now()
    order_payment.click_buy()
    order_payment.click_go_to_pay()
    # order_payment.click_direct_buy()

    # order_payment.choose_provice(5)
    # time.sleep(2)
    # order_payment.choose_city(3)
    # time.sleep(2)
    # order_payment.choose_district(4)
Beispiel #30
0
 def setUp(self):
     driver = base.open_browser()
     self.pugd = PageUserGoodsDisplay(driver)
     driver.get(url)