def test_demo(self):
        driver_path = os.path.join(os.path.dirname(__file__),"../../chromedriver/chromedriver.exe")
        # 打开浏览器
        driver = webdriver.Chrome(driver_path)
        driver.maximize_window()  # 最大化浏览器
        driver.implicitly_wait(8)  # 设置隐式时间等待
        time.sleep(2)
        # 打开网址
        driver.get("http://192.168.60.132/#/login")
        time.sleep(2)
        # 输入用户名
        username = driver.find_element_by_xpath("//input [@name='username']")
        username.clear()
        username.send_keys("admin")
        time.sleep(2)
        # 输入密码
        password = driver.find_element_by_xpath("//input [@name='password']")
        password.clear()
        password.send_keys("123456")
        time.sleep(2)
        # 点击登录
        login = driver.find_element_by_xpath("//span[contains(text(),'登录')]")
        login.click()
        time.sleep(2)
        assertions = Assertions()
        assertions.assert_in_text(driver.page_source,'首页')
        # 点击营销
        yingxiao = driver.find_element_by_xpath("//span[contains(text(),'营销')]")
        yingxiao.click()
        time.sleep(2)
        assertions = Assertions()
        assertions.assert_in_text(driver.page_source, '优惠券列表')
        # 点击优惠券列表
        youhuijuan = driver.find_element_by_xpath("//span[contains(text(),'优惠券列表')]")
        youhuijuan.click()
        time.sleep(2)
        assertions = Assertions()
        assertions.assert_in_text(driver.page_source, '筛选搜索')
        # 输入优惠券名称
        ssyouhuijuan = driver.find_element_by_xpath("//label[contains(text(),'优惠券名称:')]/following-sibling::div//input")
        ssyouhuijuan.clear()
        ssyouhuijuan.send_keys("全品类通用券")
        time.sleep(2)
        assertions = Assertions()
        assertions.assert_in_text(driver.page_source, '筛选搜索')
        # 点击查询搜索
        sousuo = driver.find_element_by_xpath("//span[contains(text(),'查询搜索')]")
        sousuo.click()
        time.sleep(4)
        assertions = Assertions()
        assertions.assert_in_text(driver.page_source, '筛选搜索')

        # 退出浏览器
        driver.quit()
    def test_testdemo1(self):
        # 打开浏览器
        # 确定chromedriver.exe的位置
        driver_path = os.path.join(os.path.dirname(__file__), "../../chromedriver/chromedriver.exe")
        print(driver_path)
        driver = webdriver.Chrome(driver_path)
        driver.maximize_window()  # 最大化浏览器
        driver.implicitly_wait(8)  # 设置隐式时间等待
        time.sleep(2)
        driver.get("http://192.168.60.132/#/login")
        # 先输入用户名
        username = driver.find_element_by_xpath('//input[@name="username"]')
        username.clear()
        username.send_keys('admin')


        # 在输入密码
        password = driver.find_element_by_xpath('//input[@name="password"]')
        password.clear()
        password.send_keys('123456')

        # 最后点击登录
        login = driver.find_element_by_xpath('//span[contains(text(),"登录")]')
        login.click()


        time.sleep(2)
        # 添加断言
        assertions = Assertions()
        assertions.assert_in_text(driver.page_source, '首页')

        # 点击营销
        yingxiao = driver.find_element_by_xpath('//span[contains(text(),"营销")]')
        yingxiao.click()
        time.sleep(2)
        # 点击优惠券列表
        youhuiquan = driver.find_element_by_xpath('//span[contains(text(),"优惠券列表")]')
        youhuiquan.click()
        time.sleep(2)
        # 输入优惠券名称
    
        # 点击查询搜索
        sousuo = driver.find_element_by_xpath('//span[contains(text(),"查询搜索")]')
        sousuo.click()
        time.sleep(2)
        # 添加断言
        assertions = Assertions()
        assertions.assert_in_text(driver.page_source, '全品类通用券')
        driver.quit()

        pass
