appium- operating micro-channel number and the public applets

1: View the current micro-channel micro-channel public number of running processes

C:\Users\edz>adb shell dumpsys activity top | findstr ACTIVITY
  ACTIVITY com.netease.cloudmusic/.activity.LockScreenActivity cb44411 pid=3869
  ACTIVITY com.tencent.mobileqq/.activity.SplashActivity 21ccf14 pid=6919
  ACTIVITY com.tencent.mm/.plugin.webview.ui.tools.WebViewUI 9e57c31 pid=18417
  ACTIVITY net.oneplus.launcher/net.oneplus.quickstep.RecentsActivity 9818f4e pid=3098
  ACTIVITY net.oneplus.h2launcher/.Launcher 71ce3d9 pid=3116
  ACTIVITY com.oneplus.gallery/.OPGalleryActivity 4b4055 pid=12000

2: Check the name of the current process

C:\Users\edz>adb shell ps 18417
USER           PID  PPID     VSZ    RSS WCHAN            ADDR S NAME
u0_a96       18417   884 2323872 217064 SyS_epoll_wait      0 S com.tencent.mm:tools

 

3: micro-channel operation or a small number of public desired_caps program are:

desired_caps={
    'platformName':'Android',
    'uiautomationName':'uiautomator2',
    'platformVersion':'9',
    'deviceName':'e8dfc3c6',
    'appPackage':'com.tencent.mm',
    'appActivity':'.ui.LauncherUI',
     ' AutomationName ' : ' com.taobao.tao.welcome.Welcome ' ,
     ' unicodeKeyboard ' : True,
     ' resetKeyboard ' : True,
     ' NoReset ' : True,
     ' chromedriverExecutable ' : ' D: \ Program Files \ \\ chromedriver 2.37 chromedriver.exe \\ ' , # Chrome micro-channel path specified applet running 
    ' chromeOptions ' : { ' androidProcess ' : ' com.tencent.mm:tools'},# Designated micro-channel applet running processes 
    ' BrowserName ' : "" ,
     " recreateChromeDriverSessions " : True 
}

4: After entering the page H5 requires context switching

Print (driver.contexts) # print all contexts 
Print (driver.current_context) # Get the current context 
driver.switch_to.context ( " WEBVIEW_com.tencent.mm:tools " ) # Jump context we need to 
Print (driver.current_context ) 
run results: 
[ ' NATIVE_APP ' , ' WEBVIEW_com.tencent.mm:tools ' ] 
NATIVE_APP 
WEBVIEW_com.tencent.mm:tools

 

5: Some small micro-channel or program can not be operated after switching context, it may be necessary to jump handler, because of which window is currently uncertain, it is possible to do so

handles=driver.window_handles
for handle in handles:
    driver.switch_to.window(handle)
    if driver.page_source.find("患者姓名")!=-1:
        break

 

Guess you like

Origin www.cnblogs.com/Be-your-own-hero/p/11345558.html