예제 #1
0
def browseproduct(action: ElementActions, key='专场', position=0):
    p.搜索后列表页.pageinto(action, key)
    # 点击对应position的商品
    action.sleep(1).click_ele(
        action.find_ele(p.搜索后列表页.商品项标题s, is_Multiple=True)[position]).sleep(2)

    productname_ele = None
    for index in range(10):
        action.swip_down()
        tmpele = action.find_ele(p.商品详情页.商品参数列表)
        goods_value_eles = action.find_ele_child(tmpele,
                                                 p.商品详情页.商品参数列表_商品参数值s,
                                                 is_Multiple=True,
                                                 wait=3)
        if len(goods_value_eles) > 0:
            productname_ele = goods_value_eles[0]
            break
    if productname_ele == None:
        raise NotFoundElementError

    action.get_img('商品详情页')
    productname = action.get_text_ele(productname_ele)

    return productname
예제 #2
0
    def test_home(self, action: ElementActions):

        # up.登录页.login(action,'13550234762','tmhrush2233')

        action.click(p.特卖首页.搜索输入框)

        #因为调用action的大部分公用方法是返回self,所以可以一条语句执行多次不同方法
        action.text(p.分类列表搜索页.搜索输入框,"口红")\
            .click(p.分类列表搜索页.搜索按钮)

        action.click(p.搜索后列表页.第一个商品项)

        #循环下拉,检查是否有对应关键字,找到后终止
        for count in range(20):
            if action.swip_down().is_text_displayed("商品参数"):
                break
        #没有对应关键字抛出错误
        if action.is_text_displayed("口红") == False:
            raise NotFoundTextError

        action.sleep(1)