예제 #1
0
def goods_attribute(driver):
    try:
        el_click(driver, cfg.get('release', 'goods_attribute'))
        screenshot(driver, 'screenshot/Release_GoodsAttribute_init_page.png')

        # 存储容量、手机维修、手机保修、手机外观、屏幕情况
        goods_attrib_select(driver, "1", "2")
        goods_attrib_select(driver, "2", "2")
        goods_attrib_select(driver, "3", "2")
        goods_attrib_select(driver, "4", "2")
        goods_attrib_select(driver, "5", "2")
        screenshot(
            driver,
            'screenshot/Release_GoodsAttribute_choice_swipe_before.png')

        # 滑动到底部
        sw.down_swipe(driver)

        # 购买渠道、全新非全新
        goods_attrib_select(driver, "5", "2")
        goods_attrib_select(driver, "6", "2")
        screenshot(driver, 'screenshot/Release_GoodsAttribute_finish.png')

    except:
        screenshot(driver, 'screenshot/Release_GoodsAttribute_error.png')
    else:
        el_click(driver, cfg.get('release', 'complete'))
        screenshot(driver, 'screenshot/Release_GoodsAttribute_end.png')
예제 #2
0
def goods_attribute(driver):
    try:
        el_click(driver,cfg.get('release','goods_attribute'))
        screenshot(driver,'screenshot/Release_GoodsAttribute_init_page.png')

        # 存储容量、手机维修、手机保修、手机外观、屏幕情况
        goods_attrib_select(driver,"1","2")
        goods_attrib_select(driver,"2","2")
        goods_attrib_select(driver,"3","2")
        goods_attrib_select(driver,"4","2")
        goods_attrib_select(driver,"5","2")
        screenshot(driver,'screenshot/Release_GoodsAttribute_choice_swipe_before.png')

        # 滑动到底部
        sw.down_swipe(driver)
        
        # 购买渠道、全新非全新
        goods_attrib_select(driver,"5","2")
        goods_attrib_select(driver,"6","2")
        screenshot(driver,'screenshot/Release_GoodsAttribute_finish.png')
        
    except:
        screenshot(driver,'screenshot/Release_GoodsAttribute_error.png')
    else:
        el_click(driver,cfg.get('release','complete'))
        screenshot(driver,'screenshot/Release_GoodsAttribute_end.png')
예제 #3
0
def add_video(driver):
    """ 添加视频使用xpath定位

        //android.support.v7.widget.RecyclerView[1]/android.widget.RelativeLayout[3]/android.widget.ImageView[1]
        
        Usage:
            在当前页面,添加图片视频区域,从左到右,从1开始计数,<添加视频>按钮处于第几个,则RelativeLayout填写几即可.
            如:在只添加一张图、当前区域未进行滑动的情况下,RelativeLayout则为[3]
            
            若添加图片视频区域进行了滑动操作,添加视频框输入第一个,则RelativeLayout为[1]
    """
    try:
        screenshot(driver,'screenshot/Release_Video_init_page.png')

        el = "//android.support.v7.widget.RecyclerView[1]/android.widget.RelativeLayout[3]/android.widget.ImageView[1]"
        el_xpath_click(driver,el)

        # find: capture Video btn
        capture_btn = driver.find_element_by_id(cfg.get('release','capture_btn'))
        # 长按录制10s
        action = TouchAction(driver)
        action.long_press(capture_btn,None,None,10000).perform()

        screenshot(driver,'screenshot/Release_Video_capture_finish.png')        

        sleep(1)
        el_click(driver,cfg.get('release','capture_finish'))
        screenshot(driver,'screenshot/Release_Video_capture_commit.png')
        sleep(5)
    except:
        try:
            screenshot(driver,'screenshot/Release_Video_error.png')
            el_click(driver,cfg.get('release','capture_close'))
        except:
            pass
