Guest User

Untitled

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