移动测试基础 po 模式 +pytest+appium 做移动自动化时报错

sanmejie · February 02, 2019 · 1356 hits

================================================================================================================================================ test session starts ==================================================================================================================================================
platform win32 -- Python 3.7.1, pytest-4.2.0, py-1.7.0, pluggy-0.8.0
rootdir: E:\tongzhuopy\hello\web_tongzh_tv, inifile: pytest.ini
plugins: remotedata-0.3.1, openfiles-0.3.1, doctestplus-0.2.0, arraydiff-0.3, allure-pytest-2.5.5
collected 8 items

Scripts\test_login.py EEEEEEEE

======================================================================================================================================================== ERRORS ========================================================================================================================================================
______________________________________________________________________________________________ ERROR at setup of Test_Login.test_login_page[test_login_001-18735704321-12345678p-\u6210\u529f-\u767b\u5f55\u6210\u529f-1] ______________________________________________________________________________________________

self =

def setup_class(self):
# 实例化登陆对象
self.LP_obj = Login_Page(get_driver())
# 点击个人中心
sleep(5)

self.LP_obj.click_sy_login_btn()

Scripts\test_login.py:24:


Page\login_page.py:10: in click_sy_login_btn
self.click_element(Page.sy_login_btn_id)
Base\Base.py:38: in click_element
self.search_element(loc).click()
Base\Base.py:21: in search_element
return WebDriverWait(self.driver, timeout, poll_frequency).until(lambda x: x.find_element(*loc))
C:\Users\Administrator\AppData\Roaming\Python\Python37\site-packages\selenium\webdriver\support\wait.py:71: in until
value = method(self._driver)


x = None

return WebDriverWait(self.driver, timeout, poll_frequency).until(lambda x: x.find_element(*loc))
E AttributeError: 'NoneType' object has no attribute 'find_element'

Base\Base.py:21: AttributeError
_____________________________________________________________________________________________ ERROR at setup of Test_Login.test_login_page[test_login_002- 15652292326-a123456789-\u6210\u529f-\u767b\u5f55\u6210\u529f-1] _____________________________________________________________________________________________

项目目录结构:
E:.
│ pytest.ini
init.py

├─Base
│ │ Base.py
│ │ init_driver.py
│ │ read_data.py
│ │ init.py
│ └─

├─Data
│ data.yml
init.py

├─Page
│ │ login_page.py
│ │ logout_page.py
│ │ init.py
│ └─

├─report
└─Scripts
│ │ test_login.py
│ │ init.py
│ └─
报错信息指向\selenium\webdriver
Base\Base.py:21: in search_element
return WebDriverWait(self.driver, timeout, poll_frequency).until(lambda x: x.find_element(*loc))
C:\Users\Administrator\AppData\Roaming\Python\Python37\site-packages\selenium\webdriver\support\wait.py:71: in until
value = method(self._driver)
详细代码如下:

def until(self, method, message=''):
"""Calls the method provided with the driver as an argument until the \
return value is not False."""

screen = None
stacktrace = None

end_time = time.time() + self._timeout
while True:
try:
value = method(self._driver)
if value:
return value
except self._ignored_exceptions as exc:
screen = getattr(exc, 'screen', None)
stacktrace = getattr(exc, 'stacktrace', None)
time.sleep(self._poll)
if time.time() > end_time:
break
raise TimeoutException(message, screen, stacktrace)

根据报信息“return WebDriverWait(self.driver, timeout, poll_frequency).until(lambda x: x.find_element(*loc))
E AttributeError: 'NoneType' object has no attribute 'find_element'”尝试写demo发现没问题。

WebDriverWait(driver,20,1.0).until(lambda x: x.find_element(By.ID,"com.deskmate.tv:id/btn_hint_yes")).click()

依赖包

共收到 0 条回复 时间 点赞
1Floor has been deleted
需要 Sign In 后方可回复, 如果你还没有账号请点击这里 Sign Up