随笔 - 63,  文章 - 0,  评论 - 4,  阅读 - 10万

此方法不比手动快,仅仅只是作为appium的练手项目

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import logging
 
from appium import webdriver
import time
from appium.webdriver.common.mobileby import MobileBy
from appium.webdriver.common.touch_action import TouchAction
 
class TestXueQiu:
    def setup(self):
        caps = {}
        caps["platformName"] = "android"
        caps["deviceName"] = "ld"
        caps["appPackage"] = "com.jingdong.app.mall"
        caps["appActivity"] = "com.jingdong.app.mall.main.MainActivity"
        caps["chromedriverExecutable"] = r"E:\python\chromedriver.exe"
        caps["noReset"] = True
        caps["skipDeviceInitialization"] = True
 
 
        self.driver = webdriver.Remote("http://127.0.0.1:4723/wd/hub", caps)
        self.driver.implicitly_wait(20)
 
    def test_search(self):
        self.driver.find_element(MobileBy.XPATH,"//*[@content-desc='购物车1']").click()
        self.driver.tap([(80,2109),(140,2109),(120,2080)],500)
 
        # 全选购物车
        actions = TouchAction(self.driver)
        actions.tap(x=120,y=2109)
        cycle=0
        while True:
            actions.perform()
            if '去结算(1)' in self.driver.page_source:
                break
            else:
 
                self.driver.find_element(MobileBy.XPATH,"//*[@content-desc='购物车1']").click()
                time.sleep(1)
                cycle+=1
                logging.warning("the {} time try buy".format(cycle))
 
        self.driver.find_element(MobileBy.XPATH, "//*[contains(@content-desc,'去结算')]").click()
        self.driver.find_element(MobileBy.XPATH, "//*[contains(@text,'提交订单')]").click()
 
 
    def teardown(self):
        time.sleep(10)
        self.driver.quit()

  

posted on   盈盈的月儿  阅读(3608)  评论(0编辑  收藏  举报
编辑推荐:
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· C#/.NET/.NET Core技术前沿周刊 | 第 29 期(2025年3.1-3.9)
· 从HTTP原因短语缺失研究HTTP/2和HTTP/3的设计差异

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示