程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Python/appium simulates the user to slide down to find the app with the best public praise column in the app interface of the application mall, and outputs it

編輯:Python
# Determine screen size 
screen_size=driver.get_window_size()
s_heigt=screen_size['height']
s_width=screen_size['width']
start_x=s_width/2
start_y=s_width*0.8
end_x=start_x
end_y=start_y-300
# Save app title 
bestapptext=[]
# Find the best target element of word of mouth while sliding 
while True:
# Sliding operation 
driver.swipe(start_x,start_y,end_x,end_y)
# The current condition for terminating the loop is to find the word-of-mouth element 
koubei=driver.find_elements_by_xpath('//android.widget.TextView[@content-desc="best reputation"]')
# Train of thought to find all the following through word-of-mouth app name text Elements , come to know ImageView Followed by TextView. Can pass xpath find 
# //*[@content-desc="best reputation"]/following-sibling::android.widget.ImageView/following-sibling::android.widget.TextView[1]'
if koubei:
best_apps_kb=driver.find_elements_by_xpath(
'//*[@content-desc="best reputation"]/following-sibling::android.widget.ImageView/following-sibling::android.widget.TextView[1]')
bestapptext.extend([app.text for app in best_apps_kb])
# If you find that users love to stop 
zuiai=driver.find_elements_by_xpath('//android.widget.TextView[@content-desc="user favorite"]')
if zuiai:
best_apps_za = driver.find_elements_by_xpath(
'//*[@content-desc="best favorite"]/following-sibling::android.widget.ImageView/following-sibling::android.widget.TextView[1]')
bestapptext.extend([app.text for app in best_apps_za])
break
# Assume that the current screen has the best reputation 
#if best_apps_kb==[] and best_apps_za==[]:
# Print the results 
bestapptext=set(bestapptext)# The same coverage 
print(' Word of mouth is the best :')
print(bestapptext)

  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved