class case_mypushlish_return(unittest.TestCase):

    def setUp(self):
        public.setUp.setUp(self)

    def tearDown(self):
        self.dr.quit()

    @user1imer
    def test_mypushlish_return(self):
        self.assertIsNone(self.dr.find_element_by_name(taskname_2),'存在taskname_2,Fail')

if __name__ == '__main__':
    suite = unittest.TestLoader().loadTestsFromTestCase(case_mypushlish_return)
    unittest.TextTestRunner(verbosity=2).run(suite)

报错:

Traceback (most recent call last):
File "D:\AutoWork\自动化测试项目\Milan_H5_Auto\public\fn_timer.py", line 16, in function_timer
result = function(*args, **kwargs)
File "D:/AutoWork/自动化测试项目/Milan_H5_Auto/test_case/case_mypushlish_return.py", line 134, in test_mypushlish_return
self.assertIsNone(self.dr.find_element_by_name(taskname_2),'存在 taskname_2,Fail')
File "D:\AutoWork\Python\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 381, in find_element_by_name
return self.find_element(by=By.NAME, value=name)
File "D:\AutoWork\Python\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 787, in find_element
'value': value})['value']
File "D:\AutoWork\Python\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 252, in execute
self.error_handler.check_response(response)
File "D:\AutoWork\Python\lib\site-packages\appium\webdriver\errorhandler.py", line 29, in check_response
raise wde
File "D:\AutoWork\Python\lib\site-packages\appium\webdriver\errorhandler.py", line 24, in check_response
super(MobileErrorHandler, self).check_response(response)
File "D:\AutoWork\Python\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 194, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: An element could not be located on the page using the given search parameters.


有人知道 assertIsNone 的正确用法吗?


↙↙↙阅读原文可查看相关链接,并与作者交流