예제 #4
0
def online_goods(driver):

    el_click(driver,cfg.get('nav','my'))
    el_click(driver,cfg.get('release','option_my_release'))

    el_xpath_click(driver,'//android.widget.HorizontalScrollView[1]')

    goods_title = el_xpath_text(driver,'//android.widget.RelativeLayout[1]/android.widget.TextView[1]')
예제 #5
0
def online_goods(driver):

    el_click(driver, cfg.get('nav', 'my'))
    el_click(driver, cfg.get('release', 'option_my_release'))

    el_xpath_click(driver, '//android.widget.HorizontalScrollView[1]')

    goods_title = el_xpath_text(
        driver,
        '//android.widget.RelativeLayout[1]/android.widget.TextView[1]')
예제 #6
0
def choice_brand(driver):
    try:
        el_click(driver, cfg.get('release', 'choice_brand'))
        screenshot(driver, 'screenshot/Release_Brand_init_page.png')

        el = "//android.widget.ListView[1]/android.widget.LinearLayout[2]/android.widget.LinearLayout[1]"
        el_xpath_click(driver, el)
    except:
        return False
    else:
        screenshot(driver, 'screenshot/Release_Brand_select_finish.png')
예제 #7
0
def choice_brand(driver):
    try:
        el_click(driver,cfg.get('release','choice_brand'))
        screenshot(driver,'screenshot/Release_Brand_init_page.png')

        el = "//android.widget.ListView[1]/android.widget.LinearLayout[2]/android.widget.LinearLayout[1]"
        el_xpath_click(driver,el)
    except:
        return False    
    else:
        screenshot(driver,'screenshot/Release_Brand_select_finish.png')
예제 #8
0
def set_goods_type(driver):
    """ Func: Goods Type

        //android.widget.ListView[2]/android.widget.FrameLayout[1]/android.widget.RelativeLayout[1]
    """
    try:
        # set Goods Type
        el_click(driver,cfg.get('release','goods_type'))
        screenshot(driver,'screenshot/Release_GoodsType_init_page.png')

        # 分类: 一级
        driver.find_element_by_xpath('//android.widget.FrameLayout[1]').click()
        screenshot(driver,'screenshot/Release_GoodsType_first.png')
        #分类:二级
        el = "//android.widget.ListView[2]/android.widget.FrameLayout[1]/android.widget.RelativeLayout[1]"
        el_xpath_click(driver,el)
    except:
        screenshot(driver,'screenshot/Release_GoodsType_error.png')
        return False
예제 #9
0
def set_goods_type(driver):
    """ Func: Goods Type

        //android.widget.ListView[2]/android.widget.FrameLayout[1]/android.widget.RelativeLayout[1]
    """
    try:
        # set Goods Type
        el_click(driver, cfg.get('release', 'goods_type'))
        screenshot(driver, 'screenshot/Release_GoodsType_init_page.png')

        # 分类: 一级
        driver.find_element_by_xpath('//android.widget.FrameLayout[1]').click()
        screenshot(driver, 'screenshot/Release_GoodsType_first.png')
        #分类:二级
        el = "//android.widget.ListView[2]/android.widget.FrameLayout[1]/android.widget.RelativeLayout[1]"
        el_xpath_click(driver, el)
    except:
        screenshot(driver, 'screenshot/Release_GoodsType_error.png')
        return False
예제 #10
0
def add_photo(driver):
    """ 选择照片
    
        //android.widget.GridView[1]/android.widget.FrameLayout[3]/android.widget.ImageView[1]
    
        usage:
            在选择图片页面,从上到下,第一张照片: FrameLayout为[1]
    """
    try:
        el_click(driver,cfg.get('release','main_release'))
        sleep(1)
        screenshot(driver,'screenshot/Release_1_Photo_init_page.png')

        sleep(1)
        el = "//android.widget.GridView[1]/android.widget.FrameLayout[2]/android.widget.CheckBox[1]"
        #el_xpath_click(driver,e1)
        driver.find_element_by_xpath("//android.widget.CheckBox").click()
        sleep(1)
    except:
        return False
    else:
        screenshot(driver,'screenshot/Release_1_Photo_choice_finish.png')
        el_click(driver,cfg.get('release','ok'))
        screenshot(driver,'screenshot/Release_1_Photo_release.png')