Beispiel #3
0
    def test_demo3(self, driver):
        base = baseUI(driver)

        driver.get("http://192.168.60.132/login#/home")
        base.send_keys("输入用户名", "//input[@name='username']", "admin")
        base.send_keys("输入密码", "//input[@name='password']", "123456")
        # 点击登录
        base.click("点击登录", "//span[contains(text(),'登录')]")
        # 点击订单(//span[contains(text(),'订单')])[1]
        base.click("点击订单", "//span[contains(text(),'订单')]")
        # 点击订单列表(//span[contains(text(),'订单列表')]
        base.click("点击订单列表", "//span[contains(text(),'订单列表')]")
        # 点击订单状态//label[contains(text(),'订单状态:')]/following-sibling::div//input
        base.click(
            "点击订单状态",
            "//label[contains(text(),'订单状态:')]/following-sibling::div//input")
        # 点击待发货//span[contains(text(),'待发货')]
        base.click("点击代发货", "//span[contains(text(),'待发货')]")
        # 点击查询搜索//span[contains(text(),'查询搜索')]
        base.click("点击查询搜索", "//span[contains(text(),'查询搜索')]")
        # 点击勾选//div/div[2]/section/div/div[3]/div/div[2]/table/thead/tr/th[1]/div/label/span/span
        base.click("点击多选", "//section//div//thead//span/span")
        #批量发货//div[2]/section/div/div[4]/div/div[1]/input
        base.click("批量发货", "//div[2]/section/div/div[4]/div/div[1]/input")
        # 点击批量发货//span[contains(text(),'批量发货')]
        base.click("批量发货", "//span[contains(text(),'批量发货')]")
        # 点击确定//span[contains(text(),'确定')]
        base.click("点击确定", "//span[contains(text(),'确定')]")
        # 获取有几行
        rows = len(driver.find_elements_by_xpath("//tbody/tr"))
        # 选择物流公司//tbody/tr[1]/td[6]//input
        # 选择快递(//span[text()='顺丰快递'])[1]
        # 物流单号//tbody/tr[1]/td[7]//input
        for i in range(1, rows + 1):
            # 选择物流公司(//tbody/tr[1]/td[6]//input)
            base.click("选择物流公司", "//tbody/tr[{0}]/td[6]//input".format(i))
            # 选择快递(//span[text()='中通顺丰快递'])[10]
            base.click("选择快递",
                       "(//span[contains(text(),'顺丰快递')])[10]".format(i))
            # 物流单号//tbody/tr[1]/td[7]//input
            base.send_keys("物流单号", "//tbody/tr[{0}]/td[7]//input".format(i),
                           "1545648751454545")
        # 点击确定//span[contains(text(),'确定')]
        base.click("点击确定", "//span[contains(text(),'确定')]")
        # 点击确定(//span[contains(text(),'确定')])[2]
        base.click("点击确定", "(//span[contains(text(),'确定')])[2]")

        xpath = driver.find_element_by_xpath("//div[@role='alert']/p")
        assertions = Assertions()
        assertions.assert_in_text(xpath.text, '发货成功!')
Beispiel #4
0
    def test_demo(self, driver):
        base = baseUI(driver)

        driver.get("http://192.168.60.132/login#/home")
        base.send_keys("输入用户名", "//input[@name='username']", "admin")
        base.send_keys("输入密码", "//input[@name='password']", "123456")
        # 点击登录
        base.click("点击登录", "//span[contains(text(),'登录')]")
        #         点击营销//span[text()='营销']

        base.click("点击营销", "//span[text()='营销']")
        # 点击优惠券列表//span[text()='优惠券列表']
        base.click("点击优惠券列表", "//span[text()='优惠券列表']")
        # 点击编辑
        base.click("点击编辑", "(//span[contains(text(),'编辑')])[1]")
        #填写优惠券名称://label[contains(text(),'优惠券名称:')]/following-sibling::div//input
        base.send_keys(
            "填写优惠券名称",
            "//label[contains(text(),'优惠券名称:')]/following-sibling::div//input",
            "全场不通用")
        # 总发行量://label[contains(text(),'总发行量:')]/following-sibling::div//input
        base.send_keys(
            "填写总发行量",
            "//label[contains(text(),'总发行量:')]/following-sibling::div//input",
            "100")
        # 面额://label[contains(text(),'面额:')]/following-sibling::div//input
        base.send_keys(
            "填写面额",
            "//label[contains(text(),'面额:')]/following-sibling::div//input",
            "20")
        # 使用门槛://label[contains(text(),'使用门槛:')]/following-sibling::div//input
        base.send_keys(
            "填写使用门槛",
            "//label[contains(text(),'使用门槛:')]/following-sibling::div//input",
            "1000")
        # 点击提交//span[contains(text(),'提交')]
        base.click("点击提交", "//span[contains(text(),'提交')]")
        # 点击确定//span[contains(text(),'确定')]
        base.click("点击确定", "//span[contains(text(),'确定')]")
        # 断言
        # print(driver.page_source)
        xpath = driver.find_element_by_xpath("//div[@role='alert']/p")
        print(xpath)
        assertions = Assertions()
        # assertions.assert_in_text(driver.page_source, '修改成功')
        assertions.assert_in_text(xpath.text, '修改成功')
