执行结果显示:Process finished with exit code 0
现象:
(1)运行后,appium server 未看到有运行的日志
(2)打断点走到 def setup(self):后就结束了
(3)但在终端用 py.test 运行这个文件对应真机能正常启动,appium server 也能看到运行日志
(4)写了一个简单的 print("helloword") 能正常打印出来
试了下百度上的修改解释器等等都无效,前来求助各位大神
代码如下:
from appium import webdriver
from selenium.webdriver.support.wait import WebDriverWait
class TestDemo:
def setup(self):
desired_cap = {
"platformName" : "android",
"deviceName" : "xiaomi",
"appPackage" : "com.xueqiu.android",
"appActivity" : "view.WelcomeActivityAlias",
"autoGrantPermissions" : "true"}
self.driver = webdriver.Remote("http://localhost:4723/wd/hub", desired_cap)
self.driver.implicitly_wait(20)
def loaded(driver):
if len(self.driver.find_elements_by_id("image_cancel")) >=1:
self.driver.find_element_by_id("image_cancel").click()
return True
else:
return False
try:
WebDriverWait(self.driver,15).until(loaded)
except:
print("no update")
def test_xpath(self):
self.driver.find_element_by_xpath("//*[@text='同意' and contains(@resource-id,'com.xueqiu.android:id/tv_agree')]").click()
def demo(self):
el1 = self.driver.find_element_by_id("com.xueqiu.android:id/home_search")
el1.click()
el2 = self.driver.find_element_by_id("com.xueqiu.android:id/search_input_text")
el2.send_keys("aaa")
def teardown(self):
self.driver.quit()