Tips : When the article is finished , Directories can be generated automatically , How to generate it, please refer to the help document on the right
use appium Simulate human sliding operation to obtain app Data to avoid frequent replacement ip The situation of , The disadvantage is that the speed of obtaining data will be relatively slow , This article introduces appium Get data content .
1,appium It's an open source mobile automation testing framework ;
2,appium You can test native 、 Mixed 、 And mobile web project ;
3,appium You can test ios,android application ( Yes, of course , also firefox os);
4,appium It's cross platform , Can be used in ios,windows as well as linux On the desktop ;
Appium Server GUI 1.22.3-4
Appium Inspector 2022.5.4
Night God Simulator The Android system used is 5.1.1
Android system needs to open developer mode , Turn on USB debugging
adopt Appium To operate the simulator to obtain data , use Appium Inspector, We can get app Of data in class,id,xpath etc. , To locate the data in the element .
In this way, you can only get the content displayed on the screen , Therefore, the code to judge the existence of elements through methods is as follows
The code is as follows :
from selenium.common.exceptions import NoSuchElementException
def isElementPresent(by, value):
try:
driver.find_element(by=by, value=value)
except NoSuchElementException:
# Print exception information
# print(NoSuchElementException)
# Something goes wrong , The element was not found in the description page , return False
return False
else:
# No abnormality , Indicates that the element was found in the page , return True
return True
from appium.webdriver.common.touch_action import TouchAction
# Get the mouse position
def get_size():
x = driver.get_window_size()['width']
y = driver.get_window_size()['height']
return(x,y)
l = get_size()
# Take half of the width
x1 = int(l[0]*0.5)
# Slide from below
y1 = int(l[1]*0.8)
# Stop at a position above
y2 = int(l[1]*0.25)
action.long_press(x=x1 ,y=y1,duration=2000).move_to(x=x1,y=y2).release().perform()
That's what we're going to talk about today , This article briefly introduces appium Use , For learning and communication only