예제 #11
0
def add_video(driver):
    """ 添加视频使用xpath定位

        //android.support.v7.widget.RecyclerView[1]/android.widget.RelativeLayout[3]/android.widget.ImageView[1]
        
        Usage:
            在当前页面,添加图片视频区域,从左到右,从1开始计数,<添加视频>按钮处于第几个,则RelativeLayout填写几即可.
            如:在只添加一张图、当前区域未进行滑动的情况下,RelativeLayout则为[3]
            
            若添加图片视频区域进行了滑动操作,添加视频框输入第一个,则RelativeLayout为[1]
    """
    try:
        screenshot(driver, 'screenshot/Release_Video_init_page.png')

        el = "//android.support.v7.widget.RecyclerView[1]/android.widget.RelativeLayout[3]/android.widget.ImageView[1]"
        el_xpath_click(driver, el)

        # find: capture Video btn
        capture_btn = driver.find_element_by_id(
            cfg.get('release', 'capture_btn'))
        # 长按录制10s
        action = TouchAction(driver)
        action.long_press(capture_btn, None, None, 10000).perform()

        screenshot(driver, 'screenshot/Release_Video_capture_finish.png')

        sleep(1)
        el_click(driver, cfg.get('release', 'capture_finish'))
        screenshot(driver, 'screenshot/Release_Video_capture_commit.png')
        sleep(5)
    except:
        try:
            screenshot(driver, 'screenshot/Release_Video_error.png')
            el_click(driver, cfg.get('release', 'capture_close'))
        except:
            pass
예제 #12
0
def add_photo(driver):
    """ 选择照片
    
        //android.widget.GridView[1]/android.widget.FrameLayout[3]/android.widget.ImageView[1]
    
        usage:
            在选择图片页面,从上到下,第一张照片: FrameLayout为[1]
    """
    try:
        el_click(driver, cfg.get('release', 'main_release'))
        sleep(1)
        screenshot(driver, 'screenshot/Release_1_Photo_init_page.png')

        sleep(1)
        el = "//android.widget.GridView[1]/android.widget.FrameLayout[2]/android.widget.CheckBox[1]"
        #el_xpath_click(driver,e1)
        driver.find_element_by_xpath("//android.widget.CheckBox").click()
        sleep(1)
    except:
        return False
    else:
        screenshot(driver, 'screenshot/Release_1_Photo_choice_finish.png')
        el_click(driver, cfg.get('release', 'ok'))
        screenshot(driver, 'screenshot/Release_1_Photo_release.png')
예제 #13
0
def to_buy(driver):
    el_click(driver, cfg.get('goods_details', 'tobuy'))
예제 #14
0
def release_goods(driver):

    # 选择照片
    add_photo(driver)

    # 填写标题
    el_send_keys(driver,cfg.get('release','goods_title'),goods_title)
    
    # 选择商品分类
    set_goods_type(driver)

    # 选择商品是否全新
    el_click(driver,cfg.get('release','new'))

    # 填写商品描述
    el_send_keys(driver,cfg.get('release','goods_describe'),goods_describe)

    # 增加视频
    add_video(driver)

    # 商品所在地
    el_location = el_text(driver,cfg.get('release','goods_location'))
    locate_fail_content = u'位置获取失败'
    
    if locate_fail_content in el_location:
        el_click(driver,cfg.get('release','goods_location'))
        screenshot(driver,'screenshot/Release_select_goods_location.png')
        el_click(driver,cfg.get('release','goods_location_btn'))
    else:
        pass

    screenshot(driver,'screenshot/Release_pageSwipe_begin.png')
    for c in range(3):
        sw.down_swipe(driver)
    screenshot(driver,'screenshot/Release_pageSwipe_behind.png')

    # 商品原价、商品售价、是否包邮
    sleep(2)
    el_send_keys(driver,cfg.get('release','goods_original_price'),goods_original_price)
    el_send_keys(driver,cfg.get('release','goods_sale_price'),goods_sale_price)
    el_click(driver,cfg.get('release','free_postage'))

    # 点击确定发布或下一步
    btn_content = el_text(driver,cfg.get('release','determine_release_btn'))

    btn_next_content = u"下一步"

    if btn_next_content in btn_content:
        screenshot(driver,'screenshot/Release_first_page_end.png')
        el_click(driver,cfg.get('release','release_next'))
        screenshot(driver,'screenshot/Release_second_page_start.png')
        # 选择品牌
        choice_brand(driver)
        # 属性规格
        goods_attribute(driver)

        el_click(driver,cfg.get('release','determine_release_btn'))        
        screenshot(driver,'screenshot/Release_TwoPage_finish.png')
    else:
        el_click(driver,cfg.get('release','determine_release_btn'))        
        screenshot(driver,'screenshot/Release_OnePage_finish.png')
