Advertisement
Guest User

Untitled

a guest
Jun 7th, 2017
494
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.21 KB | None | 0 0
  1. C:\Devel\python_training\env\Scripts\python.exe "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2016.3.3\helpers\pycharm\pytestrunner.py" -p pytest_teamcity C:/Devel/python_training/test/test_add_contact_in_group.py
  2. Testing started at 16:39 ...
  3. ============================= test session starts =============================
  4. platform win32 -- Python 3.6.1, pytest-3.0.7, py-1.4.33, pluggy-0.4.0
  5. rootdir: C:\Devel\python_training\test, inifile:
  6. collected 1 items
  7.  
  8. test_add_contact_in_group.py GET CONNECTION FROM THE LOCAL POOL
  9. SELECT `c`.`id`, `c`.`firstname`, `c`.`lastname`, `c`.`address`, `c`.`home`, `c`.`mobile`, `c`.`work`, `c`.`phone2`, `c`.`email`, `c`.`email2`, `c`.`email3`, `c`.`deprecated`
  10. FROM `addressbook` `c`
  11. WHERE `c`.`deprecated` IS NULL
  12.  
  13. COMMIT
  14. RELEASE CONNECTION
  15. GET CONNECTION FROM THE LOCAL POOL
  16. SELECT `g`.`group_id`, `g`.`group_name`, `g`.`group_header`, `g`.`group_footer`
  17. FROM `group_list` `g`
  18.  
  19. COMMIT
  20. RELEASE CONNECTION
  21. GET CONNECTION FROM THE LOCAL POOL
  22. SELECT `g`.`group_id`, `g`.`group_name`, `g`.`group_header`, `g`.`group_footer`
  23. FROM `group_list` `g`
  24.  
  25. COMMIT
  26. RELEASE CONNECTION
  27. GET CONNECTION FROM THE LOCAL POOL
  28. SELECT `g`.`group_id`, `g`.`group_name`, `g`.`group_header`, `g`.`group_footer`
  29. FROM `group_list` `g`
  30. WHERE `g`.`group_id` = %s
  31. ['103']
  32.  
  33. SELECT `c`.`id`, `c`.`firstname`, `c`.`lastname`, `c`.`address`, `c`.`home`, `c`.`mobile`, `c`.`work`, `c`.`phone2`, `c`.`email`, `c`.`email2`, `c`.`email3`, `c`.`deprecated`
  34. FROM `addressbook` `c`
  35. WHERE `c`.`deprecated` IS NULL
  36. AND %s NOT IN (
  37. SELECT `t-1`.`group_id`
  38. FROM `address_in_groups` `t-1`
  39. WHERE `c`.`id` = `t-1`.`id`
  40. )
  41. [103]
  42.  
  43. COMMIT
  44. RELEASE CONNECTION
  45. F
  46. app = <fixture.application.Application object at 0x03B02D10>
  47.  
  48. def test_add_contact_in_group(app):
  49. old_db_contact = db.get_contact_list()
  50. old_db_group = db.get_group_list()
  51. contact = Contact(firstname="firstname")
  52. group = Group(name="New group")
  53. if old_db_group:
  54. new_db_group = db.get_group_list()
  55. random_group = random.choice(new_db_group)
  56. group_id = random_group.id
  57. if old_db_contact:
  58. contacts_not_in_groups = db.get_contacts_not_in_group(random_group)
  59. random_contact = random.choice(contacts_not_in_groups)
  60. contact_id = random_contact.id
  61. > app.contact.add_contact_to_group_by_name(contact_id, group_id)
  62.  
  63. test_add_contact_in_group.py:25:
  64. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  65. ..\fixture\contact.py:192: in add_contact_to_group_by_name
  66. wd.find_element_by_xpath('//i//*[contains(text(),"group page")]').click()
  67. ..\env\lib\site-packages\selenium\webdriver\remote\webdriver.py:293: in find_element_by_xpath
  68. return self.find_element(by=By.XPATH, value=xpath)
  69. ..\env\lib\site-packages\selenium\webdriver\remote\webdriver.py:752: in find_element
  70. 'value': value})['value']
  71. ..\env\lib\site-packages\selenium\webdriver\remote\webdriver.py:236: in execute
  72. self.error_handler.check_response(response)
  73. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  74.  
  75. self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x03B02E30>
  76. response = {'status': 500, 'value': '{"name":"findElement","sessionId":"9d1fe0d0-4987-490b-b94a-6ad4a05eaa32","status":7,"value":...pu529ctlw/extensions/fxdriver@googlecode.com/components/command-processor.js","lineNumber":12608,"columnNumber":5}]}}'}
  77.  
  78. def check_response(self, response):
  79. """
  80. Checks that a JSON response from the WebDriver does not have an error.
  81.  
  82. :Args:
  83. - response - The JSON response from the WebDriver server as a dictionary
  84. object.
  85.  
  86. :Raises: If the response contains an error message.
  87. """
  88. status = response.get('status', None)
  89. if status is None or status == ErrorCode.SUCCESS:
  90. return
  91.  
  92. value = None
  93. message = response.get("message", "")
  94. screen = response.get("screen", "")
  95. stacktrace = None
  96. if isinstance(status, int):
  97. value_json = response.get('value', None)
  98. if value_json and isinstance(value_json, basestring):
  99. import json
  100. try:
  101. value = json.loads(value_json)
  102. status = value.get('error', None)
  103. if status is None:
  104. status = value["status"]
  105. message = value["value"]
  106. if not isinstance(message, basestring):
  107. value = message
  108. try:
  109. message = message['message']
  110. except TypeError:
  111. message = None
  112. else:
  113. message = value.get('message', None)
  114. except ValueError:
  115. pass
  116.  
  117. exception_class = ErrorInResponseException
  118. if status in ErrorCode.NO_SUCH_ELEMENT:
  119. exception_class = NoSuchElementException
  120. elif status in ErrorCode.NO_SUCH_FRAME:
  121. exception_class = NoSuchFrameException
  122. elif status in ErrorCode.NO_SUCH_WINDOW:
  123. exception_class = NoSuchWindowException
  124. elif status in ErrorCode.STALE_ELEMENT_REFERENCE:
  125. exception_class = StaleElementReferenceException
  126. elif status in ErrorCode.ELEMENT_NOT_VISIBLE:
  127. exception_class = ElementNotVisibleException
  128. elif status in ErrorCode.INVALID_ELEMENT_STATE:
  129. exception_class = InvalidElementStateException
  130. elif status in ErrorCode.INVALID_SELECTOR \
  131. or status in ErrorCode.INVALID_XPATH_SELECTOR \
  132. or status in ErrorCode.INVALID_XPATH_SELECTOR_RETURN_TYPER:
  133. exception_class = InvalidSelectorException
  134. elif status in ErrorCode.ELEMENT_IS_NOT_SELECTABLE:
  135. exception_class = ElementNotSelectableException
  136. elif status in ErrorCode.INVALID_COOKIE_DOMAIN:
  137. exception_class = WebDriverException
  138. elif status in ErrorCode.UNABLE_TO_SET_COOKIE:
  139. exception_class = WebDriverException
  140. elif status in ErrorCode.TIMEOUT:
  141. exception_class = TimeoutException
  142. elif status in ErrorCode.SCRIPT_TIMEOUT:
  143. exception_class = TimeoutException
  144. elif status in ErrorCode.UNKNOWN_ERROR:
  145. exception_class = WebDriverException
  146. elif status in ErrorCode.UNEXPECTED_ALERT_OPEN:
  147. exception_class = UnexpectedAlertPresentException
  148. elif status in ErrorCode.NO_ALERT_OPEN:
  149. exception_class = NoAlertPresentException
  150. elif status in ErrorCode.IME_NOT_AVAILABLE:
  151. exception_class = ImeNotAvailableException
  152. elif status in ErrorCode.IME_ENGINE_ACTIVATION_FAILED:
  153. exception_class = ImeActivationFailedException
  154. elif status in ErrorCode.MOVE_TARGET_OUT_OF_BOUNDS:
  155. exception_class = MoveTargetOutOfBoundsException
  156. else:
  157. exception_class = WebDriverException
  158. if value == '' or value is None:
  159. value = response['value']
  160. if isinstance(value, basestring):
  161. if exception_class == ErrorInResponseException:
  162. raise exception_class(response, value)
  163. raise exception_class(value)
  164. if message == "" and 'message' in value:
  165. message = value['message']
  166.  
  167. screen = None
  168. if 'screen' in value:
  169. screen = value['screen']
  170.  
  171. stacktrace = None
  172. if 'stackTrace' in value and value['stackTrace']:
  173. stacktrace = []
  174. try:
  175. for frame in value['stackTrace']:
  176. line = self._value_or_default(frame, 'lineNumber', '')
  177. file = self._value_or_default(frame, 'fileName', '<anonymous>')
  178. if line:
  179. file = "%s:%s" % (file, line)
  180. meth = self._value_or_default(frame, 'methodName', '<anonymous>')
  181. if 'className' in frame:
  182. meth = "%s.%s" % (frame['className'], meth)
  183. msg = " at %s (%s)"
  184. msg = msg % (meth, file)
  185. stacktrace.append(msg)
  186. except TypeError:
  187. pass
  188. if exception_class == ErrorInResponseException:
  189. raise exception_class(response, message)
  190. elif exception_class == UnexpectedAlertPresentException and 'alert' in value:
  191. raise exception_class(message, screen, stacktrace, value['alert'].get('text'))
  192. > raise exception_class(message, screen, stacktrace)
  193. E selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: {"method":"xpath","selector":"//i//*[contains(text(),\"group page\")]"}
  194. E Stacktrace:
  195. E at FirefoxDriver.prototype.findElementInternal_ (file:///C:/Users/BALCEV~1/AppData/Local/Temp/tmpu529ctlw/extensions/fxdriver@googlecode.com/components/driver-component.js:10770)
  196. E at FirefoxDriver.prototype.findElement (file:///C:/Users/BALCEV~1/AppData/Local/Temp/tmpu529ctlw/extensions/fxdriver@googlecode.com/components/driver-component.js:10779)
  197. E at DelayedCommand.prototype.executeInternal_/h (file:///C:/Users/BALCEV~1/AppData/Local/Temp/tmpu529ctlw/extensions/fxdriver@googlecode.com/components/command-processor.js:12661)
  198. E at DelayedCommand.prototype.executeInternal_ (file:///C:/Users/BALCEV~1/AppData/Local/Temp/tmpu529ctlw/extensions/fxdriver@googlecode.com/components/command-processor.js:12666)
  199. E at DelayedCommand.prototype.execute/< (file:///C:/Users/BALCEV~1/AppData/Local/Temp/tmpu529ctlw/extensions/fxdriver@googlecode.com/components/command-processor.js:12608)
  200.  
  201. ..\env\lib\site-packages\selenium\webdriver\remote\errorhandler.py:192: NoSuchElementException
  202.  
  203.  
  204. ================================== FAILURES ===================================
  205. __________________________ test_add_contact_in_group __________________________
  206.  
  207. app = <fixture.application.Application object at 0x03B02D10>
  208.  
  209. def test_add_contact_in_group(app):
  210. old_db_contact = db.get_contact_list()
  211. old_db_group = db.get_group_list()
  212. contact = Contact(firstname="firstname")
  213. group = Group(name="New group")
  214. if old_db_group:
  215. new_db_group = db.get_group_list()
  216. random_group = random.choice(new_db_group)
  217. group_id = random_group.id
  218. if old_db_contact:
  219. contacts_not_in_groups = db.get_contacts_not_in_group(random_group)
  220. random_contact = random.choice(contacts_not_in_groups)
  221. contact_id = random_contact.id
  222. > app.contact.add_contact_to_group_by_name(contact_id, group_id)
  223.  
  224. test_add_contact_in_group.py:25:
  225. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  226. ..\fixture\contact.py:192: in add_contact_to_group_by_name
  227. wd.find_element_by_xpath('//i//*[contains(text(),"group page")]').click()
  228. ..\env\lib\site-packages\selenium\webdriver\remote\webdriver.py:293: in find_element_by_xpath
  229. return self.find_element(by=By.XPATH, value=xpath)
  230. ..\env\lib\site-packages\selenium\webdriver\remote\webdriver.py:752: in find_element
  231. 'value': value})['value']
  232. ..\env\lib\site-packages\selenium\webdriver\remote\webdriver.py:236: in execute
  233. self.error_handler.check_response(response)
  234. _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  235.  
  236. self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x03B02E30>
  237. response = {'status': 500, 'value': '{"name":"findElement","sessionId":"9d1fe0d0-4987-490b-b94a-6ad4a05eaa32","status":7,"value":...pu529ctlw/extensions/fxdriver@googlecode.com/components/command-processor.js","lineNumber":12608,"columnNumber":5}]}}'}
  238.  
  239. def check_response(self, response):
  240. """
  241. Checks that a JSON response from the WebDriver does not have an error.
  242.  
  243. :Args:
  244. - response - The JSON response from the WebDriver server as a dictionary
  245. object.
  246.  
  247. :Raises: If the response contains an error message.
  248. """
  249. status = response.get('status', None)
  250. if status is None or status == ErrorCode.SUCCESS:
  251. return
  252.  
  253. value = None
  254. message = response.get("message", "")
  255. screen = response.get("screen", "")
  256. stacktrace = None
  257. if isinstance(status, int):
  258. value_json = response.get('value', None)
  259. if value_json and isinstance(value_json, basestring):
  260. import json
  261. try:
  262. value = json.loads(value_json)
  263. status = value.get('error', None)
  264. if status is None:
  265. status = value["status"]
  266. message = value["value"]
  267. if not isinstance(message, basestring):
  268. value = message
  269. try:
  270. message = message['message']
  271. except TypeError:
  272. message = None
  273. else:
  274. message = value.get('message', None)
  275. except ValueError:
  276. pass
  277.  
  278. exception_class = ErrorInResponseException
  279. if status in ErrorCode.NO_SUCH_ELEMENT:
  280. exception_class = NoSuchElementException
  281. elif status in ErrorCode.NO_SUCH_FRAME:
  282. exception_class = NoSuchFrameException
  283. elif status in ErrorCode.NO_SUCH_WINDOW:
  284. exception_class = NoSuchWindowException
  285. elif status in ErrorCode.STALE_ELEMENT_REFERENCE:
  286. exception_class = StaleElementReferenceException
  287. elif status in ErrorCode.ELEMENT_NOT_VISIBLE:
  288. exception_class = ElementNotVisibleException
  289. elif status in ErrorCode.INVALID_ELEMENT_STATE:
  290. exception_class = InvalidElementStateException
  291. elif status in ErrorCode.INVALID_SELECTOR \
  292. or status in ErrorCode.INVALID_XPATH_SELECTOR \
  293. or status in ErrorCode.INVALID_XPATH_SELECTOR_RETURN_TYPER:
  294. exception_class = InvalidSelectorException
  295. elif status in ErrorCode.ELEMENT_IS_NOT_SELECTABLE:
  296. exception_class = ElementNotSelectableException
  297. elif status in ErrorCode.INVALID_COOKIE_DOMAIN:
  298. exception_class = WebDriverException
  299. elif status in ErrorCode.UNABLE_TO_SET_COOKIE:
  300. exception_class = WebDriverException
  301. elif status in ErrorCode.TIMEOUT:
  302. exception_class = TimeoutException
  303. elif status in ErrorCode.SCRIPT_TIMEOUT:
  304. exception_class = TimeoutException
  305. elif status in ErrorCode.UNKNOWN_ERROR:
  306. exception_class = WebDriverException
  307. elif status in ErrorCode.UNEXPECTED_ALERT_OPEN:
  308. exception_class = UnexpectedAlertPresentException
  309. elif status in ErrorCode.NO_ALERT_OPEN:
  310. exception_class = NoAlertPresentException
  311. elif status in ErrorCode.IME_NOT_AVAILABLE:
  312. exception_class = ImeNotAvailableException
  313. elif status in ErrorCode.IME_ENGINE_ACTIVATION_FAILED:
  314. exception_class = ImeActivationFailedException
  315. elif status in ErrorCode.MOVE_TARGET_OUT_OF_BOUNDS:
  316. exception_class = MoveTargetOutOfBoundsException
  317. else:
  318. exception_class = WebDriverException
  319. if value == '' or value is None:
  320. value = response['value']
  321. if isinstance(value, basestring):
  322. if exception_class == ErrorInResponseException:
  323. raise exception_class(response, value)
  324. raise exception_class(value)
  325. if message == "" and 'message' in value:
  326. message = value['message']
  327.  
  328. screen = None
  329. if 'screen' in value:
  330. screen = value['screen']
  331.  
  332. stacktrace = None
  333. if 'stackTrace' in value and value['stackTrace']:
  334. stacktrace = []
  335. try:
  336. for frame in value['stackTrace']:
  337. line = self._value_or_default(frame, 'lineNumber', '')
  338. file = self._value_or_default(frame, 'fileName', '<anonymous>')
  339. if line:
  340. file = "%s:%s" % (file, line)
  341. meth = self._value_or_default(frame, 'methodName', '<anonymous>')
  342. if 'className' in frame:
  343. meth = "%s.%s" % (frame['className'], meth)
  344. msg = " at %s (%s)"
  345. msg = msg % (meth, file)
  346. stacktrace.append(msg)
  347. except TypeError:
  348. pass
  349. if exception_class == ErrorInResponseException:
  350. raise exception_class(response, message)
  351. elif exception_class == UnexpectedAlertPresentException and 'alert' in value:
  352. raise exception_class(message, screen, stacktrace, value['alert'].get('text'))
  353. > raise exception_class(message, screen, stacktrace)
  354. E selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: {"method":"xpath","selector":"//i//*[contains(text(),\"group page\")]"}
  355. E Stacktrace:
  356. E at FirefoxDriver.prototype.findElementInternal_ (file:///C:/Users/BALCEV~1/AppData/Local/Temp/tmpu529ctlw/extensions/fxdriver@googlecode.com/components/driver-component.js:10770)
  357. E at FirefoxDriver.prototype.findElement (file:///C:/Users/BALCEV~1/AppData/Local/Temp/tmpu529ctlw/extensions/fxdriver@googlecode.com/components/driver-component.js:10779)
  358. E at DelayedCommand.prototype.executeInternal_/h (file:///C:/Users/BALCEV~1/AppData/Local/Temp/tmpu529ctlw/extensions/fxdriver@googlecode.com/components/command-processor.js:12661)
  359. E at DelayedCommand.prototype.executeInternal_ (file:///C:/Users/BALCEV~1/AppData/Local/Temp/tmpu529ctlw/extensions/fxdriver@googlecode.com/components/command-processor.js:12666)
  360. E at DelayedCommand.prototype.execute/< (file:///C:/Users/BALCEV~1/AppData/Local/Temp/tmpu529ctlw/extensions/fxdriver@googlecode.com/components/command-processor.js:12608)
  361.  
  362. ..\env\lib\site-packages\selenium\webdriver\remote\errorhandler.py:192: NoSuchElementException
  363. ========================== 1 failed in 7.58 seconds ===========================
  364.  
  365. Process finished with exit code 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement