Guest User

Untitled

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