예제 #15
0
def release_goods(driver):

    # 选择照片
    add_photo(driver)

    # 填写标题
    el_send_keys(driver, cfg.get('release', 'goods_title'), goods_title)

    # 选择商品分类
    set_goods_type(driver)

    # 选择商品是否全新
    el_click(driver, cfg.get('release', 'new'))

    # 填写商品描述
    el_send_keys(driver, cfg.get('release', 'goods_describe'), goods_describe)

    # 增加视频
    add_video(driver)

    # 商品所在地
    el_location = el_text(driver, cfg.get('release', 'goods_location'))
    locate_fail_content = u'位置获取失败'

    if locate_fail_content in el_location:
        el_click(driver, cfg.get('release', 'goods_location'))
        screenshot(driver, 'screenshot/Release_select_goods_location.png')
        el_click(driver, cfg.get('release', 'goods_location_btn'))
    else:
        pass

    screenshot(driver, 'screenshot/Release_pageSwipe_begin.png')
    for c in range(3):
        sw.down_swipe(driver)
    screenshot(driver, 'screenshot/Release_pageSwipe_behind.png')

    # 商品原价、商品售价、是否包邮
    sleep(2)
    el_send_keys(driver, cfg.get('release', 'goods_original_price'),
                 goods_original_price)
    el_send_keys(driver, cfg.get('release', 'goods_sale_price'),
                 goods_sale_price)
    el_click(driver, cfg.get('release', 'free_postage'))

    # 点击确定发布或下一步
    btn_content = el_text(driver, cfg.get('release', 'determine_release_btn'))

    btn_next_content = u"下一步"

    if btn_next_content in btn_content:
        screenshot(driver, 'screenshot/Release_first_page_end.png')
        el_click(driver, cfg.get('release', 'release_next'))
        screenshot(driver, 'screenshot/Release_second_page_start.png')
        # 选择品牌
        choice_brand(driver)
        # 属性规格
        goods_attribute(driver)

        el_click(driver, cfg.get('release', 'determine_release_btn'))
        screenshot(driver, 'screenshot/Release_TwoPage_finish.png')
    else:
        el_click(driver, cfg.get('release', 'determine_release_btn'))
        screenshot(driver, 'screenshot/Release_OnePage_finish.png')
예제 #16
0
def to_buy(driver):
    el_click(driver,cfg.get('goods_details','tobuy'))
    
예제 #17
0
def select_goods(driver):
    el_click(driver,cfg.get('nav','main'))
    for c in range(10):
        sw.down_swipe(driver)

    driver.find_element_by_xpath("//android.widget.RelativeLayout[2]").click()
예제 #18
0
def select_goods(driver):
    el_click(driver, cfg.get('nav', 'main'))
    for c in range(10):
        sw.down_swipe(driver)

    driver.find_element_by_xpath("//android.widget.RelativeLayout[2]").click()
