思路:
思路跟短信验证码是一样的(/qq_42460470/article/details/100288798),不一样的只是操作而已。那怎么让手机飘起来扫码呢,把web端二维码的截图截下来,发到手机里,然后打开能扫码的工具,点击本地相册,找到刚才传过来的截图就扫上了啊。多简单。(截图:/qq_42460470/article/details/100307432)
代码:
import osself.driver.find_element_by_xpath('//*[@id="erweima"]').click()#在web端打开二维码time.sleep(2)#Method.Handle(self,1)time.sleep(2)self.driver.get_screenshot_as_file('C:\\Users\\11111\\Desktop\\1111r.png')#截屏os.system('adb push C:\\Users\\111111\\Desktop\11111r.png /sdcard/tencent/MicroMsg/WeiXin/')#把截屏复制到手机from appium import webdriverdesired_caps = {'platformName': 'Android', # 设备系统'deviceName': 'f0eb6a74', # 设备名称'platformVersion': '9', # 设备系统版本'appPackage': 'com.xiaomi.scanner', # apk包名'appActivity': 'com.xiaomi.scanner.app.ScanActivity' # apk的launcherActivity}driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)time.sleep(2)driver.tap([(796, 2027)]) # 坐标不通用,手机上的操作上面有提到,根据实际情况写time.sleep(2)driver.tap([(796, 2027)])
补充:
执行完之后好像是会报warning,报的话看这个
/qq_42460470/article/details/100318590
#学习笔记