Guest User

Untitled

a guest
Nov 12th, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 16.81 KB | None | 0 0
  1. F
  2. test_modify_contact.py:4 (test_modify_contact_firstname)
  3. app = <fixture.application.Application object at 0x03B675D0>
  4.  
  5. def test_modify_contact_firstname(app):
  6. app.session.login(username="admin", password="secret")
  7. > app.contact.modify_first_contact(Contact(firstname="New name", title="New title"))
  8.  
  9. test_modify_contact.py:7:
  10. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  11. ..\fixture\contact.py:97: in modify_first_contact
  12. self.fill_contact_form(new_contact_data)
  13. ..\fixture\contact.py:58: in fill_contact_form
  14. Select(wd.find_element_by_name("bday")).select_by_visible_text(contact.bday)
  15. ..\env\lib\site-packages\selenium\webdriver\support\select.py:117: in select_by_visible_text
  16. opts = self._el.find_elements(By.XPATH, xpath)
  17. ..\env\lib\site-packages\selenium\webdriver\remote\webelement.py:685: in find_elements
  18. {"using": by, "value": value})['value']
  19. ..\env\lib\site-packages\selenium\webdriver\remote\webelement.py:633: in _execute
  20. return self._parent.execute(command, params)
  21. ..\env\lib\site-packages\selenium\webdriver\remote\webdriver.py:321: in execute
  22. self.error_handler.check_response(response)
  23. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  24.  
  25. self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x03B35A10>
  26. response = {'status': 400, 'value': '{"value":{"error":"invalid selector","message":"Given xpath expression \\".//option[normaliz.../findElements<@chrome://marionette/content/element.js:315:17\\nevalFn@chrome://marionette/content/sync.js:111:7\\n"}}'}
  27.  
  28. def check_response(self, response):
  29. """
  30. Checks that a JSON response from the WebDriver does not have an error.
  31.  
  32. :Args:
  33. - response - The JSON response from the WebDriver server as a dictionary
  34. object.
  35.  
  36. :Raises: If the response contains an error message.
  37. """
  38. status = response.get('status', None)
  39. if status is None or status == ErrorCode.SUCCESS:
  40. return
  41. value = None
  42. message = response.get("message", "")
  43. screen = response.get("screen", "")
  44. stacktrace = None
  45. if isinstance(status, int):
  46. value_json = response.get('value', None)
  47. if value_json and isinstance(value_json, basestring):
  48. import json
  49. try:
  50. value = json.loads(value_json)
  51. if len(value.keys()) == 1:
  52. value = value['value']
  53. status = value.get('error', None)
  54. if status is None:
  55. status = value["status"]
  56. message = value["value"]
  57. if not isinstance(message, basestring):
  58. value = message
  59. message = message.get('message')
  60. else:
  61. message = value.get('message', None)
  62. except ValueError:
  63. pass
  64.  
  65. exception_class = ErrorInResponseException
  66. if status in ErrorCode.NO_SUCH_ELEMENT:
  67. exception_class = NoSuchElementException
  68. elif status in ErrorCode.NO_SUCH_FRAME:
  69. exception_class = NoSuchFrameException
  70. elif status in ErrorCode.NO_SUCH_WINDOW:
  71. exception_class = NoSuchWindowException
  72. elif status in ErrorCode.STALE_ELEMENT_REFERENCE:
  73. exception_class = StaleElementReferenceException
  74. elif status in ErrorCode.ELEMENT_NOT_VISIBLE:
  75. exception_class = ElementNotVisibleException
  76. elif status in ErrorCode.INVALID_ELEMENT_STATE:
  77. exception_class = InvalidElementStateException
  78. elif status in ErrorCode.INVALID_SELECTOR \
  79. or status in ErrorCode.INVALID_XPATH_SELECTOR \
  80. or status in ErrorCode.INVALID_XPATH_SELECTOR_RETURN_TYPER:
  81. exception_class = InvalidSelectorException
  82. elif status in ErrorCode.ELEMENT_IS_NOT_SELECTABLE:
  83. exception_class = ElementNotSelectableException
  84. elif status in ErrorCode.ELEMENT_NOT_INTERACTABLE:
  85. exception_class = ElementNotInteractableException
  86. elif status in ErrorCode.INVALID_COOKIE_DOMAIN:
  87. exception_class = InvalidCookieDomainException
  88. elif status in ErrorCode.UNABLE_TO_SET_COOKIE:
  89. exception_class = UnableToSetCookieException
  90. elif status in ErrorCode.TIMEOUT:
  91. exception_class = TimeoutException
  92. elif status in ErrorCode.SCRIPT_TIMEOUT:
  93. exception_class = TimeoutException
  94. elif status in ErrorCode.UNKNOWN_ERROR:
  95. exception_class = WebDriverException
  96. elif status in ErrorCode.UNEXPECTED_ALERT_OPEN:
  97. exception_class = UnexpectedAlertPresentException
  98. elif status in ErrorCode.NO_ALERT_OPEN:
  99. exception_class = NoAlertPresentException
  100. elif status in ErrorCode.IME_NOT_AVAILABLE:
  101. exception_class = ImeNotAvailableException
  102. elif status in ErrorCode.IME_ENGINE_ACTIVATION_FAILED:
  103. exception_class = ImeActivationFailedException
  104. elif status in ErrorCode.MOVE_TARGET_OUT_OF_BOUNDS:
  105. exception_class = MoveTargetOutOfBoundsException
  106. elif status in ErrorCode.JAVASCRIPT_ERROR:
  107. exception_class = JavascriptException
  108. elif status in ErrorCode.SESSION_NOT_CREATED:
  109. exception_class = SessionNotCreatedException
  110. elif status in ErrorCode.INVALID_ARGUMENT:
  111. exception_class = InvalidArgumentException
  112. elif status in ErrorCode.NO_SUCH_COOKIE:
  113. exception_class = NoSuchCookieException
  114. elif status in ErrorCode.UNABLE_TO_CAPTURE_SCREEN:
  115. exception_class = ScreenshotException
  116. elif status in ErrorCode.ELEMENT_CLICK_INTERCEPTED:
  117. exception_class = ElementClickInterceptedException
  118. elif status in ErrorCode.INSECURE_CERTIFICATE:
  119. exception_class = InsecureCertificateException
  120. elif status in ErrorCode.INVALID_COORDINATES:
  121. exception_class = InvalidCoordinatesException
  122. elif status in ErrorCode.INVALID_SESSION_ID:
  123. exception_class = InvalidSessionIdException
  124. elif status in ErrorCode.UNKNOWN_METHOD:
  125. exception_class = UnknownMethodException
  126. else:
  127. exception_class = WebDriverException
  128. if value == '' or value is None:
  129. value = response['value']
  130. if isinstance(value, basestring):
  131. if exception_class == ErrorInResponseException:
  132. raise exception_class(response, value)
  133. raise exception_class(value)
  134. if message == "" and 'message' in value:
  135. message = value['message']
  136.  
  137. screen = None
  138. if 'screen' in value:
  139. screen = value['screen']
  140.  
  141. stacktrace = None
  142. if 'stackTrace' in value and value['stackTrace']:
  143. stacktrace = []
  144. try:
  145. for frame in value['stackTrace']:
  146. line = self._value_or_default(frame, 'lineNumber', '')
  147. file = self._value_or_default(frame, 'fileName', '<anonymous>')
  148. if line:
  149. file = "%s:%s" % (file, line)
  150. meth = self._value_or_default(frame, 'methodName', '<anonymous>')
  151. if 'className' in frame:
  152. meth = "%s.%s" % (frame['className'], meth)
  153. msg = " at %s (%s)"
  154. msg = msg % (meth, file)
  155. stacktrace.append(msg)
  156. except TypeError:
  157. pass
  158. if exception_class == ErrorInResponseException:
  159. raise exception_class(response, message)
  160. elif exception_class == UnexpectedAlertPresentException:
  161. alert_text = None
  162. if 'data' in value:
  163. alert_text = value['data'].get('text')
  164. elif 'alert' in value:
  165. alert_text = value['alert'].get('text')
  166. raise exception_class(message, screen, stacktrace, alert_text)
  167. > raise exception_class(message, screen, stacktrace)
  168. E selenium.common.exceptions.InvalidSelectorException: Message: Given xpath expression ".//option[normalize-space(.) = ""]" is invalid: WrongDocumentError: Node cannot be used in a document other than the one in which it was created
  169.  
  170. ..\env\lib\site-packages\selenium\webdriver\remote\errorhandler.py:242: InvalidSelectorException
  171. F
  172. test_modify_contact.py:10 (test_modify_contact_title)
  173. app = <fixture.application.Application object at 0x03B675D0>
  174.  
  175. def test_modify_contact_title(app):
  176. app.session.login(username="admin", password="secret")
  177. > app.contact.modify_first_contact(Contact(title="New title"))
  178.  
  179. test_modify_contact.py:13:
  180. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  181. ..\fixture\contact.py:97: in modify_first_contact
  182. self.fill_contact_form(new_contact_data)
  183. ..\fixture\contact.py:58: in fill_contact_form
  184. Select(wd.find_element_by_name("bday")).select_by_visible_text(contact.bday)
  185. ..\env\lib\site-packages\selenium\webdriver\support\select.py:117: in select_by_visible_text
  186. opts = self._el.find_elements(By.XPATH, xpath)
  187. ..\env\lib\site-packages\selenium\webdriver\remote\webelement.py:685: in find_elements
  188. {"using": by, "value": value})['value']
  189. ..\env\lib\site-packages\selenium\webdriver\remote\webelement.py:633: in _execute
  190. return self._parent.execute(command, params)
  191. ..\env\lib\site-packages\selenium\webdriver\remote\webdriver.py:321: in execute
  192. self.error_handler.check_response(response)
  193. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  194.  
  195. self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x03B35A10>
  196. response = {'status': 400, 'value': '{"value":{"error":"invalid selector","message":"Given xpath expression \\".//option[normaliz.../findElements<@chrome://marionette/content/element.js:315:17\\nevalFn@chrome://marionette/content/sync.js:111:7\\n"}}'}
  197.  
  198. def check_response(self, response):
  199. """
  200. Checks that a JSON response from the WebDriver does not have an error.
  201.  
  202. :Args:
  203. - response - The JSON response from the WebDriver server as a dictionary
  204. object.
  205.  
  206. :Raises: If the response contains an error message.
  207. """
  208. status = response.get('status', None)
  209. if status is None or status == ErrorCode.SUCCESS:
  210. return
  211. value = None
  212. message = response.get("message", "")
  213. screen = response.get("screen", "")
  214. stacktrace = None
  215. if isinstance(status, int):
  216. value_json = response.get('value', None)
  217. if value_json and isinstance(value_json, basestring):
  218. import json
  219. try:
  220. value = json.loads(value_json)
  221. if len(value.keys()) == 1:
  222. value = value['value']
  223. status = value.get('error', None)
  224. if status is None:
  225. status = value["status"]
  226. message = value["value"]
  227. if not isinstance(message, basestring):
  228. value = message
  229. message = message.get('message')
  230. else:
  231. message = value.get('message', None)
  232. except ValueError:
  233. pass
  234.  
  235. exception_class = ErrorInResponseException
  236. if status in ErrorCode.NO_SUCH_ELEMENT:
  237. exception_class = NoSuchElementException
  238. elif status in ErrorCode.NO_SUCH_FRAME:
  239. exception_class = NoSuchFrameException
  240. elif status in ErrorCode.NO_SUCH_WINDOW:
  241. exception_class = NoSuchWindowException
  242. elif status in ErrorCode.STALE_ELEMENT_REFERENCE:
  243. exception_class = StaleElementReferenceException
  244. elif status in ErrorCode.ELEMENT_NOT_VISIBLE:
  245. exception_class = ElementNotVisibleException
  246. elif status in ErrorCode.INVALID_ELEMENT_STATE:
  247. exception_class = InvalidElementStateException
  248. elif status in ErrorCode.INVALID_SELECTOR \
  249. or status in ErrorCode.INVALID_XPATH_SELECTOR \
  250. or status in ErrorCode.INVALID_XPATH_SELECTOR_RETURN_TYPER:
  251. exception_class = InvalidSelectorException
  252. elif status in ErrorCode.ELEMENT_IS_NOT_SELECTABLE:
  253. exception_class = ElementNotSelectableException
  254. elif status in ErrorCode.ELEMENT_NOT_INTERACTABLE:
  255. exception_class = ElementNotInteractableException
  256. elif status in ErrorCode.INVALID_COOKIE_DOMAIN:
  257. exception_class = InvalidCookieDomainException
  258. elif status in ErrorCode.UNABLE_TO_SET_COOKIE:
  259. exception_class = UnableToSetCookieException
  260. elif status in ErrorCode.TIMEOUT:
  261. exception_class = TimeoutException
  262. elif status in ErrorCode.SCRIPT_TIMEOUT:
  263. exception_class = TimeoutException
  264. elif status in ErrorCode.UNKNOWN_ERROR:
  265. exception_class = WebDriverException
  266. elif status in ErrorCode.UNEXPECTED_ALERT_OPEN:
  267. exception_class = UnexpectedAlertPresentException
  268. elif status in ErrorCode.NO_ALERT_OPEN:
  269. exception_class = NoAlertPresentException
  270. elif status in ErrorCode.IME_NOT_AVAILABLE:
  271. exception_class = ImeNotAvailableException
  272. elif status in ErrorCode.IME_ENGINE_ACTIVATION_FAILED:
  273. exception_class = ImeActivationFailedException
  274. elif status in ErrorCode.MOVE_TARGET_OUT_OF_BOUNDS:
  275. exception_class = MoveTargetOutOfBoundsException
  276. elif status in ErrorCode.JAVASCRIPT_ERROR:
  277. exception_class = JavascriptException
  278. elif status in ErrorCode.SESSION_NOT_CREATED:
  279. exception_class = SessionNotCreatedException
  280. elif status in ErrorCode.INVALID_ARGUMENT:
  281. exception_class = InvalidArgumentException
  282. elif status in ErrorCode.NO_SUCH_COOKIE:
  283. exception_class = NoSuchCookieException
  284. elif status in ErrorCode.UNABLE_TO_CAPTURE_SCREEN:
  285. exception_class = ScreenshotException
  286. elif status in ErrorCode.ELEMENT_CLICK_INTERCEPTED:
  287. exception_class = ElementClickInterceptedException
  288. elif status in ErrorCode.INSECURE_CERTIFICATE:
  289. exception_class = InsecureCertificateException
  290. elif status in ErrorCode.INVALID_COORDINATES:
  291. exception_class = InvalidCoordinatesException
  292. elif status in ErrorCode.INVALID_SESSION_ID:
  293. exception_class = InvalidSessionIdException
  294. elif status in ErrorCode.UNKNOWN_METHOD:
  295. exception_class = UnknownMethodException
  296. else:
  297. exception_class = WebDriverException
  298. if value == '' or value is None:
  299. value = response['value']
  300. if isinstance(value, basestring):
  301. if exception_class == ErrorInResponseException:
  302. raise exception_class(response, value)
  303. raise exception_class(value)
  304. if message == "" and 'message' in value:
  305. message = value['message']
  306.  
  307. screen = None
  308. if 'screen' in value:
  309. screen = value['screen']
  310.  
  311. stacktrace = None
  312. if 'stackTrace' in value and value['stackTrace']:
  313. stacktrace = []
  314. try:
  315. for frame in value['stackTrace']:
  316. line = self._value_or_default(frame, 'lineNumber', '')
  317. file = self._value_or_default(frame, 'fileName', '<anonymous>')
  318. if line:
  319. file = "%s:%s" % (file, line)
  320. meth = self._value_or_default(frame, 'methodName', '<anonymous>')
  321. if 'className' in frame:
  322. meth = "%s.%s" % (frame['className'], meth)
  323. msg = " at %s (%s)"
  324. msg = msg % (meth, file)
  325. stacktrace.append(msg)
  326. except TypeError:
  327. pass
  328. if exception_class == ErrorInResponseException:
  329. raise exception_class(response, message)
  330. elif exception_class == UnexpectedAlertPresentException:
  331. alert_text = None
  332. if 'data' in value:
  333. alert_text = value['data'].get('text')
  334. elif 'alert' in value:
  335. alert_text = value['alert'].get('text')
  336. raise exception_class(message, screen, stacktrace, alert_text)
  337. > raise exception_class(message, screen, stacktrace)
  338. E selenium.common.exceptions.InvalidSelectorException: Message: Given xpath expression ".//option[normalize-space(.) = ""]" is invalid: WrongDocumentError: Node cannot be used in a document other than the one in which it was created
  339.  
  340. ..\env\lib\site-packages\selenium\webdriver\remote\errorhandler.py:242: InvalidSelectorException
  341. . [ 81%]
  342. test_modify_group.py
Add Comment
Please, Sign In to add comment