Guest User

Untitled

a guest
Oct 6th, 2018
319
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.98 KB | None | 0 0
  1. F
  2. test_modify_contact.py:3 (test_modify_group)
  3. app = <fixture.application.Application object at 0x1069b3978>
  4.  
  5. def test_modify_group(app):
  6. #app.navigation.open_home_page()
  7. #app.session.login(login="admin", password="secret")
  8. app.contact.modify_first_contact(Contact(firstname="Ekaterina", middlename="E.Smithes", lastname="Smithes", nickname="Cat", photo="/Users/i.mamutkina/Desktop/photo.png", title="Manager",
  9. company="Facebook", address="13 Main str, 9 apr, SF", home="1122334455", mobile="33221166554", work="99887744556",
  10. fax="fax-745-126-789", email="cat_1@gmail.com", email2="cat_2@gmail.com", email3="cat_3@gmail.com", homepage="Changed homepage",
  11. bday="10", bmonth="April", byear="1998", aday="19", amonth="December", ayear="1999", address2="123 Main str, 40 apr, San Carlos",
  12. > phone2="385263354", notes="New changed notes!"))
  13.  
  14. test_modify_contact.py:11:
  15. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  16. ../fixture/contact.py:93: in modify_first_contact
  17. wd.find_element_by_xpath("//img[@alt='Edit']").click()
  18. /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py:394: in find_element_by_xpath
  19. return self.find_element(by=By.XPATH, value=xpath)
  20. /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py:978: in find_element
  21. 'value': value})['value']
  22. /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py:321: in execute
  23. self.error_handler.check_response(response)
  24. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  25.  
  26. self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x1069d0240>
  27. response = {'status': 404, 'value': '{"value":{"error":"no such element","message":"Unable to locate element: //img[@alt=\'Edit\'...ror@chrome://marionette/content/error.js:388:5\\nelement.find/</<@chrome://marionette/content/element.js:341:16\\n"}}'}
  28.  
  29. def check_response(self, response):
  30. """
  31. Checks that a JSON response from the WebDriver does not have an error.
  32.  
  33. :Args:
  34. - response - The JSON response from the WebDriver server as a dictionary
  35. object.
  36.  
  37. :Raises: If the response contains an error message.
  38. """
  39. status = response.get('status', None)
  40. if status is None or status == ErrorCode.SUCCESS:
  41. return
  42. value = None
  43. message = response.get("message", "")
  44. screen = response.get("screen", "")
  45. stacktrace = None
  46. if isinstance(status, int):
  47. value_json = response.get('value', None)
  48. if value_json and isinstance(value_json, basestring):
  49. import json
  50. try:
  51. value = json.loads(value_json)
  52. if len(value.keys()) == 1:
  53. value = value['value']
  54. status = value.get('error', None)
  55. if status is None:
  56. status = value["status"]
  57. message = value["value"]
  58. if not isinstance(message, basestring):
  59. value = message
  60. message = message.get('message')
  61. else:
  62. message = value.get('message', None)
  63. except ValueError:
  64. pass
  65.  
  66. exception_class = ErrorInResponseException
  67. if status in ErrorCode.NO_SUCH_ELEMENT:
  68. exception_class = NoSuchElementException
  69. elif status in ErrorCode.NO_SUCH_FRAME:
  70. exception_class = NoSuchFrameException
  71. elif status in ErrorCode.NO_SUCH_WINDOW:
  72. exception_class = NoSuchWindowException
  73. elif status in ErrorCode.STALE_ELEMENT_REFERENCE:
  74. exception_class = StaleElementReferenceException
  75. elif status in ErrorCode.ELEMENT_NOT_VISIBLE:
  76. exception_class = ElementNotVisibleException
  77. elif status in ErrorCode.INVALID_ELEMENT_STATE:
  78. exception_class = InvalidElementStateException
  79. elif status in ErrorCode.INVALID_SELECTOR \
  80. or status in ErrorCode.INVALID_XPATH_SELECTOR \
  81. or status in ErrorCode.INVALID_XPATH_SELECTOR_RETURN_TYPER:
  82. exception_class = InvalidSelectorException
  83. elif status in ErrorCode.ELEMENT_IS_NOT_SELECTABLE:
  84. exception_class = ElementNotSelectableException
  85. elif status in ErrorCode.ELEMENT_NOT_INTERACTABLE:
  86. exception_class = ElementNotInteractableException
  87. elif status in ErrorCode.INVALID_COOKIE_DOMAIN:
  88. exception_class = InvalidCookieDomainException
  89. elif status in ErrorCode.UNABLE_TO_SET_COOKIE:
  90. exception_class = UnableToSetCookieException
  91. elif status in ErrorCode.TIMEOUT:
  92. exception_class = TimeoutException
  93. elif status in ErrorCode.SCRIPT_TIMEOUT:
  94. exception_class = TimeoutException
  95. elif status in ErrorCode.UNKNOWN_ERROR:
  96. exception_class = WebDriverException
  97. elif status in ErrorCode.UNEXPECTED_ALERT_OPEN:
  98. exception_class = UnexpectedAlertPresentException
  99. elif status in ErrorCode.NO_ALERT_OPEN:
  100. exception_class = NoAlertPresentException
  101. elif status in ErrorCode.IME_NOT_AVAILABLE:
  102. exception_class = ImeNotAvailableException
  103. elif status in ErrorCode.IME_ENGINE_ACTIVATION_FAILED:
  104. exception_class = ImeActivationFailedException
  105. elif status in ErrorCode.MOVE_TARGET_OUT_OF_BOUNDS:
  106. exception_class = MoveTargetOutOfBoundsException
  107. elif status in ErrorCode.JAVASCRIPT_ERROR:
  108. exception_class = JavascriptException
  109. elif status in ErrorCode.SESSION_NOT_CREATED:
  110. exception_class = SessionNotCreatedException
  111. elif status in ErrorCode.INVALID_ARGUMENT:
  112. exception_class = InvalidArgumentException
  113. elif status in ErrorCode.NO_SUCH_COOKIE:
  114. exception_class = NoSuchCookieException
  115. elif status in ErrorCode.UNABLE_TO_CAPTURE_SCREEN:
  116. exception_class = ScreenshotException
  117. elif status in ErrorCode.ELEMENT_CLICK_INTERCEPTED:
  118. exception_class = ElementClickInterceptedException
  119. elif status in ErrorCode.INSECURE_CERTIFICATE:
  120. exception_class = InsecureCertificateException
  121. elif status in ErrorCode.INVALID_COORDINATES:
  122. exception_class = InvalidCoordinatesException
  123. elif status in ErrorCode.INVALID_SESSION_ID:
  124. exception_class = InvalidSessionIdException
  125. elif status in ErrorCode.UNKNOWN_METHOD:
  126. exception_class = UnknownMethodException
  127. else:
  128. exception_class = WebDriverException
  129. if value == '' or value is None:
  130. value = response['value']
  131. if isinstance(value, basestring):
  132. if exception_class == ErrorInResponseException:
  133. raise exception_class(response, value)
  134. raise exception_class(value)
  135. if message == "" and 'message' in value:
  136. message = value['message']
  137.  
  138. screen = None
  139. if 'screen' in value:
  140. screen = value['screen']
  141.  
  142. stacktrace = None
  143. if 'stackTrace' in value and value['stackTrace']:
  144. stacktrace = []
  145. try:
  146. for frame in value['stackTrace']:
  147. line = self._value_or_default(frame, 'lineNumber', '')
  148. file = self._value_or_default(frame, 'fileName', '<anonymous>')
  149. if line:
  150. file = "%s:%s" % (file, line)
  151. meth = self._value_or_default(frame, 'methodName', '<anonymous>')
  152. if 'className' in frame:
  153. meth = "%s.%s" % (frame['className'], meth)
  154. msg = " at %s (%s)"
  155. msg = msg % (meth, file)
  156. stacktrace.append(msg)
  157. except TypeError:
  158. pass
  159. if exception_class == ErrorInResponseException:
  160. raise exception_class(response, message)
  161. elif exception_class == UnexpectedAlertPresentException:
  162. alert_text = None
  163. if 'data' in value:
  164. alert_text = value['data'].get('text')
  165. elif 'alert' in value:
  166. alert_text = value['alert'].get('text')
  167. raise exception_class(message, screen, stacktrace, alert_text)
  168. > raise exception_class(message, screen, stacktrace)
  169. E selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: //img[@alt='Edit']
  170.  
  171. /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/selenium/webdriver/remote/errorhandler.py:242: NoSuchElementException
  172. [ 77%]
  173. test_modify_group.py
Add Comment
Please, Sign In to add comment