예제 #19
0
def add_address(driver):
    sleep(1)
    # driver.find_element_by_id(cfg.get('nav','my')).click()
    # try:
    #     driver.find_element_by_id("com.jiuai:id/linearLayout_mask").click()
    # except NoSuchElementException:
    #     pass
    # driver.find_element_by_id(cfg.get('my','edit_profile')).click()
    # driver.find_element_by_id(cfg.get('personal_data','address')).click()

    el_click(driver,cfg.get('nav','my'))
    try:
        el_click(driver,cfg.get('my','register_mask'))
    except NoSuchElementException:
        pass

    el_click(driver,cfg.get('my','edit_profile'))
    el_click(driver,cfg.get('personal_data','address'))
    el_click(driver,cfg.get('address','add_address'))

    el_send_keys(driver,cfg.get('address','cnee_name'),cnee_name)
    el_send_keys(driver,cfg.get('address','cnee_phone'),cnee_phone)
    el_click(driver,cfg.get('address','cnee_area'))
    el_click(driver,cfg.get('address','select_area'))
    el_send_keys(driver,cfg.get('address','cnee_detail_address'),cnee_detail_address)
    el_click(driver,cfg.get('address','cnee_commit'))

    el_click(driver,cfg.get('action','back'))
    el_click(driver,cfg.get('action','home'))
예제 #20
0
def login_input_verify(driver,username,passwd):
    el_click(driver,cfg.get('login','user')).send_keys(username)
    el_click(driver,cfg.get('login','pwd')).send_keys(passwd)
예제 #21
0
def register(driver,username,identifying_code,password,nickname):
    #open register page
    sleep(3)
    el_click(driver,cfg.get('nav','my'))
    el_click(driver,cfg.get('my','personal'))
    el_click(driver,cfg.get('login','tvregister'))

    #register:the first step 
    el_click(driver,cfg.get('login','user')).send_keys(username)
    el_click(driver,cfg.get('register','getcode'))
    el_click(driver,cfg.get('register','inputcode')).send_keys(identifying_code)
    el_click(driver,cfg.get('login','pwd')).send_keys(password)
    sleep(2)
    driver.keyevent(66)
    el_click(driver,cfg.get('register','reg_next_btn'))
        
    #register:the second setp
    el_click(driver,cfg.get('register','nickname')).send_keys(nickname)
    el_click(driver,cfg.get('register','register_btn'))
    sleep(3)

    #register succesful page
    #assert ".activity.RegisterRecommendActivity" in driver.current_activity
    #sleep(2)
    driver.get_screenshot_as_file('screenshot/go_home.png')
    #driver.find_element_by_xpath("//android.widget.LinearLayout[@index='5']/ImageView")
    el_click(driver,cfg.get('register','gohome'))
    sleep(2)
예제 #22
0
def add_address(driver):
    sleep(1)
    # driver.find_element_by_id(cfg.get('nav','my')).click()
    # try:
    #     driver.find_element_by_id("com.jiuai:id/linearLayout_mask").click()
    # except NoSuchElementException:
    #     pass
    # driver.find_element_by_id(cfg.get('my','edit_profile')).click()
    # driver.find_element_by_id(cfg.get('personal_data','address')).click()

    el_click(driver, cfg.get('nav', 'my'))
    try:
        el_click(driver, cfg.get('my', 'register_mask'))
    except NoSuchElementException:
        pass

    el_click(driver, cfg.get('my', 'edit_profile'))
    el_click(driver, cfg.get('personal_data', 'address'))
    el_click(driver, cfg.get('address', 'add_address'))

    el_send_keys(driver, cfg.get('address', 'cnee_name'), cnee_name)
    el_send_keys(driver, cfg.get('address', 'cnee_phone'), cnee_phone)
    el_click(driver, cfg.get('address', 'cnee_area'))
    el_click(driver, cfg.get('address', 'select_area'))
    el_send_keys(driver, cfg.get('address', 'cnee_detail_address'),
                 cnee_detail_address)
    el_click(driver, cfg.get('address', 'cnee_commit'))

    el_click(driver, cfg.get('action', 'back'))
    el_click(driver, cfg.get('action', 'home'))