Guest User

Untitled

a guest
May 19th, 2018
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 34.86 KB | None | 0 0
  1. Testing started at 6:27 PM ...
  2. /Users/evgeny.artsiomenko/PycharmProjects/task_1_1/env1_1/bin/python "/Applications/PyCharm CE 2.app/Contents/helpers/pycharm/_jb_pytest_runner.py" --path /Users/evgeny.artsiomenko/PycharmProjects/task1_1/test/test_add_contact.py
  3. Launching py.test with arguments /Users/evgeny.artsiomenko/PycharmProjects/task1_1/test/test_add_contact.py in /Users/evgeny.artsiomenko/PycharmProjects/task1_1
  4.  
  5. ============================= test session starts ==============================
  6. platform darwin -- Python 3.6.4, pytest-3.5.0, py-1.5.3, pluggy-0.6.0
  7. rootdir: /Users/evgeny.artsiomenko/PycharmProjects/task1_1, inifile:collected 2 items
  8.  
  9. test/test_add_contact.py E
  10. test setup failed
  11. request = <SubRequest 'app' for <Function 'test_add_contact[None:lastname <S4? zj8;firstnamepkL23m]'>>
  12.  
  13. @pytest.fixture
  14. def app(request):
  15. global fixture
  16. global target
  17. browser = request.config.getoption("--browser")
  18. if target is None:
  19. with open(request.config.getoption("--target")) as config_file:
  20. target = json.load(config_file)
  21. if fixture is None or not fixture.is_valid():
  22. fixture = Application(browser=browser,base_url=target["baseUrl"])
  23. > fixture.session.ensure_login(username=target["username"], password=target["password"])
  24.  
  25. conftest.py:17:
  26. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  27. fixture/session.py:47: in ensure_login
  28. self.login(username,password)
  29. fixture/session.py:11: in login
  30. wd.find_element_by_name("user").click()
  31. ../task_1_1/env1_1/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py:487: in find_element_by_name
  32. return self.find_element(by=By.NAME, value=name)
  33. ../task_1_1/env1_1/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py:955: in find_element
  34. 'value': value})['value']
  35. ../task_1_1/env1_1/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py:312: in execute
  36. self.error_handler.check_response(response)
  37. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  38.  
  39. self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x10cfc8b00>
  40. response = {'status': 404, 'value': '{"value":{"error":"no such element","message":"Unable to locate element: [name=\\"user\\"]",...ror@chrome://marionette/content/error.js:434:5\\nelement.find/</<@chrome://marionette/content/element.js:341:16\\n"}}'}
  41.  
  42. def check_response(self, response):
  43. """
  44. Checks that a JSON response from the WebDriver does not have an error.
  45.  
  46. :Args:
  47. - response - The JSON response from the WebDriver server as a dictionary
  48. object.
  49.  
  50. :Raises: If the response contains an error message.
  51. """
  52. status = response.get('status', None)
  53. if status is None or status == ErrorCode.SUCCESS:
  54. return
  55. value = None
  56. message = response.get("message", "")
  57. screen = response.get("screen", "")
  58. stacktrace = None
  59. if isinstance(status, int):
  60. value_json = response.get('value', None)
  61. if value_json and isinstance(value_json, basestring):
  62. import json
  63. try:
  64. value = json.loads(value_json)
  65. if len(value.keys()) == 1:
  66. value = value['value']
  67. status = value.get('error', None)
  68. if status is None:
  69. status = value["status"]
  70. message = value["value"]
  71. if not isinstance(message, basestring):
  72. value = message
  73. message = message.get('message')
  74. else:
  75. message = value.get('message', None)
  76. except ValueError:
  77. pass
  78.  
  79. exception_class = ErrorInResponseException
  80. if status in ErrorCode.NO_SUCH_ELEMENT:
  81. exception_class = NoSuchElementException
  82. elif status in ErrorCode.NO_SUCH_FRAME:
  83. exception_class = NoSuchFrameException
  84. elif status in ErrorCode.NO_SUCH_WINDOW:
  85. exception_class = NoSuchWindowException
  86. elif status in ErrorCode.STALE_ELEMENT_REFERENCE:
  87. exception_class = StaleElementReferenceException
  88. elif status in ErrorCode.ELEMENT_NOT_VISIBLE:
  89. exception_class = ElementNotVisibleException
  90. elif status in ErrorCode.INVALID_ELEMENT_STATE:
  91. exception_class = InvalidElementStateException
  92. elif status in ErrorCode.INVALID_SELECTOR \
  93. or status in ErrorCode.INVALID_XPATH_SELECTOR \
  94. or status in ErrorCode.INVALID_XPATH_SELECTOR_RETURN_TYPER:
  95. exception_class = InvalidSelectorException
  96. elif status in ErrorCode.ELEMENT_IS_NOT_SELECTABLE:
  97. exception_class = ElementNotSelectableException
  98. elif status in ErrorCode.ELEMENT_NOT_INTERACTABLE:
  99. exception_class = ElementNotInteractableException
  100. elif status in ErrorCode.INVALID_COOKIE_DOMAIN:
  101. exception_class = InvalidCookieDomainException
  102. elif status in ErrorCode.UNABLE_TO_SET_COOKIE:
  103. exception_class = UnableToSetCookieException
  104. elif status in ErrorCode.TIMEOUT:
  105. exception_class = TimeoutException
  106. elif status in ErrorCode.SCRIPT_TIMEOUT:
  107. exception_class = TimeoutException
  108. elif status in ErrorCode.UNKNOWN_ERROR:
  109. exception_class = WebDriverException
  110. elif status in ErrorCode.UNEXPECTED_ALERT_OPEN:
  111. exception_class = UnexpectedAlertPresentException
  112. elif status in ErrorCode.NO_ALERT_OPEN:
  113. exception_class = NoAlertPresentException
  114. elif status in ErrorCode.IME_NOT_AVAILABLE:
  115. exception_class = ImeNotAvailableException
  116. elif status in ErrorCode.IME_ENGINE_ACTIVATION_FAILED:
  117. exception_class = ImeActivationFailedException
  118. elif status in ErrorCode.MOVE_TARGET_OUT_OF_BOUNDS:
  119. exception_class = MoveTargetOutOfBoundsException
  120. elif status in ErrorCode.JAVASCRIPT_ERROR:
  121. exception_class = JavascriptException
  122. elif status in ErrorCode.SESSION_NOT_CREATED:
  123. exception_class = SessionNotCreatedException
  124. elif status in ErrorCode.INVALID_ARGUMENT:
  125. exception_class = InvalidArgumentException
  126. elif status in ErrorCode.NO_SUCH_COOKIE:
  127. exception_class = NoSuchCookieException
  128. elif status in ErrorCode.UNABLE_TO_CAPTURE_SCREEN:
  129. exception_class = ScreenshotException
  130. elif status in ErrorCode.ELEMENT_CLICK_INTERCEPTED:
  131. exception_class = ElementClickInterceptedException
  132. elif status in ErrorCode.INSECURE_CERTIFICATE:
  133. exception_class = InsecureCertificateException
  134. elif status in ErrorCode.INVALID_COORDINATES:
  135. exception_class = InvalidCoordinatesException
  136. elif status in ErrorCode.INVALID_SESSION_ID:
  137. exception_class = InvalidSessionIdException
  138. elif status in ErrorCode.UNKNOWN_METHOD:
  139. exception_class = UnknownMethodException
  140. else:
  141. exception_class = WebDriverException
  142. if value == '' or value is None:
  143. value = response['value']
  144. if isinstance(value, basestring):
  145. if exception_class == ErrorInResponseException:
  146. raise exception_class(response, value)
  147. raise exception_class(value)
  148. if message == "" and 'message' in value:
  149. message = value['message']
  150.  
  151. screen = None
  152. if 'screen' in value:
  153. screen = value['screen']
  154.  
  155. stacktrace = None
  156. if 'stackTrace' in value and value['stackTrace']:
  157. stacktrace = []
  158. try:
  159. for frame in value['stackTrace']:
  160. line = self._value_or_default(frame, 'lineNumber', '')
  161. file = self._value_or_default(frame, 'fileName', '<anonymous>')
  162. if line:
  163. file = "%s:%s" % (file, line)
  164. meth = self._value_or_default(frame, 'methodName', '<anonymous>')
  165. if 'className' in frame:
  166. meth = "%s.%s" % (frame['className'], meth)
  167. msg = " at %s (%s)"
  168. msg = msg % (meth, file)
  169. stacktrace.append(msg)
  170. except TypeError:
  171. pass
  172. if exception_class == ErrorInResponseException:
  173. raise exception_class(response, message)
  174. elif exception_class == UnexpectedAlertPresentException:
  175. alert_text = None
  176. if 'data' in value:
  177. alert_text = value['data'].get('text')
  178. elif 'alert' in value:
  179. alert_text = value['alert'].get('text')
  180. raise exception_class(message, screen, stacktrace, alert_text)
  181. > raise exception_class(message, screen, stacktrace)
  182. E selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: [name="user"]
  183.  
  184. ../task_1_1/env1_1/lib/python3.6/site-packages/selenium/webdriver/remote/errorhandler.py:242: NoSuchElementException
  185. E
  186. test setup failed
  187. request = <SubRequest 'app' for <Function 'test_add_contact[None:lastname%R;firstnameT23Oz@]'>>
  188.  
  189. @pytest.fixture
  190. def app(request):
  191. global fixture
  192. global target
  193. browser = request.config.getoption("--browser")
  194. if target is None:
  195. with open(request.config.getoption("--target")) as config_file:
  196. target = json.load(config_file)
  197. if fixture is None or not fixture.is_valid():
  198. fixture = Application(browser=browser,base_url=target["baseUrl"])
  199. > fixture.session.ensure_login(username=target["username"], password=target["password"])
  200.  
  201. conftest.py:17:
  202. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  203. fixture/session.py:47: in ensure_login
  204. self.login(username,password)
  205. fixture/session.py:11: in login
  206. wd.find_element_by_name("user").click()
  207. ../task_1_1/env1_1/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py:487: in find_element_by_name
  208. return self.find_element(by=By.NAME, value=name)
  209. ../task_1_1/env1_1/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py:955: in find_element
  210. 'value': value})['value']
  211. ../task_1_1/env1_1/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py:312: in execute
  212. self.error_handler.check_response(response)
  213. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  214.  
  215. self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x10cfc8b00>
  216. response = {'status': 404, 'value': '{"value":{"error":"no such element","message":"Unable to locate element: [name=\\"user\\"]",...ror@chrome://marionette/content/error.js:434:5\\nelement.find/</<@chrome://marionette/content/element.js:341:16\\n"}}'}
  217.  
  218. def check_response(self, response):
  219. """
  220. Checks that a JSON response from the WebDriver does not have an error.
  221.  
  222. :Args:
  223. - response - The JSON response from the WebDriver server as a dictionary
  224. object.
  225.  
  226. :Raises: If the response contains an error message.
  227. """
  228. status = response.get('status', None)
  229. if status is None or status == ErrorCode.SUCCESS:
  230. return
  231. value = None
  232. message = response.get("message", "")
  233. screen = response.get("screen", "")
  234. stacktrace = None
  235. if isinstance(status, int):
  236. value_json = response.get('value', None)
  237. if value_json and isinstance(value_json, basestring):
  238. import json
  239. try:
  240. value = json.loads(value_json)
  241. if len(value.keys()) == 1:
  242. value = value['value']
  243. status = value.get('error', None)
  244. if status is None:
  245. status = value["status"]
  246. message = value["value"]
  247. if not isinstance(message, basestring):
  248. value = message
  249. message = message.get('message')
  250. else:
  251. message = value.get('message', None)
  252. except ValueError:
  253. pass
  254.  
  255. exception_class = ErrorInResponseException
  256. if status in ErrorCode.NO_SUCH_ELEMENT:
  257. exception_class = NoSuchElementException
  258. elif status in ErrorCode.NO_SUCH_FRAME:
  259. exception_class = NoSuchFrameException
  260. elif status in ErrorCode.NO_SUCH_WINDOW:
  261. exception_class = NoSuchWindowException
  262. elif status in ErrorCode.STALE_ELEMENT_REFERENCE:
  263. exception_class = StaleElementReferenceException
  264. elif status in ErrorCode.ELEMENT_NOT_VISIBLE:
  265. exception_class = ElementNotVisibleException
  266. elif status in ErrorCode.INVALID_ELEMENT_STATE:
  267. exception_class = InvalidElementStateException
  268. elif status in ErrorCode.INVALID_SELECTOR \
  269. or status in ErrorCode.INVALID_XPATH_SELECTOR \
  270. or status in ErrorCode.INVALID_XPATH_SELECTOR_RETURN_TYPER:
  271. exception_class = InvalidSelectorException
  272. elif status in ErrorCode.ELEMENT_IS_NOT_SELECTABLE:
  273. exception_class = ElementNotSelectableException
  274. elif status in ErrorCode.ELEMENT_NOT_INTERACTABLE:
  275. exception_class = ElementNotInteractableException
  276. elif status in ErrorCode.INVALID_COOKIE_DOMAIN:
  277. exception_class = InvalidCookieDomainException
  278. elif status in ErrorCode.UNABLE_TO_SET_COOKIE:
  279. exception_class = UnableToSetCookieException
  280. elif status in ErrorCode.TIMEOUT:
  281. exception_class = TimeoutException
  282. elif status in ErrorCode.SCRIPT_TIMEOUT:
  283. exception_class = TimeoutException
  284. elif status in ErrorCode.UNKNOWN_ERROR:
  285. exception_class = WebDriverException
  286. elif status in ErrorCode.UNEXPECTED_ALERT_OPEN:
  287. exception_class = UnexpectedAlertPresentException
  288. elif status in ErrorCode.NO_ALERT_OPEN:
  289. exception_class = NoAlertPresentException
  290. elif status in ErrorCode.IME_NOT_AVAILABLE:
  291. exception_class = ImeNotAvailableException
  292. elif status in ErrorCode.IME_ENGINE_ACTIVATION_FAILED:
  293. exception_class = ImeActivationFailedException
  294. elif status in ErrorCode.MOVE_TARGET_OUT_OF_BOUNDS:
  295. exception_class = MoveTargetOutOfBoundsException
  296. elif status in ErrorCode.JAVASCRIPT_ERROR:
  297. exception_class = JavascriptException
  298. elif status in ErrorCode.SESSION_NOT_CREATED:
  299. exception_class = SessionNotCreatedException
  300. elif status in ErrorCode.INVALID_ARGUMENT:
  301. exception_class = InvalidArgumentException
  302. elif status in ErrorCode.NO_SUCH_COOKIE:
  303. exception_class = NoSuchCookieException
  304. elif status in ErrorCode.UNABLE_TO_CAPTURE_SCREEN:
  305. exception_class = ScreenshotException
  306. elif status in ErrorCode.ELEMENT_CLICK_INTERCEPTED:
  307. exception_class = ElementClickInterceptedException
  308. elif status in ErrorCode.INSECURE_CERTIFICATE:
  309. exception_class = InsecureCertificateException
  310. elif status in ErrorCode.INVALID_COORDINATES:
  311. exception_class = InvalidCoordinatesException
  312. elif status in ErrorCode.INVALID_SESSION_ID:
  313. exception_class = InvalidSessionIdException
  314. elif status in ErrorCode.UNKNOWN_METHOD:
  315. exception_class = UnknownMethodException
  316. else:
  317. exception_class = WebDriverException
  318. if value == '' or value is None:
  319. value = response['value']
  320. if isinstance(value, basestring):
  321. if exception_class == ErrorInResponseException:
  322. raise exception_class(response, value)
  323. raise exception_class(value)
  324. if message == "" and 'message' in value:
  325. message = value['message']
  326.  
  327. screen = None
  328. if 'screen' in value:
  329. screen = value['screen']
  330.  
  331. stacktrace = None
  332. if 'stackTrace' in value and value['stackTrace']:
  333. stacktrace = []
  334. try:
  335. for frame in value['stackTrace']:
  336. line = self._value_or_default(frame, 'lineNumber', '')
  337. file = self._value_or_default(frame, 'fileName', '<anonymous>')
  338. if line:
  339. file = "%s:%s" % (file, line)
  340. meth = self._value_or_default(frame, 'methodName', '<anonymous>')
  341. if 'className' in frame:
  342. meth = "%s.%s" % (frame['className'], meth)
  343. msg = " at %s (%s)"
  344. msg = msg % (meth, file)
  345. stacktrace.append(msg)
  346. except TypeError:
  347. pass
  348. if exception_class == ErrorInResponseException:
  349. raise exception_class(response, message)
  350. elif exception_class == UnexpectedAlertPresentException:
  351. alert_text = None
  352. if 'data' in value:
  353. alert_text = value['data'].get('text')
  354. elif 'alert' in value:
  355. alert_text = value['alert'].get('text')
  356. raise exception_class(message, screen, stacktrace, alert_text)
  357. > raise exception_class(message, screen, stacktrace)
  358. E selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: [name="user"]
  359.  
  360. ../task_1_1/env1_1/lib/python3.6/site-packages/selenium/webdriver/remote/errorhandler.py:242: NoSuchElementException
  361. [100%]
  362.  
  363. ==================================== ERRORS ====================================
  364. __ ERROR at setup of test_add_contact[None:lastname <S4? zj8;firstnamepkL23m] __
  365.  
  366. request = <SubRequest 'app' for <Function 'test_add_contact[None:lastname <S4? zj8;firstnamepkL23m]'>>
  367.  
  368. @pytest.fixture
  369. def app(request):
  370. global fixture
  371. global target
  372. browser = request.config.getoption("--browser")
  373. if target is None:
  374. with open(request.config.getoption("--target")) as config_file:
  375. target = json.load(config_file)
  376. if fixture is None or not fixture.is_valid():
  377. fixture = Application(browser=browser,base_url=target["baseUrl"])
  378. > fixture.session.ensure_login(username=target["username"], password=target["password"])
  379.  
  380. conftest.py:17:
  381. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  382. fixture/session.py:47: in ensure_login
  383. self.login(username,password)
  384. fixture/session.py:11: in login
  385. wd.find_element_by_name("user").click()
  386. ../task_1_1/env1_1/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py:487: in find_element_by_name
  387. return self.find_element(by=By.NAME, value=name)
  388. ../task_1_1/env1_1/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py:955: in find_element
  389. 'value': value})['value']
  390. ../task_1_1/env1_1/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py:312: in execute
  391. self.error_handler.check_response(response)
  392. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  393.  
  394. self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x10cfc8b00>
  395. response = {'status': 404, 'value': '{"value":{"error":"no such element","message":"Unable to locate element: [name=\\"user\\"]",...ror@chrome://marionette/content/error.js:434:5\\nelement.find/</<@chrome://marionette/content/element.js:341:16\\n"}}'}
  396.  
  397. def check_response(self, response):
  398. """
  399. Checks that a JSON response from the WebDriver does not have an error.
  400.  
  401. :Args:
  402. - response - The JSON response from the WebDriver server as a dictionary
  403. object.
  404.  
  405. :Raises: If the response contains an error message.
  406. """
  407. status = response.get('status', None)
  408. if status is None or status == ErrorCode.SUCCESS:
  409. return
  410. value = None
  411. message = response.get("message", "")
  412. screen = response.get("screen", "")
  413. stacktrace = None
  414. if isinstance(status, int):
  415. value_json = response.get('value', None)
  416. if value_json and isinstance(value_json, basestring):
  417. import json
  418. try:
  419. value = json.loads(value_json)
  420. if len(value.keys()) == 1:
  421. value = value['value']
  422. status = value.get('error', None)
  423. if status is None:
  424. status = value["status"]
  425. message = value["value"]
  426. if not isinstance(message, basestring):
  427. value = message
  428. message = message.get('message')
  429. else:
  430. message = value.get('message', None)
  431. except ValueError:
  432. pass
  433.  
  434. exception_class = ErrorInResponseException
  435. if status in ErrorCode.NO_SUCH_ELEMENT:
  436. exception_class = NoSuchElementException
  437. elif status in ErrorCode.NO_SUCH_FRAME:
  438. exception_class = NoSuchFrameException
  439. elif status in ErrorCode.NO_SUCH_WINDOW:
  440. exception_class = NoSuchWindowException
  441. elif status in ErrorCode.STALE_ELEMENT_REFERENCE:
  442. exception_class = StaleElementReferenceException
  443. elif status in ErrorCode.ELEMENT_NOT_VISIBLE:
  444. exception_class = ElementNotVisibleException
  445. elif status in ErrorCode.INVALID_ELEMENT_STATE:
  446. exception_class = InvalidElementStateException
  447. elif status in ErrorCode.INVALID_SELECTOR \
  448. or status in ErrorCode.INVALID_XPATH_SELECTOR \
  449. or status in ErrorCode.INVALID_XPATH_SELECTOR_RETURN_TYPER:
  450. exception_class = InvalidSelectorException
  451. elif status in ErrorCode.ELEMENT_IS_NOT_SELECTABLE:
  452. exception_class = ElementNotSelectableException
  453. elif status in ErrorCode.ELEMENT_NOT_INTERACTABLE:
  454. exception_class = ElementNotInteractableException
  455. elif status in ErrorCode.INVALID_COOKIE_DOMAIN:
  456. exception_class = InvalidCookieDomainException
  457. elif status in ErrorCode.UNABLE_TO_SET_COOKIE:
  458. exception_class = UnableToSetCookieException
  459. elif status in ErrorCode.TIMEOUT:
  460. exception_class = TimeoutException
  461. elif status in ErrorCode.SCRIPT_TIMEOUT:
  462. exception_class = TimeoutException
  463. elif status in ErrorCode.UNKNOWN_ERROR:
  464. exception_class = WebDriverException
  465. elif status in ErrorCode.UNEXPECTED_ALERT_OPEN:
  466. exception_class = UnexpectedAlertPresentException
  467. elif status in ErrorCode.NO_ALERT_OPEN:
  468. exception_class = NoAlertPresentException
  469. elif status in ErrorCode.IME_NOT_AVAILABLE:
  470. exception_class = ImeNotAvailableException
  471. elif status in ErrorCode.IME_ENGINE_ACTIVATION_FAILED:
  472. exception_class = ImeActivationFailedException
  473. elif status in ErrorCode.MOVE_TARGET_OUT_OF_BOUNDS:
  474. exception_class = MoveTargetOutOfBoundsException
  475. elif status in ErrorCode.JAVASCRIPT_ERROR:
  476. exception_class = JavascriptException
  477. elif status in ErrorCode.SESSION_NOT_CREATED:
  478. exception_class = SessionNotCreatedException
  479. elif status in ErrorCode.INVALID_ARGUMENT:
  480. exception_class = InvalidArgumentException
  481. elif status in ErrorCode.NO_SUCH_COOKIE:
  482. exception_class = NoSuchCookieException
  483. elif status in ErrorCode.UNABLE_TO_CAPTURE_SCREEN:
  484. exception_class = ScreenshotException
  485. elif status in ErrorCode.ELEMENT_CLICK_INTERCEPTED:
  486. exception_class = ElementClickInterceptedException
  487. elif status in ErrorCode.INSECURE_CERTIFICATE:
  488. exception_class = InsecureCertificateException
  489. elif status in ErrorCode.INVALID_COORDINATES:
  490. exception_class = InvalidCoordinatesException
  491. elif status in ErrorCode.INVALID_SESSION_ID:
  492. exception_class = InvalidSessionIdException
  493. elif status in ErrorCode.UNKNOWN_METHOD:
  494. exception_class = UnknownMethodException
  495. else:
  496. exception_class = WebDriverException
  497. if value == '' or value is None:
  498. value = response['value']
  499. if isinstance(value, basestring):
  500. if exception_class == ErrorInResponseException:
  501. raise exception_class(response, value)
  502. raise exception_class(value)
  503. if message == "" and 'message' in value:
  504. message = value['message']
  505.  
  506. screen = None
  507. if 'screen' in value:
  508. screen = value['screen']
  509.  
  510. stacktrace = None
  511. if 'stackTrace' in value and value['stackTrace']:
  512. stacktrace = []
  513. try:
  514. for frame in value['stackTrace']:
  515. line = self._value_or_default(frame, 'lineNumber', '')
  516. file = self._value_or_default(frame, 'fileName', '<anonymous>')
  517. if line:
  518. file = "%s:%s" % (file, line)
  519. meth = self._value_or_default(frame, 'methodName', '<anonymous>')
  520. if 'className' in frame:
  521. meth = "%s.%s" % (frame['className'], meth)
  522. msg = " at %s (%s)"
  523. msg = msg % (meth, file)
  524. stacktrace.append(msg)
  525. except TypeError:
  526. pass
  527. if exception_class == ErrorInResponseException:
  528. raise exception_class(response, message)
  529. elif exception_class == UnexpectedAlertPresentException:
  530. alert_text = None
  531. if 'data' in value:
  532. alert_text = value['data'].get('text')
  533. elif 'alert' in value:
  534. alert_text = value['alert'].get('text')
  535. raise exception_class(message, screen, stacktrace, alert_text)
  536. > raise exception_class(message, screen, stacktrace)
  537. E selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: [name="user"]
  538.  
  539. ../task_1_1/env1_1/lib/python3.6/site-packages/selenium/webdriver/remote/errorhandler.py:242: NoSuchElementException
  540. _____ ERROR at setup of test_add_contact[None:lastname%R;firstnameT23Oz@] ______
  541.  
  542. request = <SubRequest 'app' for <Function 'test_add_contact[None:lastname%R;firstnameT23Oz@]'>>
  543.  
  544. @pytest.fixture
  545. def app(request):
  546. global fixture
  547. global target
  548. browser = request.config.getoption("--browser")
  549. if target is None:
  550. with open(request.config.getoption("--target")) as config_file:
  551. target = json.load(config_file)
  552. if fixture is None or not fixture.is_valid():
  553. fixture = Application(browser=browser,base_url=target["baseUrl"])
  554. > fixture.session.ensure_login(username=target["username"], password=target["password"])
  555.  
  556. conftest.py:17:
  557. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  558. fixture/session.py:47: in ensure_login
  559. self.login(username,password)
  560. fixture/session.py:11: in login
  561. wd.find_element_by_name("user").click()
  562. ../task_1_1/env1_1/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py:487: in find_element_by_name
  563. return self.find_element(by=By.NAME, value=name)
  564. ../task_1_1/env1_1/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py:955: in find_element
  565. 'value': value})['value']
  566. ../task_1_1/env1_1/lib/python3.6/site-packages/selenium/webdriver/remote/webdriver.py:312: in execute
  567. self.error_handler.check_response(response)
  568. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  569.  
  570. self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x10cfc8b00>
  571. response = {'status': 404, 'value': '{"value":{"error":"no such element","message":"Unable to locate element: [name=\\"user\\"]",...ror@chrome://marionette/content/error.js:434:5\\nelement.find/</<@chrome://marionette/content/element.js:341:16\\n"}}'}
  572.  
  573. def check_response(self, response):
  574. """
  575. Checks that a JSON response from the WebDriver does not have an error.
  576.  
  577. :Args:
  578. - response - The JSON response from the WebDriver server as a dictionary
  579. object.
  580.  
  581. :Raises: If the response contains an error message.
  582. """
  583. status = response.get('status', None)
  584. if status is None or status == ErrorCode.SUCCESS:
  585. return
  586. value = None
  587. message = response.get("message", "")
  588. screen = response.get("screen", "")
  589. stacktrace = None
  590. if isinstance(status, int):
  591. value_json = response.get('value', None)
  592. if value_json and isinstance(value_json, basestring):
  593. import json
  594. try:
  595. value = json.loads(value_json)
  596. if len(value.keys()) == 1:
  597. value = value['value']
  598. status = value.get('error', None)
  599. if status is None:
  600. status = value["status"]
  601. message = value["value"]
  602. if not isinstance(message, basestring):
  603. value = message
  604. message = message.get('message')
  605. else:
  606. message = value.get('message', None)
  607. except ValueError:
  608. pass
  609.  
  610. exception_class = ErrorInResponseException
  611. if status in ErrorCode.NO_SUCH_ELEMENT:
  612. exception_class = NoSuchElementException
  613. elif status in ErrorCode.NO_SUCH_FRAME:
  614. exception_class = NoSuchFrameException
  615. elif status in ErrorCode.NO_SUCH_WINDOW:
  616. exception_class = NoSuchWindowException
  617. elif status in ErrorCode.STALE_ELEMENT_REFERENCE:
  618. exception_class = StaleElementReferenceException
  619. elif status in ErrorCode.ELEMENT_NOT_VISIBLE:
  620. exception_class = ElementNotVisibleException
  621. elif status in ErrorCode.INVALID_ELEMENT_STATE:
  622. exception_class = InvalidElementStateException
  623. elif status in ErrorCode.INVALID_SELECTOR \
  624. or status in ErrorCode.INVALID_XPATH_SELECTOR \
  625. or status in ErrorCode.INVALID_XPATH_SELECTOR_RETURN_TYPER:
  626. exception_class = InvalidSelectorException
  627. elif status in ErrorCode.ELEMENT_IS_NOT_SELECTABLE:
  628. exception_class = ElementNotSelectableException
  629. elif status in ErrorCode.ELEMENT_NOT_INTERACTABLE:
  630. exception_class = ElementNotInteractableException
  631. elif status in ErrorCode.INVALID_COOKIE_DOMAIN:
  632. exception_class = InvalidCookieDomainException
  633. elif status in ErrorCode.UNABLE_TO_SET_COOKIE:
  634. exception_class = UnableToSetCookieException
  635. elif status in ErrorCode.TIMEOUT:
  636. exception_class = TimeoutException
  637. elif status in ErrorCode.SCRIPT_TIMEOUT:
  638. exception_class = TimeoutException
  639. elif status in ErrorCode.UNKNOWN_ERROR:
  640. exception_class = WebDriverException
  641. elif status in ErrorCode.UNEXPECTED_ALERT_OPEN:
  642. exception_class = UnexpectedAlertPresentException
  643. elif status in ErrorCode.NO_ALERT_OPEN:
  644. exception_class = NoAlertPresentException
  645. elif status in ErrorCode.IME_NOT_AVAILABLE:
  646. exception_class = ImeNotAvailableException
  647. elif status in ErrorCode.IME_ENGINE_ACTIVATION_FAILED:
  648. exception_class = ImeActivationFailedException
  649. elif status in ErrorCode.MOVE_TARGET_OUT_OF_BOUNDS:
  650. exception_class = MoveTargetOutOfBoundsException
  651. elif status in ErrorCode.JAVASCRIPT_ERROR:
  652. exception_class = JavascriptException
  653. elif status in ErrorCode.SESSION_NOT_CREATED:
  654. exception_class = SessionNotCreatedException
  655. elif status in ErrorCode.INVALID_ARGUMENT:
  656. exception_class = InvalidArgumentException
  657. elif status in ErrorCode.NO_SUCH_COOKIE:
  658. exception_class = NoSuchCookieException
  659. elif status in ErrorCode.UNABLE_TO_CAPTURE_SCREEN:
  660. exception_class = ScreenshotException
  661. elif status in ErrorCode.ELEMENT_CLICK_INTERCEPTED:
  662. exception_class = ElementClickInterceptedException
  663. elif status in ErrorCode.INSECURE_CERTIFICATE:
  664. exception_class = InsecureCertificateException
  665. elif status in ErrorCode.INVALID_COORDINATES:
  666. exception_class = InvalidCoordinatesException
  667. elif status in ErrorCode.INVALID_SESSION_ID:
  668. exception_class = InvalidSessionIdException
  669. elif status in ErrorCode.UNKNOWN_METHOD:
  670. exception_class = UnknownMethodException
  671. else:
  672. exception_class = WebDriverException
  673. if value == '' or value is None:
  674. value = response['value']
  675. if isinstance(value, basestring):
  676. if exception_class == ErrorInResponseException:
  677. raise exception_class(response, value)
  678. raise exception_class(value)
  679. if message == "" and 'message' in value:
  680. message = value['message']
  681.  
  682. screen = None
  683. if 'screen' in value:
  684. screen = value['screen']
  685.  
  686. stacktrace = None
  687. if 'stackTrace' in value and value['stackTrace']:
  688. stacktrace = []
  689. try:
  690. for frame in value['stackTrace']:
  691. line = self._value_or_default(frame, 'lineNumber', '')
  692. file = self._value_or_default(frame, 'fileName', '<anonymous>')
  693. if line:
  694. file = "%s:%s" % (file, line)
  695. meth = self._value_or_default(frame, 'methodName', '<anonymous>')
  696. if 'className' in frame:
  697. meth = "%s.%s" % (frame['className'], meth)
  698. msg = " at %s (%s)"
  699. msg = msg % (meth, file)
  700. stacktrace.append(msg)
  701. except TypeError:
  702. pass
  703. if exception_class == ErrorInResponseException:
  704. raise exception_class(response, message)
  705. elif exception_class == UnexpectedAlertPresentException:
  706. alert_text = None
  707. if 'data' in value:
  708. alert_text = value['data'].get('text')
  709. elif 'alert' in value:
  710. alert_text = value['alert'].get('text')
  711. raise exception_class(message, screen, stacktrace, alert_text)
  712. > raise exception_class(message, screen, stacktrace)
  713. E selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: [name="user"]
  714.  
  715. ../task_1_1/env1_1/lib/python3.6/site-packages/selenium/webdriver/remote/errorhandler.py:242: NoSuchElementException
  716. =========================== 2 error in 5.17 seconds ============================
  717. Process finished with exit code 0
Add Comment
Please, Sign In to add comment