Beispiel #5
0
    def test_demo(self,driver):
        base = baseUI(driver)
        # 打开网页
        driver.get("http://192.168.60.132/#/login")
        base.send_keys("输入用户名", "//input[@name='username']", "admin")
        base.send_keys("输入密码", "//input[@name='password']", "123456")
        # 点击登录
        base.click("点击登录","//span[contains(text(),'登录')]")

        # 点击营销
        base.click("点击营销", "(//span[contains(text(),'营销')])[1]")
        # 点击优惠券列表
        base.click("点击优惠券列表","(//span[contains(text(),'优惠券列表')])[1]")
        # 点击编辑编号为2的商品
        base.click("点击编辑", "(//span[contains(text(),'编辑')])[1]")
        # 点击优惠券类型
        base.click('点击优惠券类型',"(//label[contains(text(),'优惠券类型:')]/following-sibling::div//span)[1]")
        # 点击全场赠券
        base.click('点击全场赠券',"//span[contains(text(),'全场赠券')]")
        # 输入优惠券名称
        base.send_keys('输入优惠券名称',"//label[contains(text(),'优惠券名称:')]/following-sibling::div//input",'能看不能用')
        # 输入总发行量
        base.send_keys('输入总发行量',"//label[contains(text(),'总发行量:')]/following-sibling::div//input",'1')
        # 输入面额
        base.send_keys('输入面额',"//label[contains(text(),'面额:')]/following-sibling::div//input",'7')
        # 输入使用门槛
        base.send_keys('输入使用门槛',"//label[contains(text(),'使用门槛:')]/following-sibling::div//input","12")
        # 点击全场通用
        base.click('点击全场通用',"//label[contains(text(),'使用门槛:')]/following-sibling::div//input")
        # 点击提交
        base.click('点击提交',"//span[contains(text(),'提交')]")
        # 点击确定
        base.click('点击确定',"//span[contains(text(),'确定')]")
        # 添加断言
        # print(driver.page_source)打印,获取代码
        xpath = driver.find_element_by_xpath("//div[contains(@role,'alert')]/p")
        # print(xpath)  获取文字
        assertions = Assertions()
        assertions.assert_in_text(xpath.text,'修改成功')
