京东抢券活动
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

42 lines
1.4 KiB

from appium import webdriver
from appium.options.android import UiAutomator2Options
import time
class JdClient:
def __init__(self, device_name):
self.desired_caps = {
'platformName': 'Android',
'deviceName': device_name,
'platformVersion': '12.0',
'appPackage': 'com.jingdong.app.mall',
'appActivity': 'main.MainActivity',
'noReset': True,
'appium:automationName': 'UiAutomator2',
'newCommandTimeout': 6000,
'udid': device_name,
}
self.device =None
def initial_device(self, port):
print(f'设备:{self.desired_caps}')
self.device = webdriver.Remote(f'http://127.0.0.1:{port}/wd/hub', options=UiAutomator2Options().load_capabilities(self.desired_caps))
time.sleep(5)
x = self.device.get_window_size()['width']
y = self.device.get_window_size()['height']
print(f'{self.desired_caps["deviceName"]}屏幕尺寸:{x}x{y}')
def do(self, msg_dict):
self.device.set_clipboard_text(msg_dict['msg'])
print(self.device.get_clipboard_text())
time.sleep(0.5)
print(f'{self.desired_caps["platformName"]}点击')
self.device.tap([(550, 1263)], 100)
if __name__ == '__main__':
jd_client = JdClient('127.0.0.1:16416')
jd_client.initial_device(4723)
jd_client.do('玩具乐器五折券')