The site updated articles with a delay, if you want to see about python + appium articles, please go to testhome attention I oh testerhome.com/topics/2780…
From APP Android end automation test beginner’s notes, write wrong place we a lot of advice oh.
Many current APP login require binding mobile phone number, but when we need plenty of simulation of the new user registration log on, unable to provide a large number of cell phone number to test, so you can have the server gives a clear account of the interface, when writing the automation scripts can call this interface, assure to be able to use an account for new user registration login many times.
One, environment installation
CMD enter: PIP install requests
Two, on the chestnut:
Take Douban Search trisomy as an example: www.douban.com/search?q= Trisomy
def server(self, phone) :
clear_user_url = "[https://www.douban.com/search?](https://www.douban.com/search?q=%E4%B8%89%E4%BD%93)"
# Parameters passed in
request_data = ({"q": "Three body"})
# use get request
ret = requests.get(clear_user_url, request_data)
200: The server has successfully processed the request. Typically, this means that the server has provided the requested web page.
if ret.status_code == 200:
text = json.loads(ret.text)
print(text)
Copy the code
3. It is used in Python + Appium automatic test, encapsulate the method, and the encapsulated method can be directly called
class InvokeServer:
def __init__(self, search_context) :
self.search_context= search_context
def server(self, search_context) :
clear_user_url = "[https://www.douban.com/search?](https://www.douban.com/search?q=%E4%B8%89%E4%BD%93)"
request_data = ({"q": search_context})
# use get request
ret = requests.get(clear_user_url, request_data)
200: The server has successfully processed the request. Typically, this means that the server has provided the requested web page.
if ret.status_code == 200:
text = json.loads(ret.text)
print(text)
Copy the code
The automated test procedure calls the above methods
class TestInvokeServer:
driver: webdriver = None
def __init__(self) :
self.invoke_server = InvokeServer(driver)
def test_01(self) :
self.invoke_server.server("Three body")
Copy the code