Beispiel #6
0
    def test_testdemo2(self, driver):
        base = baseUI(driver)
        # # 打开浏览器
        # # 确定chromedriver.exe的位置
        # driver_path = os.path.join(os.path.dirname(__file__), "../../ChromDriver/chromedriver.exe")
        # print(driver_path)
        # driver = webdriver.Chrome(driver_path)
        # driver.maximize_window()  # 最大化浏览器
        # driver.implicitly_wait(8)  # 设置隐式时间等待
        # time.sleep(2)
        # 打开网址
        base.driver.get("http://192.168.60.132/home#/login")
        # 输入用户名
        base.send_keys('输入用户名', '//input[@name="username"]', 'admin')
        # 输入密码
        base.send_keys('输入密码', "//input[@name = 'password']", '123456')
        # 点击登录
        base.click('点击登录', "//span[contains(text(),'登录')]")
        # 点击商品
        base.click('点击商品', "//span[contains(text(),'商品')]")
        # 点击添加商品
        base.click('点击添加商品', "//span[contains(text(),'添加商品')]")
        # 点击商品分类_下拉框
        base.click('点击商品分类', "//span[@class='el-cascader__label']")
        #选择下拉框_服装
        base.click('选择服装', "//li[contains(text(),'服装')]")
        # 选择下拉框_服装_外套
        base.click('选择外套', "//li[contains(text(),'外套')]")
        # 输入商品名称
        base.send_keys(
            '输入商品名称',
            "//label[contains(text(),'商品名称:')]/following-sibling::div//input",
            '海澜之家')
        # 副标题
        base.send_keys(
            '副标题',
            "//label[contains(text(),'副标题:')]/following-sibling::div//input",
            '海澜')
        # 商品品牌
        base.click('商品品牌', "//input[@placeholder='请选择品牌']")
        # 选择品牌_海澜之家
        base.click('选择品牌', "//span[contains(text(),'海澜之家')]")
        # 点击查询搜索
        base.click('点击查询搜索', "//span[contains(text(),'下一步,填写商品促销')]")

        # 赠送积分
        base.send_keys(
            '输入赠送积分',
            "//label[contains(text(),'赠送积分:')]/following-sibling::div//input",
            100)
        # 赠送成长值
        base.send_keys(
            '输入赠送成长值',
            "//label[contains(text(),'赠送成长值:')]/following-sibling::div//input",
            101)
        # 积分购买限制
        base.send_keys(
            '输入积分购买限制',
            "//label[contains(text(),'积分购买限制:')]/following-sibling::div//input",
            1000)
        # 预告商品
        base.click(
            '选择预告商品',
            "//label[contains(text(),'预告商品:')]/following-sibling::div//span")
        # 商品上架
        base.click(
            '商品上架',
            "//label[contains(text(),'商品上架:')]/following-sibling::div//span")
        # 商品推荐
        base.click(
            '新品',
            "(//span[contains(text(),'新品')]/following-sibling::div/span)[2]")
        # 服务保证
        base.click('选择服务保证', "//span[contains(text(),'免费包邮')]")
        # 详细页标题
        base.send_keys(
            '详细页标题',
            "//label[contains(text(),'详细页标题:')]/following-sibling::div//input",
            '标题')
        # 详细页描述
        base.send_keys(
            '详细页描述',
            "//label[contains(text(),'详细页描述:')]/following-sibling::div//input",
            '海澜之家')
        # 商品关键字
        base.send_keys(
            '商品关键字',
            "//label[contains(text(),'商品关键字:')]/following-sibling::div//input",
            '海')
        # 商品备注
        base.send_keys(
            '商品备注',
            "//label[contains(text(),'商品备注:')]/following-sibling::div//textarea",
            '之家')
        # 点击优惠券方式
        base.click('点击优惠券方式', "//span[contains(text(),'无优惠')]")
        # 下一步,填写商品属性
        base.click('点击下一步', "//span[contains(text(),'下一步,填写商品属性')]")

        # 点击商品属性类型
        base.click(
            '点击商品属性类型',
            "//label[contains(text(),'属性类型')]/following-sibling::div//input")
        # 点击商品属性类型___T恤
        base.click('点击服装-T恤', "//span[contains(text(),'服装-T恤')]")
        # 点击商品规格_输入增加颜色
        base.send_keys(
            '增加颜色',
            "//label[contains(text(),'商品规格:')]/following-sibling::div//input",
            'red')
        # 点击商品规格_输入增加颜色_点击增加
        base.click('点击增加', "//span[contains(text(),'增加')]")
        # 点击选择尺寸"M"
        base.click('点击尺寸', "//span[contains(text(),'M')]")
        # 填写商品编号
        base.send_keys(
            '填写商品编号',
            "//div[contains(text(),'商品编号:')]/following-sibling::div/input",
            1314)
        # 点击适用季节
        base.click(
            '点击适用季节',
            "//div[contains(text(),'适用季节:')]/following-sibling::div//input")
        # 点击适用季节_夏季
        base.click('点击夏季', "//span[contains(text(),'夏季')]")
        # 点击适用人群
        base.click(
            '点击适用人群',
            "//div[contains(text(),'适用人群:')]/following-sibling::div//input")
        # 点击适用人群_点击儿童
        base.click('点击夏季', "//span[contains(text(),'儿童')]")
        # 点击上市时间
        base.click(
            '点击上市时间',
            "//div[contains(text(),'上市时间:')]/following-sibling::div//input")
        # 点击上市时间_2017年秋
        base.click('点击2017年秋', "//span[contains(text(),'2017年秋')]")
        # 点击袖长
        base.click(
            '点击袖长',
            "//div[contains(text(),'袖长:')]/following-sibling::div//input")
        # 点击袖长_短袖
        base.click('点击长袖', "//span[contains(text(),'长袖')]")
        # 点击规格参数

        # 点击下一步,选择商品关联
        base.click('点击下一步', "//span[contains(text(),'下一步,选择商品关联')]")

        # 营销_优惠券列表_第一个编辑
        # 点击营销
        base.click('点击营销', "//span[contains(text(),'营销')]")
        # 点击优惠券列表
        base.click('点击优惠券列表', "//span[contains(text(),'优惠券列表')]")
        # 点击第一条_编辑
        base.click('点击编辑', "//span[contains(text(),' 编辑')]")
        # 点击选择优惠券类型
        base.click(
            '点击选择优惠券类型',
            "//label[contains(text(),'优惠券类型:')]/following-sibling::div//input")
        # 点击选择全场赠券
        base.click('点击选择全场赠券', "//span[contains(text(),'全场赠券')]")
        # 输入优惠券名称
        base.send_keys(
            '点击选择优惠券名称',
            "//label[contains(text(),'优惠券名称:')]/following-sibling::div//input",
            '通用券')
        # 点击选择适用平台
        base.click(
            '点击选择适用平台',
            "//label[contains(text(),'适用平台:')]/following-sibling::div//input")
        # 点击选择全平台
        base.click('点击选择全平台', "//span[contains(text(),'全平台')]")
        # 输入总发行量
        base.send_keys(
            '输入总发行量',
            "//label[contains(text(),'总发行量:')]/following-sibling::div//input",
            250)
        # 输入面额
        base.send_keys(
            '输入面额',
            "//label[contains(text(),'面额:')]/following-sibling::div//input",
            250)
        # 输入没人限领
        base.send_keys(
            '输入没人限领',
            "//label[contains(text(),'每人限领:')]/following-sibling::div//input",
            1)
        # 输入使用门槛
        base.send_keys(
            '输入使用门槛',
            "//label[contains(text(),'使用门槛:')]/following-sibling::div//input",
            200)
        # 点击有效期
        # base.click('点击有效期',"//label[contains(text(),'有效期:')]/following-sibling::div//input")
        # 点击选择2019.4.8号
        # base.click('选择8号',"//span[contains(text(),'8')][1]")
        # 点击可使用商品_全场通用
        base.click(
            '点击全场通用',
            "//label[contains(text(),'可使用商品:')]/following-sibling::div//span")
        # 输入备注内容
        base.send_keys(
            '输入备注内容',
            "//label[contains(text(),'备注:')]/following-sibling::div//textarea",
            '满200减250')
        # 点击提交按钮
        base.click('点击提交按钮', "//span[contains(text(),'提交')]")
        # 点击确定按钮
        base.click('点击确定按钮', "//span[contains(text(),'确定')]")
        print(driver.page_source)
        text = base.get_text("获取页面展示文本", "//div[@role='alert']/p")

        Assertions.assert_in_text(text, "修改成功")
        time.sleep(4)
