Guest User

Untitled

a guest
Jun 22nd, 2018
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.07 KB | None | 0 0
  1. Testing started at 18:59 ...
  2. C:\dev\python_training\env\Scripts\python.exe "C:\Program Files\JetBrains\PyCharm Community Edition 2018.1.3\helpers\pycharm\_jb_pytest_runner.py" --path C:/dev/python_training/test/test_del_contact.py
  3. Launching py.test with arguments C:/dev/python_training/test/test_del_contact.py in C:\dev\python_training\test
  4.  
  5. ============================= test session starts =============================
  6. platform win32 -- Python 3.6.5, pytest-3.6.0, py-1.5.3, pluggy-0.6.0
  7. rootdir: C:\dev\python_training\test, inifile:collected 1 item
  8.  
  9. test_del_contact.py F
  10. test_del_contact.py:3 (test_delete_first_contact)
  11. app = <fixture.application.Application object at 0x0449BE30>
  12.  
  13. def test_delete_first_contact(app):
  14. app.open_home_page()
  15. if app.contact.count() == 0:
  16. app.contact.create_contact(Contact(first_name="Alex"))
  17. old_contacts = app.contact.get_contact_list()
  18. > app.contact.delete_first_contact()
  19.  
  20. test_del_contact.py:9:
  21. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  22. ..\fixture\contact.py:44: in delete_first_contact
  23. self.return_to_home_page()
  24. ..\fixture\contact.py:61: in return_to_home_page
  25. wd.find_element_by_link_text("home page").click()
  26. ..\env\lib\site-packages\selenium\webdriver\remote\webdriver.py:421: in find_element_by_link_text
  27. return self.find_element(by=By.LINK_TEXT, value=link_text)
  28. ..\env\lib\site-packages\selenium\webdriver\remote\webdriver.py:957: in find_element
  29. 'value': value})['value']
  30. ..\env\lib\site-packages\selenium\webdriver\remote\webdriver.py:314: in execute
  31. self.error_handler.check_response(response)
  32. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  33.  
  34. self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x04471AF0>
  35. response = {'status': 500, 'value': '{"name":"findElement","sessionId":"6d6e09dd-e42b-4707-9a25-cf91196931d9","status":7,"value":...p0uq5fd45/extensions/fxdriver@googlecode.com/components/command-processor.js","lineNumber":13335,"columnNumber":5}]}}'}
  36.  
  37. def check_response(self, response):
  38. """
  39. Checks that a JSON response from the WebDriver does not have an error.
  40.  
  41. :Args:
  42. - response - The JSON response from the WebDriver server as a dictionary
  43. object.
  44.  
  45. :Raises: If the response contains an error message.
  46. """
  47. status = response.get('status', None)
  48. if status is None or status == ErrorCode.SUCCESS:
  49. return
  50. value = None
  51. message = response.get("message", "")
  52. screen = response.get("screen", "")
  53. stacktrace = None
  54. if isinstance(status, int):
  55. value_json = response.get('value', None)
  56. if value_json and isinstance(value_json, basestring):
  57. import json
  58. try:
  59. value = json.loads(value_json)
  60. if len(value.keys()) == 1:
  61. value = value['value']
  62. status = value.get('error', None)
  63. if status is None:
  64. status = value["status"]
  65. message = value["value"]
  66. if not isinstance(message, basestring):
  67. value = message
  68. message = message.get('message')
  69. else:
  70. message = value.get('message', None)
  71. except ValueError:
  72. pass
  73.  
  74. exception_class = ErrorInResponseException
  75. if status in ErrorCode.NO_SUCH_ELEMENT:
  76. exception_class = NoSuchElementException
  77. elif status in ErrorCode.NO_SUCH_FRAME:
  78. exception_class = NoSuchFrameException
  79. elif status in ErrorCode.NO_SUCH_WINDOW:
  80. exception_class = NoSuchWindowException
  81. elif status in ErrorCode.STALE_ELEMENT_REFERENCE:
  82. exception_class = StaleElementReferenceException
  83. elif status in ErrorCode.ELEMENT_NOT_VISIBLE:
  84. exception_class = ElementNotVisibleException
  85. elif status in ErrorCode.INVALID_ELEMENT_STATE:
  86. exception_class = InvalidElementStateException
  87. elif status in ErrorCode.INVALID_SELECTOR \
  88. or status in ErrorCode.INVALID_XPATH_SELECTOR \
  89. or status in ErrorCode.INVALID_XPATH_SELECTOR_RETURN_TYPER:
  90. exception_class = InvalidSelectorException
  91. elif status in ErrorCode.ELEMENT_IS_NOT_SELECTABLE:
  92. exception_class = ElementNotSelectableException
  93. elif status in ErrorCode.ELEMENT_NOT_INTERACTABLE:
  94. exception_class = ElementNotInteractableException
  95. elif status in ErrorCode.INVALID_COOKIE_DOMAIN:
  96. exception_class = InvalidCookieDomainException
  97. elif status in ErrorCode.UNABLE_TO_SET_COOKIE:
  98. exception_class = UnableToSetCookieException
  99. elif status in ErrorCode.TIMEOUT:
  100. exception_class = TimeoutException
  101. elif status in ErrorCode.SCRIPT_TIMEOUT:
  102. exception_class = TimeoutException
  103. elif status in ErrorCode.UNKNOWN_ERROR:
  104. exception_class = WebDriverException
  105. elif status in ErrorCode.UNEXPECTED_ALERT_OPEN:
  106. exception_class = UnexpectedAlertPresentException
  107. elif status in ErrorCode.NO_ALERT_OPEN:
  108. exception_class = NoAlertPresentException
  109. elif status in ErrorCode.IME_NOT_AVAILABLE:
  110. exception_class = ImeNotAvailableException
  111. elif status in ErrorCode.IME_ENGINE_ACTIVATION_FAILED:
  112. exception_class = ImeActivationFailedException
  113. elif status in ErrorCode.MOVE_TARGET_OUT_OF_BOUNDS:
  114. exception_class = MoveTargetOutOfBoundsException
  115. elif status in ErrorCode.JAVASCRIPT_ERROR:
  116. exception_class = JavascriptException
  117. elif status in ErrorCode.SESSION_NOT_CREATED:
  118. exception_class = SessionNotCreatedException
  119. elif status in ErrorCode.INVALID_ARGUMENT:
  120. exception_class = InvalidArgumentException
  121. elif status in ErrorCode.NO_SUCH_COOKIE:
  122. exception_class = NoSuchCookieException
  123. elif status in ErrorCode.UNABLE_TO_CAPTURE_SCREEN:
  124. exception_class = ScreenshotException
  125. elif status in ErrorCode.ELEMENT_CLICK_INTERCEPTED:
  126. exception_class = ElementClickInterceptedException
  127. elif status in ErrorCode.INSECURE_CERTIFICATE:
  128. exception_class = InsecureCertificateException
  129. elif status in ErrorCode.INVALID_COORDINATES:
  130. exception_class = InvalidCoordinatesException
  131. elif status in ErrorCode.INVALID_SESSION_ID:
  132. exception_class = InvalidSessionIdException
  133. elif status in ErrorCode.UNKNOWN_METHOD:
  134. exception_class = UnknownMethodException
  135. else:
  136. exception_class = WebDriverException
  137. if value == '' or value is None:
  138. value = response['value']
  139. if isinstance(value, basestring):
  140. if exception_class == ErrorInResponseException:
  141. raise exception_class(response, value)
  142. raise exception_class(value)
  143. if message == "" and 'message' in value:
  144. message = value['message']
  145.  
  146. screen = None
  147. if 'screen' in value:
  148. screen = value['screen']
  149.  
  150. stacktrace = None
  151. if 'stackTrace' in value and value['stackTrace']:
  152. stacktrace = []
  153. try:
  154. for frame in value['stackTrace']:
  155. line = self._value_or_default(frame, 'lineNumber', '')
  156. file = self._value_or_default(frame, 'fileName', '<anonymous>')
  157. if line:
  158. file = "%s:%s" % (file, line)
  159. meth = self._value_or_default(frame, 'methodName', '<anonymous>')
  160. if 'className' in frame:
  161. meth = "%s.%s" % (frame['className'], meth)
  162. msg = " at %s (%s)"
  163. msg = msg % (meth, file)
  164. stacktrace.append(msg)
  165. except TypeError:
  166. pass
  167. if exception_class == ErrorInResponseException:
  168. raise exception_class(response, message)
  169. elif exception_class == UnexpectedAlertPresentException:
  170. alert_text = None
  171. if 'data' in value:
  172. alert_text = value['data'].get('text')
  173. elif 'alert' in value:
  174. alert_text = value['alert'].get('text')
  175. raise exception_class(message, screen, stacktrace, alert_text)
  176. > raise exception_class(message, screen, stacktrace)
  177. E selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: {"method":"link text","selector":"home page"}
  178. E Stacktrace:
  179. E at FirefoxDriver.prototype.findElementInternal_ (file:///C:/Users/USER/AppData/Local/Temp/tmp0uq5fd45/extensions/fxdriver@googlecode.com/components/driver-component.js:11878)
  180. E at FirefoxDriver.prototype.findElement (file:///C:/Users/USER/AppData/Local/Temp/tmp0uq5fd45/extensions/fxdriver@googlecode.com/components/driver-component.js:11887)
  181. E at DelayedCommand.prototype.executeInternal_/k (file:///C:/Users/USER/AppData/Local/Temp/tmp0uq5fd45/extensions/fxdriver@googlecode.com/components/command-processor.js:13388)
  182. E at DelayedCommand.prototype.executeInternal_ (file:///C:/Users/USER/AppData/Local/Temp/tmp0uq5fd45/extensions/fxdriver@googlecode.com/components/command-processor.js:13393)
  183. E at DelayedCommand.prototype.execute/< (file:///C:/Users/USER/AppData/Local/Temp/tmp0uq5fd45/extensions/fxdriver@googlecode.com/components/command-processor.js:13335)
  184.  
  185. ..\env\lib\site-packages\selenium\webdriver\remote\errorhandler.py:242: NoSuchElementException
  186. [100%]
  187.  
  188. ================================== FAILURES ===================================
  189. __________________________ test_delete_first_contact __________________________
  190.  
  191. app = <fixture.application.Application object at 0x0449BE30>
  192.  
  193. def test_delete_first_contact(app):
  194. app.open_home_page()
  195. if app.contact.count() == 0:
  196. app.contact.create_contact(Contact(first_name="Alex"))
  197. old_contacts = app.contact.get_contact_list()
  198. > app.contact.delete_first_contact()
  199.  
  200. test_del_contact.py:9:
  201. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  202. ..\fixture\contact.py:44: in delete_first_contact
  203. self.return_to_home_page()
  204. ..\fixture\contact.py:61: in return_to_home_page
  205. wd.find_element_by_link_text("home page").click()
  206. ..\env\lib\site-packages\selenium\webdriver\remote\webdriver.py:421: in find_element_by_link_text
  207. return self.find_element(by=By.LINK_TEXT, value=link_text)
  208. ..\env\lib\site-packages\selenium\webdriver\remote\webdriver.py:957: in find_element
  209. 'value': value})['value']
  210. ..\env\lib\site-packages\selenium\webdriver\remote\webdriver.py:314: in execute
  211. self.error_handler.check_response(response)
  212. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  213.  
  214. self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x04471AF0>
  215. response = {'status': 500, 'value': '{"name":"findElement","sessionId":"6d6e09dd-e42b-4707-9a25-cf91196931d9","status":7,"value":...p0uq5fd45/extensions/fxdriver@googlecode.com/components/command-processor.js","lineNumber":13335,"columnNumber":5}]}}'}
  216.  
  217. def check_response(self, response):
  218. """
  219. Checks that a JSON response from the WebDriver does not have an error.
  220.  
  221. :Args:
  222. - response - The JSON response from the WebDriver server as a dictionary
  223. object.
  224.  
  225. :Raises: If the response contains an error message.
  226. """
  227. status = response.get('status', None)
  228. if status is None or status == ErrorCode.SUCCESS:
  229. return
  230. value = None
  231. message = response.get("message", "")
  232. screen = response.get("screen", "")
  233. stacktrace = None
  234. if isinstance(status, int):
  235. value_json = response.get('value', None)
  236. if value_json and isinstance(value_json, basestring):
  237. import json
  238. try:
  239. value = json.loads(value_json)
  240. if len(value.keys()) == 1:
  241. value = value['value']
  242. status = value.get('error', None)
  243. if status is None:
  244. status = value["status"]
  245. message = value["value"]
  246. if not isinstance(message, basestring):
  247. value = message
  248. message = message.get('message')
  249. else:
  250. message = value.get('message', None)
  251. except ValueError:
  252. pass
  253.  
  254. exception_class = ErrorInResponseException
  255. if status in ErrorCode.NO_SUCH_ELEMENT:
  256. exception_class = NoSuchElementException
  257. elif status in ErrorCode.NO_SUCH_FRAME:
  258. exception_class = NoSuchFrameException
  259. elif status in ErrorCode.NO_SUCH_WINDOW:
  260. exception_class = NoSuchWindowException
  261. elif status in ErrorCode.STALE_ELEMENT_REFERENCE:
  262. exception_class = StaleElementReferenceException
  263. elif status in ErrorCode.ELEMENT_NOT_VISIBLE:
  264. exception_class = ElementNotVisibleException
  265. elif status in ErrorCode.INVALID_ELEMENT_STATE:
  266. exception_class = InvalidElementStateException
  267. elif status in ErrorCode.INVALID_SELECTOR \
  268. or status in ErrorCode.INVALID_XPATH_SELECTOR \
  269. or status in ErrorCode.INVALID_XPATH_SELECTOR_RETURN_TYPER:
  270. exception_class = InvalidSelectorException
  271. elif status in ErrorCode.ELEMENT_IS_NOT_SELECTABLE:
  272. exception_class = ElementNotSelectableException
  273. elif status in ErrorCode.ELEMENT_NOT_INTERACTABLE:
  274. exception_class = ElementNotInteractableException
  275. elif status in ErrorCode.INVALID_COOKIE_DOMAIN:
  276. exception_class = InvalidCookieDomainException
  277. elif status in ErrorCode.UNABLE_TO_SET_COOKIE:
  278. exception_class = UnableToSetCookieException
  279. elif status in ErrorCode.TIMEOUT:
  280. exception_class = TimeoutException
  281. elif status in ErrorCode.SCRIPT_TIMEOUT:
  282. exception_class = TimeoutException
  283. elif status in ErrorCode.UNKNOWN_ERROR:
  284. exception_class = WebDriverException
  285. elif status in ErrorCode.UNEXPECTED_ALERT_OPEN:
  286. exception_class = UnexpectedAlertPresentException
  287. elif status in ErrorCode.NO_ALERT_OPEN:
  288. exception_class = NoAlertPresentException
  289. elif status in ErrorCode.IME_NOT_AVAILABLE:
  290. exception_class = ImeNotAvailableException
  291. elif status in ErrorCode.IME_ENGINE_ACTIVATION_FAILED:
  292. exception_class = ImeActivationFailedException
  293. elif status in ErrorCode.MOVE_TARGET_OUT_OF_BOUNDS:
  294. exception_class = MoveTargetOutOfBoundsException
  295. elif status in ErrorCode.JAVASCRIPT_ERROR:
  296. exception_class = JavascriptException
  297. elif status in ErrorCode.SESSION_NOT_CREATED:
  298. exception_class = SessionNotCreatedException
  299. elif status in ErrorCode.INVALID_ARGUMENT:
  300. exception_class = InvalidArgumentException
  301. elif status in ErrorCode.NO_SUCH_COOKIE:
  302. exception_class = NoSuchCookieException
  303. elif status in ErrorCode.UNABLE_TO_CAPTURE_SCREEN:
  304. exception_class = ScreenshotException
  305. elif status in ErrorCode.ELEMENT_CLICK_INTERCEPTED:
  306. exception_class = ElementClickInterceptedException
  307. elif status in ErrorCode.INSECURE_CERTIFICATE:
  308. exception_class = InsecureCertificateException
  309. elif status in ErrorCode.INVALID_COORDINATES:
  310. exception_class = InvalidCoordinatesException
  311. elif status in ErrorCode.INVALID_SESSION_ID:
  312. exception_class = InvalidSessionIdException
  313. elif status in ErrorCode.UNKNOWN_METHOD:
  314. exception_class = UnknownMethodException
  315. else:
  316. exception_class = WebDriverException
  317. if value == '' or value is None:
  318. value = response['value']
  319. if isinstance(value, basestring):
  320. if exception_class == ErrorInResponseException:
  321. raise exception_class(response, value)
  322. raise exception_class(value)
  323. if message == "" and 'message' in value:
  324. message = value['message']
  325.  
  326. screen = None
  327. if 'screen' in value:
  328. screen = value['screen']
  329.  
  330. stacktrace = None
  331. if 'stackTrace' in value and value['stackTrace']:
  332. stacktrace = []
  333. try:
  334. for frame in value['stackTrace']:
  335. line = self._value_or_default(frame, 'lineNumber', '')
  336. file = self._value_or_default(frame, 'fileName', '<anonymous>')
  337. if line:
  338. file = "%s:%s" % (file, line)
  339. meth = self._value_or_default(frame, 'methodName', '<anonymous>')
  340. if 'className' in frame:
  341. meth = "%s.%s" % (frame['className'], meth)
  342. msg = " at %s (%s)"
  343. msg = msg % (meth, file)
  344. stacktrace.append(msg)
  345. except TypeError:
  346. pass
  347. if exception_class == ErrorInResponseException:
  348. raise exception_class(response, message)
  349. elif exception_class == UnexpectedAlertPresentException:
  350. alert_text = None
  351. if 'data' in value:
  352. alert_text = value['data'].get('text')
  353. elif 'alert' in value:
  354. alert_text = value['alert'].get('text')
  355. raise exception_class(message, screen, stacktrace, alert_text)
  356. > raise exception_class(message, screen, stacktrace)
  357. E selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: {"method":"link text","selector":"home page"}
  358. E Stacktrace:
  359. E at FirefoxDriver.prototype.findElementInternal_ (file:///C:/Users/USER/AppData/Local/Temp/tmp0uq5fd45/extensions/fxdriver@googlecode.com/components/driver-component.js:11878)
  360. E at FirefoxDriver.prototype.findElement (file:///C:/Users/USER/AppData/Local/Temp/tmp0uq5fd45/extensions/fxdriver@googlecode.com/components/driver-component.js:11887)
  361. E at DelayedCommand.prototype.executeInternal_/k (file:///C:/Users/USER/AppData/Local/Temp/tmp0uq5fd45/extensions/fxdriver@googlecode.com/components/command-processor.js:13388)
  362. E at DelayedCommand.prototype.executeInternal_ (file:///C:/Users/USER/AppData/Local/Temp/tmp0uq5fd45/extensions/fxdriver@googlecode.com/components/command-processor.js:13393)
  363. E at DelayedCommand.prototype.execute/< (file:///C:/Users/USER/AppData/Local/Temp/tmp0uq5fd45/extensions/fxdriver@googlecode.com/components/command-processor.js:13335)
  364.  
  365. ..\env\lib\site-packages\selenium\webdriver\remote\errorhandler.py:242: NoSuchElementException
  366. ========================== 1 failed in 8.39 seconds ===========================
  367. Process finished with exit code 0
Add Comment
Please, Sign In to add comment