问题描述:
- 环境:macOS、pycharm 2018.1(CE)、appium1.21.0
- 移动端型号:小米MI 5
- 移动端系统:android6.0
- 问题复述:运行代码后显示Process finished with exit code 0,但实际appium server没有运行日志,且模拟器没有运行相应app
相关log文件
无
相关代码(包括log文件,都要使用markdown代码格式,)
# 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
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()
现象:
(1)运行后,appium server 未看到有运行的日志
(2)打断点走到 def setup(self):后就结束了
(3)在终端用 py.test 运行这个文件对应真机能正常启动,appium server 也能看到运行日志。但在同意了隐私协议后过了2秒也闪退了,未进入到搜索aaa,报错是找不到元素。应该是代码有问题,也需要大神帮忙看下代码有什么问题?
(4)写了一个简单的 print(“helloworld”) 能正常打印出来
试了下百度上的修改解释器等等都无效,前来求助各位大神