Beispiel #7
0
    def test_testdemo1(self,driver):
        # # 打开浏览器
        # # 确定chromedriver.exe的位置
        # driver_path = os.path.join(os.path.dirname(__file__), "../../chromedriver/chromedriver.exe")
        # print(driver_path)
        # driver = webdriver.Chrome(driver_path)
        # driver.maximize_window()  # 最大化浏览器
        # driver.implicitly_wait(8)  # 设置隐式时间等待
        # time.sleep(2)
        driver.get("http://192.168.60.132/#/login")
        # 先输入用户名

        send_keys(driver,'//input[@name="username"]','admin')

        # username = driver.find_element_by_xpath('//input[@name="username"]')
        # username.clear()
        # username.send_keys('admin')
        # time.sleep(2)


        # 在输入密码

        send_keys(driver,'//input[@name="password"]','123456')

        # password = driver.find_element_by_xpath('//input[@name="password"]')
        # password.clear()
        # password.send_keys('123456')
        # time.sleep(2)

        # 最后点击登录
        click_demo(driver,"//span[contains(text(),'登录')]")

        # 点击商品

        click_demo(driver,'//span[contains(text(),"商品")]')

        # shangping = driver.find_element_by_xpath('//span[contains(text(),"商品")]')
        # shangping.click()
        # time.sleep(2)

        # 点击添加商品

        click_demo(driver,'//span[contains(text(),"添加商品")]')

        # tianjia = driver.find_element_by_xpath('//span[contains(text(),"添加商品")]')
        # tianjia.click()
        # time.sleep(2)


        # 点击商品分类

        click_demo(driver,'(//label[contains(text(),"商品分类:")]/following-sibling::div//span)[4]')

        # dianjishangpingfenlei = driver.find_element_by_xpath('(//label[contains(text(),"商品分类:")]/following-sibling::div//span)[4]')
        # dianjishangpingfenlei.click()
        # time.sleep(2)

        # 点击商品分类家用电器下拉框

        click_demo(driver,'//li[contains(text(),"家用电器")]')

        # jiayongdianqi = driver.find_element_by_xpath('//li[contains(text(),"家用电器")]')
        # jiayongdianqi.click()
        # time.sleep(2)

        # 点击二级洗衣机下拉框

        click_demo(driver,'//li[contains(text(),"洗衣机")]')

        # xiyiji = driver.find_element_by_xpath('//li[contains(text(),"洗衣机")]')
        # xiyiji.click()
        # time.sleep(2)

        # 点击商品名称

        send_keys(driver,'//label[contains(text(),"商品名称:")]/following-sibling::div//input',"长虹洗衣机")

        # shangpinmingcheng = driver.find_element_by_xpath('//label[contains(text(),"商品名称:")]/following-sibling::div//input')
        # shangpinmingcheng.clear()
        # shangpinmingcheng.send_keys("长虹洗衣机")
        # time.sleep(2)

        # 点击副标题

        send_keys(driver,'//label[contains(text(),"副标题:")]/following-sibling::div//input',"家用洗衣机")

        # fubiaoti = driver.find_element_by_xpath('//label[contains(text(),"副标题:")]/following-sibling::div//input')
        # fubiaoti.clear()
        # fubiaoti.send_keys("家用洗衣机")
        # time.sleep(2)

        # 点击商品品牌

        click_demo(driver,'//label[contains(text(),"商品品牌:")]/following-sibling::div/div')

        # pingpai = driver.find_element_by_xpath('//label[contains(text(),"商品品牌:")]/following-sibling::div/div')
        # pingpai.click()
        # time.sleep(2)

        # 点击格力

        click_demo(driver,'//span[contains(text(),"格力")]')

        # geli = driver.find_element_by_xpath('//span[contains(text(),"格力")]')
        # geli.click()
        # time.sleep(2)

        # 商品介绍

        send_keys(driver,'//label[contains(text(),"商品介绍:")]/following-sibling::div//textarea',"洗衣机")

        # shangpinjieshao = driver.find_element_by_xpath('//label[contains(text(),"商品介绍:")]/following-sibling::div//textarea')
        # shangpinjieshao.clear()
        # shangpinjieshao.send_keys("洗衣机")
        # time.sleep(2)

        # 商品货号

        send_keys(driver,'//label[contains(text(),"商品货号:")]/following-sibling::div//input',"789562")

        # huohao = driver.find_element_by_xpath('//label[contains(text(),"商品货号:")]/following-sibling::div//input')
        # huohao.clear()
        # huohao.send_keys("789562")
        # time.sleep(2)

        # 商品售价

        send_keys(driver,'//label[contains(text(),"商品售价:")]/following-sibling::div//input',"789562")

        # shoujia = driver.find_element_by_xpath('//label[contains(text(),"商品售价:")]/following-sibling::div//input')
        # shoujia.clear()
        # shoujia.send_keys("789562")
        # time.sleep(2)

        # 市场价

        send_keys(driver,'//label[contains(text(),"市场价:")]/following-sibling::div//input',"999999")

        # shichangjia = driver.find_element_by_xpath('//label[contains(text(),"市场价:")]/following-sibling::div//input')
        # shichangjia.clear()
        # shichangjia.send_keys("999999")
        # time.sleep(2)

        # 商品库存

        send_keys(driver,'//label[contains(text(),"商品库存:")]/following-sibling::div//input',"100000")

        # kucun = driver.find_element_by_xpath('//label[contains(text(),"商品库存:")]/following-sibling::div//input')
        # kucun.clear()
        # kucun.send_keys("100000")
        # time.sleep(2)

        # 下拉滚动条

        js = "var q=document.documentElement.scrollTop=10000"
        driver.execute_script(js)

        # 计量单位

        send_keys(driver,'//label[contains(text(),"计量单位:")]/following-sibling::div//input',"***")

        # danwei= driver.find_element_by_xpath('//label[contains(text(),"计量单位:")]/following-sibling::div//input')
        # danwei.clear()
        # danwei.send_keys("***")
        # time.sleep(2)

        # 商品重量

        send_keys(driver,'//label[contains(text(),"商品重量:")]/following-sibling::div//input',"99999")

        # zhongliang= driver.find_element_by_xpath('//label[contains(text(),"商品重量:")]/following-sibling::div//input')
        # zhongliang.clear()
        # zhongliang.send_keys("99999")
        # time.sleep(2)

        # 排序

        send_keys(driver,'//label[contains(text(),"排序")]/following-sibling::div//input',"2")

        # paixu= driver.find_element_by_xpath('//label[contains(text(),"排序")]/following-sibling::div//input')
        # paixu.clear()
        # paixu.send_keys("2")
        # time.sleep(2)

        # 点击下一步

        click_demo(driver,'//span[contains(text(),"下一步,填写商品促销")]')

        # xiayibu = driver.find_element_by_xpath('//span[contains(text(),"下一步,填写商品促销")]')
        # xiayibu.click()
        # time.sleep(2)

        # 赠送积分

        send_keys(driver,'//label[contains(text(),"赠送积分:")]/following-sibling::div//input','100')

        # 赠送成长值

        send_keys(driver,'//label[contains(text(),"赠送成长值:")]/following-sibling::div//input','50')

        # 积分购买限制

        send_keys(driver,'//label[contains(text(),"积分购买限制:")]/following-sibling::div//input','200')

        # 预告商品

        click_demo(driver,'//label[contains(text(),"预告商品:")]/following-sibling::div//span')

        # 商品上架

        click_demo(driver,'//label[contains(text(),"商品上架:")]/following-sibling::div//span')

        # 商品推荐

        click_demo(driver,'(//label[contains(text(),"商品推荐:")]/following-sibling::div//span)[4]')

        # 服务保证

        click_demo(driver,'(//label[contains(text(),"服务保证:")]/following-sibling::div//span)[2]')
        click_demo(driver,'(//label[contains(text(),"服务保证:")]/following-sibling::div//span)[5]')
        click_demo(driver,'(//label[contains(text(),"服务保证:")]/following-sibling::div//span)[8]')

        # 详细页标题

        send_keys(driver,'//label[contains(text(),"详细页标题:")]/following-sibling::div//input','bbbbb')

        # 详细页描述

        send_keys(driver,'//label[contains(text(),"详细页描述:")]/following-sibling::div//input','101010101')

        # 商品关键字

        send_keys(driver,'//label[contains(text(),"商品关键字:")]/following-sibling::div//input','bbbbb')

        # 商品备注

        send_keys(driver,'//label[contains(text(),"商品备注:")]/following-sibling::div//textarea','10101010')

        # 选择优惠方式

        click_demo(driver,'(//label[contains(text(),"选择优惠方式:")]/following-sibling::div//span)[2]')


        # 特惠促销
        #     开始时间
        send_keys(driver,'//div[contains(text(),"开始时间:")]/div/input','2019-04-02 16:25:01')

        # 结束时间

        send_keys(driver,'//div[contains(text(),"结束时间:")]/div/input','2019-04-10 16:32:01')

        # 促销价格

        send_keys(driver,'//div[contains(text(),"促销价格:")]/div/input','9999')



        # 下一步,填写商品属性

        click_demo(driver,'//span[contains(text(),"下一步,填写商品属性")]')

        # xiayibu1 = driver.find_element_by_xpath('//span[contains(text(),"下一步,填写商品属性")]')
        # xiayibu1.click()
        # time.sleep(2)

        # 下一步,选择商品关联

        click_demo(driver,'//span[contains(text(),"下一步,选择商品关联")]')

        # xiayibu2 = driver.find_element_by_xpath('//span[contains(text(),"下一步,选择商品关联")]')
        # xiayibu2.click()
        # time.sleep(2)

        # 完成,提交商品

        click_demo(driver,'//span[contains(text(),"完成,提交商品")]')

        # wancheng = driver.find_element_by_xpath('//span[contains(text(),"完成,提交商品")]')
        # wancheng.click()
        # time.sleep(2)

        # 确定

        click_demo(driver,'(//span[contains(text(),"确定")])[3]')

        # queding = driver.find_element_by_xpath('//span[contains(text(),"确定")]')
        # queding.click()
        # time.sleep(2)






        assertions = Assertions()
        assertions.assert_in_text(driver.page_source, '填写商品信息')
