晚上 8:00 开始
adb logcat | grep Displayed
08-20 20:14:19.034 439 473 I ActivityManager: Displayed com.mumu.launcher/.Launcher: +2s236ms
08-20 20:16:00.097 439 473 I ActivityManager: Displayed com.xueqiu.android/.view.WelcomeActivityAlias: +1s927ms
08-20 20:16:07.040 439 473 I ActivityManager: Displayed com.xueqiu.android/.common.MainActivity: +2s142ms
{
"platformName": "android",
"deviceName": "hogwarts",
"appPackage": "com.xueqiu.android",
"appActivity": ".view.WelcomeActivityAlias",
"autoGrantPermissions": "true"
}
# This sample code uses the Appium python client
# pip install Appium-Python-Client
# Then you can paste this into a file and simply run with Python
from appium import webdriver
caps = {}
caps["platformName"] = "android"
caps["deviceName"] = "hogwarts"
caps["appPackage"] = "com.xueqiu.android"
caps["appActivity"] = ".view.WelcomeActivityAlias"
caps["autoGrantPermissions"] = "true"
driver = webdriver.Remote("http://localhost:4723/wd/hub", caps)
el1 = driver.find_element_by_id("com.xueqiu.android:id/tv_search")
el1.click()
el2 = driver.find_element_by_id("com.xueqiu.android:id/search_input_text")
el2.send_keys("alibaba")
el3 = driver.find_element_by_xpath("/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.RelativeLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.support.v7.widget.RecyclerView/android.widget.RelativeLayout[1]/android.widget.TextView")
el3.click()
driver.quit()
# This sample code uses the Appium python client
# pip install Appium-Python-Client
# Then you can paste this into a file and simply run with Python
from appium import webdriver
import pytest
import unittest
class TestPO(unittest.TestCase):
def setUp(self):
caps = {}
caps["platformName"] = "android"
caps["deviceName"] = "hogwarts"
caps["appPackage"] = "com.xueqiu.android"
caps["appActivity"] = ".view.WelcomeActivityAlias"
caps["autoGrantPermissions"] = "true"
self.driver = webdriver.Remote("http://localhost:4723/wd/hub", caps)
self.driver.implicitly_wait(5)
def test_search(self):
el1 = self.driver.find_element_by_id("com.xueqiu.android:id/tv_search")
el1.click()
el2 = self.driver.find_element_by_id("com.xueqiu.android:id/search_input_text")
el2.send_keys("alibaba")
el3 = self.driver.find_element_by_xpath("/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.RelativeLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.support.v7.widget.RecyclerView/android.widget.RelativeLayout[1]/android.widget.TextView")
el3.click()
def tearDown(self) -> None:
self.driver.quit()
# This sample code uses the Appium python client
# pip install Appium-Python-Client
# Then you can paste this into a file and simply run with Python
from appium import webdriver
import pytest
class TestPO:
def setup(self):
caps = {}
caps["platformName"] = "android"
caps["deviceName"] = "hogwarts"
caps["appPackage"] = "com.xueqiu.android"
caps["appActivity"] = ".view.WelcomeActivityAlias"
caps["autoGrantPermissions"] = "true"
self.driver = webdriver.Remote("http://localhost:4723/wd/hub", caps)
self.driver.implicitly_wait(5)
def test_search(self):
el1 = self.driver.find_element_by_id("com.xueqiu.android:id/tv_search")
el1.click()
el2 = self.driver.find_element_by_id("com.xueqiu.android:id/search_input_text")
el2.send_keys("alibaba")
el3 = self.driver.find_element_by_xpath("/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.RelativeLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.support.v7.widget.RecyclerView/android.widget.RelativeLayout[1]/android.widget.TextView")
el3.click()
def teardown(self) -> None:
self.driver.quit()
import pytest
from appium import webdriver
from page.xueqiu_page import XueqiuPage
class TestSearch:
def setup(self):
self.xueqiu=XueqiuPage()
@pytest.mark.parametrize("keyword", [
"alibaba",
"xiaomi",
"pingan",
"pdd",
"facebook"
])
def test_search(self, keyword):
assert self.xueqiu.search()\
.search(keyword)\
.get_price() == 100
def test_search_xiaomi(self):
assert self.xueqiu.search().search("xiaomi").get_price() == 100