# -*- coding: utf-8 -*- # @Author: wangkun # @Time: 2023/2/10 from appium import webdriver from selenium.webdriver.common.by import By class Searchkey: @classmethod def start_weixinzhishu(cls): desired_caps = {'app': 'Root', 'deviceName': 'windowsPC', 'platformName': 'Windows'} driver = webdriver.Remote( command_executor='http://127.0.0.1:4723', desired_capabilities=desired_caps) main_win = driver.find_element(By.NAME, '微信指数') print(main_win) hd = hex(int(main_win.get_attribute("NativeWindowHandle"))) print(hd) caps = {'appTopLevelWindow': str(hd)} driver = webdriver.Remote( command_executor='http://127.0.0.1:4723', desired_capabilities=caps) if __name__ == "__main__": Searchkey.start_weixinzhishu()