Beispiel #8
0
    def test_demo1(self):

        # 确定chromedriver.exe的位置
        driver_path = os.path.join(os.path.dirname(__file__),
                                   "../../chromedriver/chromedriver.exe")

        # 打开浏览器
        driver = webdriver.Chrome(driver_path)
        driver.maximize_window()  # 最大化浏览器
        driver.implicitly_wait(8)  # 设置隐式时间等待

        # 打开网址
        driver.get("http://192.168.60.132/#/login")
        # 输入用户名
        username = driver.find_element_by_xpath("//input[@name='username']")
        username.clear()
        username.send_keys('admin')
        # 输入密码
        password = driver.find_element_by_xpath("//input[@name='password']")
        password.clear()
        password.send_keys('123456')
        # 点击登录
        login = driver.find_element_by_xpath("//span[contains(text(),'登录')]")
        login.click()
        time.sleep(2)
        print(driver.page_source)
        # 断言

        assertions = Assertions()
        assertions.assert_in_text(driver.page_source, '首页')

        # 点击营销
        dianji = driver.find_element_by_xpath(
            "// span[contains(text(), '营销')]")
        dianji.click()
        assertions = Assertions()
        assertions.assert_in_text(driver.page_source, '秒杀活动列表')
        time.sleep(2)
        # 点击优惠券列表
        youhui = driver.find_element_by_xpath(
            "// span[contains(text(), '优惠券列表')]")
        youhui.click()
        time.sleep(2)
        assertions = Assertions()
        assertions.assert_in_text(driver.page_source, '优惠券类型')
        time.sleep(2)

        # 输入优惠券名称
        mingcheng = driver.find_element_by_xpath(
            "//label[contains(text(),'优惠券名称')]/following-sibling::div//input")
        mingcheng.clear()
        # mingcheng.click()
        mingcheng.send_keys('全品类')
        time.sleep(2)
        assertions = Assertions()
        assertions.assert_in_text(driver.page_source, '全品类')
        time.sleep(2)
        # 点击查询搜索
        chaxun = driver.find_element_by_xpath(
            "// span[contains(text(), '查询')]")
        chaxun.click()
        assertions = Assertions()
        assertions.assert_in_text(driver.page_source, '全品类')

        # 退出
        driver.quit()
        pass
