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
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]')
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]')
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')
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')
def goods_attrib_select(driver,attrib_name,attrib_content): """ attrib_name: 商品属性规格名称 1.存储容量、手机维修、手机保修、手机外观、屏幕情况、购买情况、全新非全新 2.在未滑动屏幕时,从上到下,元素定位: //android.widget.LinearLayout[1] 1 2 3 ... attrib_content: 属性内容 LinearLayout 1 2 3 .. Usage: goods_attrib_select(driver,1,1) """ el = "//android.widget.LinearLayout[attribute_name_num]/android.widget.GridView[1]/android.widget.LinearLayout[attribute_content_num]/android.widget.CheckBox[1]" attribute = el.replace("attribute_name_num",attrib_name).replace("attribute_content_num",attrib_content) el_xpath_click(driver,attribute)
def goods_attrib_select(driver, attrib_name, attrib_content): """ attrib_name: 商品属性规格名称 1.存储容量、手机维修、手机保修、手机外观、屏幕情况、购买情况、全新非全新 2.在未滑动屏幕时,从上到下,元素定位: //android.widget.LinearLayout[1] 1 2 3 ... attrib_content: 属性内容 LinearLayout 1 2 3 .. Usage: goods_attrib_select(driver,1,1) """ el = "//android.widget.LinearLayout[attribute_name_num]/android.widget.GridView[1]/android.widget.LinearLayout[attribute_content_num]/android.widget.CheckBox[1]" attribute = el.replace("attribute_name_num", attrib_name).replace("attribute_content_num", attrib_content) el_xpath_click(driver, attribute)
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
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
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