Appium + python - weixin number of public operations

from appium import webdriver
from time import sleep

desired_caps = {
"platformName":"Android",
"platformVersion":"9",
"deviceName":"4871660c",
"appPackage":"com.tencent.mm",
"appActivity":".ui.LauncherUI",
"chromeOptions":"{'androidProcess':'com.tencent.mm:tools'}",
"automationName":"Uiautomator2",
"unicodeKeyboard":True,
"resetKeyboard":True,
"noReset":True
}

driver = webdriver.Remote("http://localhost:4723/wd/hub",desired_caps)
driver.implicitly_wait (10) sleep (3) # type in the search . driver.find_element_by_id ( "com.tencent.mm:id/jb") the Click () # point micro-channel home search button

the try:





id_text = 'resourceId ( "com.tencent.mm:id/l3" ). text ( " search")'
driver.find_element_by_android_uiautomator (id_text) .send_keys ( "yoyoketang \ n-")

# opening the public No.
SLEEP (. 3)
id_text1 = 'resourceId ( "com.tencent.mm:id/qm") . text ( " start from scratch to learn automated testing")'
driver.find_element_by_android_uiautomator (id_text1) .click ()

# click on the number of public courses menu -2019
# sleep ( 3)
# id_text2 = 'resourceId ( "com.tencent.mm:id/an0"). text ( "2019 program")'
# driver.find_element_by_android_uiautomator (id_text2) .click ()
# = driver.contexts contexts
# Print (contexts )

# handover Webview
# SLEEP (. 3)
# driver.switch_to_default_content ( "WEBVIEW_com.tencent.mm:tools ")

# click user name - Shanghai
SLEEP # (3)
# id_text3 = '. ResourceId ( "js_author_name") text ( "Shanghai yo")'
# driver.find_element_by_android_uiautomator (id_text3) .click ()
# Print (driver.contexts)

# Click History - django tutorial
SLEEP (. 3)
id_text4 = 'The resourceId ( "com.tencent.mm:id/an0"). text ( "history")'
List1 = driver.find_element_by_android_uiautomator (id_text4) .click ()
# = driver.find_elements_by_xpath List1 ( " // * [@ text = 'history'] "). the Click ()
Print (of the type (List1), List1)
Print (driver.contexts)
# driver.switch_to.context ( 'WEBVIEW_com.tencent.mm:tools')
# class_text = 'className ( "android.widget.TextView "). text ( "django tutorial")'
# driver.find_element_by_android_uiautomator(class_text).click()
# contexts = driver.contexts
# print(contexts)

# sleep(3)
# driver.switch_to.context( 'NATIVE_APP')
#

#
#点击django合集
# id_text5 = 'resourceId("com.tencent.mm:id/cx").text("django合集")'
# driver.find_element_by_android_uiautomator(id_text5).click()
# print(driver.contexts)


# id_text6 = 'resourceId("activity-name").text("django合集")'
# apps = driver.find_elements_by_android_uiautomator(id_text6)
# for item in apps:
# print(item)

except Exception :
print("Error")
#退出微信应用
driver.quit()

Guess you like

Origin www.cnblogs.com/Teachertao/p/10990969.html