Guest User

Untitled

a guest
Dec 17th, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.90 KB | None | 0 0
  1. F
  2. test_add_group.py:9 (test_add_empty_group)
  3. app = <fixture.application.Application object at 0x1035499e8>
  4.  
  5. def test_add_empty_group(app):
  6. > app.session.login(username="admin", password="secret")
  7.  
  8. test_add_group.py:11:
  9. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  10. ../fixture/session.py:11: in login
  11. wd.find_element_by_name("user").click()
  12. ../env/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py:496: in find_element_by_name
  13. return self.find_element(by=By.NAME, value=name)
  14. ../env/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py:978: in find_element
  15. 'value': value})['value']
  16. ../env/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py:321: in execute
  17. self.error_handler.check_response(response)
  18. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  19.  
  20. self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x102f65860>
  21. response = {'status': 404, 'value': '{"value":{"error":"no such element","message":"Unable to locate element: [name=\\"user\\"]",...ror@chrome://marionette/content/error.js:388:5\\nelement.find/</<@chrome://marionette/content/element.js:339:16\\n"}}'}
  22.  
  23. def check_response(self, response):
  24. """
  25. Checks that a JSON response from the WebDriver does not have an error.
  26.  
  27. :Args:
  28. - response - The JSON response from the WebDriver server as a dictionary
  29. object.
  30.  
  31. :Raises: If the response contains an error message.
  32. """
  33. status = response.get('status', None)
  34. if status is None or status == ErrorCode.SUCCESS:
  35. return
  36. value = None
  37. message = response.get("message", "")
  38. screen = response.get("screen", "")
  39. stacktrace = None
  40. if isinstance(status, int):
  41. value_json = response.get('value', None)
  42. if value_json and isinstance(value_json, basestring):
  43. import json
  44. try:
  45. value = json.loads(value_json)
  46. if len(value.keys()) == 1:
  47. value = value['value']
  48. status = value.get('error', None)
  49. if status is None:
  50. status = value["status"]
  51. message = value["value"]
  52. if not isinstance(message, basestring):
  53. value = message
  54. message = message.get('message')
  55. else:
  56. message = value.get('message', None)
  57. except ValueError:
  58. pass
  59.  
  60. exception_class = ErrorInResponseException
  61. if status in ErrorCode.NO_SUCH_ELEMENT:
  62. exception_class = NoSuchElementException
  63. elif status in ErrorCode.NO_SUCH_FRAME:
  64. exception_class = NoSuchFrameException
  65. elif status in ErrorCode.NO_SUCH_WINDOW:
  66. exception_class = NoSuchWindowException
  67. elif status in ErrorCode.STALE_ELEMENT_REFERENCE:
  68. exception_class = StaleElementReferenceException
  69. elif status in ErrorCode.ELEMENT_NOT_VISIBLE:
  70. exception_class = ElementNotVisibleException
  71. elif status in ErrorCode.INVALID_ELEMENT_STATE:
  72. exception_class = InvalidElementStateException
  73. elif status in ErrorCode.INVALID_SELECTOR \
  74. or status in ErrorCode.INVALID_XPATH_SELECTOR \
  75. or status in ErrorCode.INVALID_XPATH_SELECTOR_RETURN_TYPER:
  76. exception_class = InvalidSelectorException
  77. elif status in ErrorCode.ELEMENT_IS_NOT_SELECTABLE:
  78. exception_class = ElementNotSelectableException
  79. elif status in ErrorCode.ELEMENT_NOT_INTERACTABLE:
  80. exception_class = ElementNotInteractableException
  81. elif status in ErrorCode.INVALID_COOKIE_DOMAIN:
  82. exception_class = InvalidCookieDomainException
  83. elif status in ErrorCode.UNABLE_TO_SET_COOKIE:
  84. exception_class = UnableToSetCookieException
  85. elif status in ErrorCode.TIMEOUT:
  86. exception_class = TimeoutException
  87. elif status in ErrorCode.SCRIPT_TIMEOUT:
  88. exception_class = TimeoutException
  89. elif status in ErrorCode.UNKNOWN_ERROR:
  90. exception_class = WebDriverException
  91. elif status in ErrorCode.UNEXPECTED_ALERT_OPEN:
  92. exception_class = UnexpectedAlertPresentException
  93. elif status in ErrorCode.NO_ALERT_OPEN:
  94. exception_class = NoAlertPresentException
  95. elif status in ErrorCode.IME_NOT_AVAILABLE:
  96. exception_class = ImeNotAvailableException
  97. elif status in ErrorCode.IME_ENGINE_ACTIVATION_FAILED:
  98. exception_class = ImeActivationFailedException
  99. elif status in ErrorCode.MOVE_TARGET_OUT_OF_BOUNDS:
  100. exception_class = MoveTargetOutOfBoundsException
  101. elif status in ErrorCode.JAVASCRIPT_ERROR:
  102. exception_class = JavascriptException
  103. elif status in ErrorCode.SESSION_NOT_CREATED:
  104. exception_class = SessionNotCreatedException
  105. elif status in ErrorCode.INVALID_ARGUMENT:
  106. exception_class = InvalidArgumentException
  107. elif status in ErrorCode.NO_SUCH_COOKIE:
  108. exception_class = NoSuchCookieException
  109. elif status in ErrorCode.UNABLE_TO_CAPTURE_SCREEN:
  110. exception_class = ScreenshotException
  111. elif status in ErrorCode.ELEMENT_CLICK_INTERCEPTED:
  112. exception_class = ElementClickInterceptedException
  113. elif status in ErrorCode.INSECURE_CERTIFICATE:
  114. exception_class = InsecureCertificateException
  115. elif status in ErrorCode.INVALID_COORDINATES:
  116. exception_class = InvalidCoordinatesException
  117. elif status in ErrorCode.INVALID_SESSION_ID:
  118. exception_class = InvalidSessionIdException
  119. elif status in ErrorCode.UNKNOWN_METHOD:
  120. exception_class = UnknownMethodException
  121. else:
  122. exception_class = WebDriverException
  123. if value == '' or value is None:
  124. value = response['value']
  125. if isinstance(value, basestring):
  126. if exception_class == ErrorInResponseException:
  127. raise exception_class(response, value)
  128. raise exception_class(value)
  129. if message == "" and 'message' in value:
  130. message = value['message']
  131.  
  132. screen = None
  133. if 'screen' in value:
  134. screen = value['screen']
  135.  
  136. stacktrace = None
  137. if 'stackTrace' in value and value['stackTrace']:
  138. stacktrace = []
  139. try:
  140. for frame in value['stackTrace']:
  141. line = self._value_or_default(frame, 'lineNumber', '')
  142. file = self._value_or_default(frame, 'fileName', '<anonymous>')
  143. if line:
  144. file = "%s:%s" % (file, line)
  145. meth = self._value_or_default(frame, 'methodName', '<anonymous>')
  146. if 'className' in frame:
  147. meth = "%s.%s" % (frame['className'], meth)
  148. msg = " at %s (%s)"
  149. msg = msg % (meth, file)
  150. stacktrace.append(msg)
  151. except TypeError:
  152. pass
  153. if exception_class == ErrorInResponseException:
  154. raise exception_class(response, message)
  155. elif exception_class == UnexpectedAlertPresentException:
  156. alert_text = None
  157. if 'data' in value:
  158. alert_text = value['data'].get('text')
  159. elif 'alert' in value:
  160. alert_text = value['alert'].get('text')
  161. raise exception_class(message, screen, stacktrace, alert_text)
  162. > raise exception_class(message, screen, stacktrace)
  163. E selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: [name="user"]
  164.  
  165. ../env/lib/python3.7/site-packages/selenium/webdriver/remote/errorhandler.py:242: NoSuchElementException
Add Comment
Please, Sign In to add comment