Beispiel #9
0
    def test_demo1(self, driver):
        base = baseUI(driver)

        driver.get("http://192.168.60.132/login#/home")
        base.send_keys("输入用户名", "//input[@name='username']", "admin")
        base.send_keys("输入密码", "//input[@name='password']", "123456")
        # 点击登录
        base.click("点击登录", "//span[contains(text(),'登录')]")
        #点击订单(//span[contains(text(),'订单')])[1]
        base.click("点击订单", "//span[contains(text(),'订单')]")
        # 点击订单列表(//span[contains(text(),'订单列表')]
        base.click("点击订单列表", "//span[contains(text(),'订单列表')]")
        # 点击订单状态//label[contains(text(),'订单状态:')]/following-sibling::div//input
        base.click(
            "点击订单状态",
            "//label[contains(text(),'订单状态:')]/following-sibling::div//input")
        # 点击待发货//span[contains(text(),'待发货')]
        base.click("点击代发货", "//span[contains(text(),'待发货')]")
        # 点击查询搜索//span[contains(text(),'查询搜索')]
        base.click("点击查询搜索", "//span[contains(text(),'查询搜索')]")
        # 记录编号//tbody/tr[1]/td[2]/div
        num = base.get_text("第一条编号", "//tbody/tr[1]/td[2]/div")
        # 记录订单编号
        order_num = base.get_text("点击第一条订单编号", "//tbody/tr[1]/td[3]/div")
        # 点击第一条订单发货
        base.click("点击第一条订单发货", "//tbody/tr[1]/td[10]/div/button[3]")
        # 选择物理公司//input[@readonly='readonly']
        base.click("选择物理公司", "//input[@readonly='readonly']")
        # 选择顺丰//span[contains(text(),'顺丰')]
        base.click("选择顺丰", "//span[contains(text(),'顺丰')]")
        # 输入订单编号
        base.send_keys(
            "选择顺丰",
            "//*[@id='app']/div/div[2]/section/div/div[2]/div[1]/div[3]/table/tbody/tr/td[7]/div/div/input",
            '123456789')
        # 点击确定//span[contains(text(),'确定')]
        base.click("点击确定", "//span[contains(text(),'确定')]")
        # 点击确定(//span[contains(text(),'确定')])[2]
        base.click("点击确定", "(//span[contains(text(),'确定')])[2]")
        # 断言
        # print(driver.page_source)
        xpath = driver.find_element_by_xpath("//div[@role='alert']/p")
        # print(xpath.text)
        assertions = Assertions()
        assertions.assert_in_text(xpath.text, '发货成功!')

        # 点击订单状态//label[contains(text(),'订单状态:')]/following-sibling::div//input
        base.click(
            "点击订单状态",
            "//label[contains(text(),'订单状态:')]/following-sibling::div//input")
        # 点击已发货//span[text()='待发货']
        base.click("点击已发货", "//span[text()='已发货']")
        #输入订单编号//input[@placeholder='订单编号']
        base.send_keys("输入订单编号", "//input[@placeholder='订单编号']", order_num)
        # 点击搜索查询//span[contains(text(),'查询搜索')]
        base.click("点击搜索查询", "//span[contains(text(),'查询搜索')]")
        #定位到刚才发货的订单
        time.sleep(1)
        #通过xpath定位到一组元素,存到一个list中
        nums = driver.find_elements_by_xpath("(//tbody)[1]/tr/td[2]")
        #存放是否能找到编号 找到true  未找到 false
        b = False
        #遍历上边的list
        for n in nums:
            #n.text取出元素的可视文本
            print(n.text)
            #判断可视文本是否与发货订单的编号相同
            if n.text == num:
                #如果相同,就讲true赋值给b
                b = True
        #断言,订单状态转换是否正确
        assert True == b
        time.sleep(3)