orderzmz

Posted liuyun66535309

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了orderzmz相关的知识,希望对你有一定的参考价值。

#-*- coding:utf-8 -*-
import APPMethod,PublicMethod,os
from appium import webdriver
from TOMTOP.androidtest import *
from time import *

class Order():
    def __init__(self,keywords):
        self.keywords=keywords

        conName=K06TJ64180003473
        taskTepmDir=C:\01mywork\workspace\ROBOT\TestAutomationForIT5\data
        #startAppium(conName,taskTepmDir)
        self.desired_caps = {}
        self.desired_caps[platformName]=Android
        self.desired_caps[platformVersion]=6.0
        self.desired_caps[deviceName]=K06TJ64180003473
        self.desired_caps[appPackage]=com.amazon.mShop.android.shopping
        self.desired_caps[appActivity]=com.amazon.mShop.home.HomeActivity
        self.desired_caps[appWaitActivity]=com.amazon.mShop.home.HomeActivity
        self.driver = webdriver.Remote(http://localhost:4723/wd/hub,self.desired_caps)
        self.driver.implicitly_wait(10)

    def search(self):
        driver=self.driver
        SetSougouIme(self.desired_caps[deviceName])
        APPMethod.click_element(driver,rs_search_src_text,id)
        driver.find_element_by_id(rs_search_src_text).send_keys(self.keywords)
        driver.press_keycode(66)
        SetAppiumIme(self.desired_caps[deviceName])

    # 粗略的翻阅商品详情页
    def rough_reading_of_details(self):
        pass

    # 仔细的翻阅商品详情页
    def read_the_details_carefully(self):
        pass

    # 加入购物车
    def add_to_cart(self):
        driver=self.driver
        for i in range(5):
            driver.swipe(100,810,100,390)
            try:
                sleep(2)
                driver.find_element_by_accessibility_id(Add to Cart).click()
            except:
                print u没找到Add to Cart,再往下滑一下!

    # 直接购买
    def buy_now(self):
        driver=self.driver
        for i in range(5):
            driver.swipe(100,810,100,390)
            try:
                sleep(2)
                driver.find_element_by_accessibility_id(Buy Now).click()
            except:
                print u没找到Buy Now,再往下滑一下!

    # 选择颜色和尺寸
    def select_size_color(self):
        driver=self.driver
        APPMethod.wait_element_OK(driver,glow_subnav_label,id)
        sleep(10)
        print u上滑一下
        driver.swipe(100,800,100,410)
        sleep(5)
        print u点击选择尺寸按钮
        locator=driver.find_element_by_xpath(//android.widget.Button[contains(@content-desc,"Size")]).location
        x=int(locator[x])
        y=int(locator[y])
        driver.tap([(x+300,y+60)])
        sleep(5)
        driver.tap([(82,657)])# 选择尺寸82 240 397
        sleep(5)
        driver.flick(100,800,500,800)# 快速右滑
        driver.flick(100,800,500,800)
        driver.tap([(130,1000)])# 选择颜色
        sleep(5)
        ‘‘‘
        cmd=‘adb shell input keyevent 4‘#触发手机上的back键,实现DONE退出
        os.popen(cmd)
        driver.tap([(640,475)])# 点击DONE坐标
        ‘‘‘
        driver.find_element_by_accessibility_id(DONE).click()# 返回 DONE
        sleep(3)
        self.buy_now()
        cmd=adb shell input keyevent 4#触发手机上的back键,实现退出
        os.popen(cmd)
        sleep(5)

    def for_product(self):
        driver=self.driver
        APPMethod.wait_element_OK(driver,item_title,id)
        print u开始向上滑动
        for i in range(30):
            # 统计显示的商品名称数量,并打印
            p_title=driver.find_elements_by_id(item_title)
            for i in range(len(p_title)):
                if p_title[i].text=="Lark & Ro Women‘s Sleeveless Color-Block A-Line Dress":
                    p_title[i].click()
                    self.select_size_color()
                    break
            # 滑动页面
            driver.swipe(100,800,100,410)
            PublicMethod.random_sleep(1,3)
        print u向上滑动完成了


if __name__==__main__:
    keywords=dress
    order=Order(keywords)
    order.search()
    order.for_product()

 

#-*- coding:utf-8 -*-import APPMethod,PublicMethod,osfrom appium import webdriverfrom TOMTOP.androidtest import *from time import *
class Order():    def __init__(self,keywords):        self.keywords=keywords
        conName=‘K06TJ64180003473‘        taskTepmDir=‘C:\01mywork\workspace\ROBOT\TestAutomationForIT5\data‘        #startAppium(conName,taskTepmDir)        self.desired_caps = {}        self.desired_caps[‘platformName‘]=‘Android‘        self.desired_caps[‘platformVersion‘]=‘6.0‘        self.desired_caps[‘deviceName‘]=‘K06TJ64180003473‘        self.desired_caps[‘appPackage‘]=‘com.amazon.mShop.android.shopping‘        self.desired_caps[‘appActivity‘]=‘com.amazon.mShop.home.HomeActivity‘        self.desired_caps[‘appWaitActivity‘]=‘com.amazon.mShop.home.HomeActivity‘        self.driver = webdriver.Remote(‘http://localhost:4723/wd/hub‘,self.desired_caps)        self.driver.implicitly_wait(10)
    def search(self):        driver=self.driver        SetSougouIme(self.desired_caps[‘deviceName‘])        APPMethod.click_element(driver,‘rs_search_src_text‘,‘id‘)        driver.find_element_by_id(‘rs_search_src_text‘).send_keys(self.keywords)        driver.press_keycode(66)        SetAppiumIme(self.desired_caps[‘deviceName‘])
    # 粗略的翻阅商品详情页    def rough_reading_of_details(self):        pass
    # 仔细的翻阅商品详情页    def read_the_details_carefully(self):        pass
    # 加入购物车    def add_to_cart(self):        driver=self.driver        for i in range(5):            driver.swipe(100,810,100,390)            try:                sleep(2)                driver.find_element_by_accessibility_id(‘Add to Cart‘).click()            except:                print u‘没找到Add to Cart,再往下滑一下!‘
    # 直接购买    def buy_now(self):        driver=self.driver        for i in range(5):            driver.swipe(100,810,100,390)            try:                sleep(2)                driver.find_element_by_accessibility_id(‘Buy Now‘).click()            except:                print u‘没找到Buy Now,再往下滑一下!‘
    # 选择颜色和尺寸    def select_size_color(self):        driver=self.driver        APPMethod.wait_element_OK(driver,‘glow_subnav_label‘,‘id‘)        sleep(10)        print u‘上滑一下‘        driver.swipe(100,800,100,410)        sleep(5)        print u‘点击选择尺寸按钮‘        locator=driver.find_element_by_xpath(‘//android.widget.Button[contains(@content-desc,"Size")]‘).location        x=int(locator[‘x‘])        y=int(locator[‘y‘])        driver.tap([(x+300,y+60)])        sleep(5)        driver.tap([(82,657)])# 选择尺寸82 240 397        sleep(5)        driver.flick(100,800,500,800)# 快速右滑        driver.flick(100,800,500,800)        driver.tap([(130,1000)])# 选择颜色        sleep(5)        ‘‘‘        cmd=‘adb shell input keyevent 4‘#触发手机上的back键,实现DONE退出        os.popen(cmd)        driver.tap([(640,475)])# 点击DONE坐标        ‘‘‘        driver.find_element_by_accessibility_id(‘DONE‘).click()# 返回 DONE        sleep(3)        self.buy_now()        cmd=‘adb shell input keyevent 4‘#触发手机上的back键,实现退出        os.popen(cmd)        sleep(5)
    def for_product(self):        driver=self.driver        APPMethod.wait_element_OK(driver,‘item_title‘,‘id‘)        print u‘开始向上滑动‘        for i in range(30):            # 统计显示的商品名称数量,并打印            p_title=driver.find_elements_by_id(‘item_title‘)            for i in range(len(p_title)):                if p_title[i].text=="Lark & Ro Women‘s Sleeveless Color-Block A-Line Dress":                    p_title[i].click()                    self.select_size_color()                    break            # 滑动页面            driver.swipe(100,800,100,410)            PublicMethod.random_sleep(1,3)        print u‘向上滑动完成了‘

if __name__==‘__main__‘:    keywords=‘dress‘    order=Order(keywords)    order.search()    order.for_product()












以上是关于orderzmz的主要内容,如果未能解决你的问题,请参考以下文章

VSCode自定义代码片段——CSS选择器

谷歌浏览器调试jsp 引入代码片段,如何调试代码片段中的js

片段和活动之间的核心区别是啥?哪些代码可以写成片段?

VSCode自定义代码片段——.vue文件的模板

VSCode自定义代码片段6——CSS选择器

VSCode自定义代码片段——声明函数