Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2017
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.88 KB | None | 0 0
  1. E
  2. test setup failed
  3. request = <SubRequest 'app' for <Function 'test_add_group'>>
  4.  
  5. @pytest.fixture
  6. def app(request):
  7. global fixture
  8. if fixture is None:
  9. fixture = Application()
  10. else:
  11. if not fixture.is_valid():
  12. fixture = Application()
  13. > fixture.session.ensure_login(username="admin", password="secret")
  14.  
  15. conftest.py:15:
  16. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  17. fixture\session.py:36: in ensure_login
  18. if self.is_logged_in():
  19. fixture\session.py:28: in is_logged_in
  20. return len(wd.find_element_by_link_text("Logout")) > 0
  21. env\lib\site-packages\selenium\webdriver\remote\webdriver.py:378: in find_element_by_link_text
  22. return self.find_element(by=By.LINK_TEXT, value=link_text)
  23. env\lib\site-packages\selenium\webdriver\remote\webdriver.py:832: in find_element
  24. 'value': value})['value']
  25. env\lib\site-packages\selenium\webdriver\remote\webdriver.py:297: in execute
  26. self.error_handler.check_response(response)
  27. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  28.  
  29. self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x040BB410>
  30. response = {'status': 404, 'value': '{"value":{"error":"no such element","message":"Unable to locate element: Logout","stacktrace... 0x4173a7 - <no info>\\n 9: 0x6d38b3 - <no info>\\n 10: 0x7ff8994a8364 - BaseThreadInitThunk"}}'}
  31.  
  32. def check_response(self, response):
  33. """
  34. Checks that a JSON response from the WebDriver does not have an error.
  35.  
  36. :Args:
  37. - response - The JSON response from the WebDriver server as a dictionary
  38. object.
  39.  
  40. :Raises: If the response contains an error message.
  41. """
  42. status = response.get('status', None)
  43. if status is None or status == ErrorCode.SUCCESS:
  44. return
  45. value = None
  46. message = response.get("message", "")
  47. screen = response.get("screen", "")
  48. stacktrace = None
  49. if isinstance(status, int):
  50. value_json = response.get('value', None)
  51. if value_json and isinstance(value_json, basestring):
  52. import json
  53. try:
  54. value = json.loads(value_json)
  55. if len(value.keys()) == 1:
  56. value = value['value']
  57. status = value.get('error', None)
  58. if status is None:
  59. status = value["status"]
  60. message = value["value"]
  61. if not isinstance(message, basestring):
  62. value = message
  63. message = message.get('message')
  64. else:
  65. message = value.get('message', None)
  66. except ValueError:
  67. pass
  68.  
  69. exception_class = ErrorInResponseException
  70. if status in ErrorCode.NO_SUCH_ELEMENT:
  71. exception_class = NoSuchElementException
  72. elif status in ErrorCode.NO_SUCH_FRAME:
  73. exception_class = NoSuchFrameException
  74. elif status in ErrorCode.NO_SUCH_WINDOW:
  75. exception_class = NoSuchWindowException
  76. elif status in ErrorCode.STALE_ELEMENT_REFERENCE:
  77. exception_class = StaleElementReferenceException
  78. elif status in ErrorCode.ELEMENT_NOT_VISIBLE:
  79. exception_class = ElementNotVisibleException
  80. elif status in ErrorCode.INVALID_ELEMENT_STATE:
  81. exception_class = InvalidElementStateException
  82. elif status in ErrorCode.INVALID_SELECTOR \
  83. or status in ErrorCode.INVALID_XPATH_SELECTOR \
  84. or status in ErrorCode.INVALID_XPATH_SELECTOR_RETURN_TYPER:
  85. exception_class = InvalidSelectorException
  86. elif status in ErrorCode.ELEMENT_IS_NOT_SELECTABLE:
  87. exception_class = ElementNotSelectableException
  88. elif status in ErrorCode.ELEMENT_NOT_INTERACTABLE:
  89. exception_class = ElementNotInteractableException
  90. elif status in ErrorCode.INVALID_COOKIE_DOMAIN:
  91. exception_class = WebDriverException
  92. elif status in ErrorCode.UNABLE_TO_SET_COOKIE:
  93. exception_class = WebDriverException
  94. elif status in ErrorCode.TIMEOUT:
  95. exception_class = TimeoutException
  96. elif status in ErrorCode.SCRIPT_TIMEOUT:
  97. exception_class = TimeoutException
  98. elif status in ErrorCode.UNKNOWN_ERROR:
  99. exception_class = WebDriverException
  100. elif status in ErrorCode.UNEXPECTED_ALERT_OPEN:
  101. exception_class = UnexpectedAlertPresentException
  102. elif status in ErrorCode.NO_ALERT_OPEN:
  103. exception_class = NoAlertPresentException
  104. elif status in ErrorCode.IME_NOT_AVAILABLE:
  105. exception_class = ImeNotAvailableException
  106. elif status in ErrorCode.IME_ENGINE_ACTIVATION_FAILED:
  107. exception_class = ImeActivationFailedException
  108. elif status in ErrorCode.MOVE_TARGET_OUT_OF_BOUNDS:
  109. exception_class = MoveTargetOutOfBoundsException
  110. else:
  111. exception_class = WebDriverException
  112. if value == '' or value is None:
  113. value = response['value']
  114. if isinstance(value, basestring):
  115. if exception_class == ErrorInResponseException:
  116. raise exception_class(response, value)
  117. raise exception_class(value)
  118. if message == "" and 'message' in value:
  119. message = value['message']
  120.  
  121. screen = None
  122. if 'screen' in value:
  123. screen = value['screen']
  124.  
  125. stacktrace = None
  126. if 'stackTrace' in value and value['stackTrace']:
  127. stacktrace = []
  128. try:
  129. for frame in value['stackTrace']:
  130. line = self._value_or_default(frame, 'lineNumber', '')
  131. file = self._value_or_default(frame, 'fileName', '<anonymous>')
  132. if line:
  133. file = "%s:%s" % (file, line)
  134. meth = self._value_or_default(frame, 'methodName', '<anonymous>')
  135. if 'className' in frame:
  136. meth = "%s.%s" % (frame['className'], meth)
  137. msg = " at %s (%s)"
  138. msg = msg % (meth, file)
  139. stacktrace.append(msg)
  140. except TypeError:
  141. pass
  142. if exception_class == ErrorInResponseException:
  143. raise exception_class(response, message)
  144. elif exception_class == UnexpectedAlertPresentException and 'alert' in value:
  145. raise exception_class(message, screen, stacktrace, value['alert'].get('text'))
  146. > raise exception_class(message, screen, stacktrace)
  147. E selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: Logout
  148.  
  149. env\lib\site-packages\selenium\webdriver\remote\errorhandler.py:194: NoSuchElementException
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement