Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Select
C:\Users\iv.kalitina\AppData\Local\Programs\Python\Python36-32\python.exe "C:\Users\iv.kalitina\AppData\Roaming\JetBrains\PyCharm Community Edition 2017.2.3\helpers\pycharm\_jb_pytest_runner.py" --path C:/Users/iv.kalitina/Documents/GitHub/future_LKK/Add_campaign.py
Testing started at 11:04 ...
Launching py.test with arguments C:/Users/iv.kalitina/Documents/GitHub/future_LKK/Add_campaign.py in C:\Users\iv.kalitina\Documents\GitHub\future_LKK
============================= test session starts =============================
platform win32 -- Python 3.6.3, pytest-3.2.3, py-1.4.34, pluggy-0.4.0
rootdir: C:\Users\iv.kalitina\Documents\GitHub\future_LKK, inifile:
collected 1 item
Add_campaign.py F
Add_campaign.py:20 (Add_campaign.test_Add_campaign)
self = <Add_campaign.Add_campaign testMethod=test_Add_campaign>
def test_Add_campaign(self):
success = True
wd = self.wd
wd.get("https://toprussianbloggers.ru/")
wd.find_element_by_link_text("войти").click()
wd.find_element_by_id("system-auth-form-login").click()
wd.find_element_by_id("system-auth-form-login").clear()
wd.find_element_by_id("system-auth-form-login").send_keys("maria9@toprussianbloggers.ru")
wd.find_element_by_id("system-auth-form-password").click()
wd.find_element_by_id("system-auth-form-password").clear()
wd.find_element_by_id("system-auth-form-password").send_keys("123456")
wd.find_element_by_xpath("//div[@class='modal-body']/form/div[4]/input").click()
wd.find_element_by_link_text("Maria").click()
wd.find_element_by_link_text("Мои PR-кампании").click()
wd.find_element_by_link_text("Добавить новую кампанию").click()
wd.find_element_by_id("NAME").click()
wd.find_element_by_id("NAME").clear()
wd.find_element_by_id("NAME").send_keys("maria way")
wd.find_element_by_id("DATE_START").click()
wd.find_element_by_id("DATE_START").clear()
wd.find_element_by_id("DATE_START").send_keys("27.12.2017")
wd.find_element_by_id("DATE_END").click()
wd.find_element_by_id("DATE_END").click()
wd.find_element_by_id("DATE_END").clear()
wd.find_element_by_id("DATE_END").send_keys("29.12.2017")
wd.find_element_by_id("SET_TO").click()
wd.find_element_by_id("SET_TO").clear()
wd.find_element_by_id("SET_TO").send_keys("26.12.2017")
wd.find_element_by_css_selector("input.select2-search__field").click()
> wd.find_element_by_xpath("//span[contains(@aria-activedescedant,'select2-DIRECTION-result')]").click()
Add_campaign.py:50:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
..\..\..\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\webdriver.py:365: in find_element_by_xpath
return self.find_element(by=By.XPATH, value=xpath)
..\..\..\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\webdriver.py:843: in find_element
'value': value})['value']
..\..\..\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\webdriver.py:308: in execute
self.error_handler.check_response(response)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x0401F4B0>
response = {'status': 500, 'value': '{"name":"findElement","sessionId":"24f1e6ec-1113-4292-87a6-4537b1814ce4","status":7,"value":.../tmp_xsdeqzr/extensions/fxdriver@googlecode.com/components/driver-component.js","lineNumber":740,"columnNumber":5}]}}'}
def check_response(self, response):
"""
Checks that a JSON response from the WebDriver does not have an error.
:Args:
- response - The JSON response from the WebDriver server as a dictionary
object.
:Raises: If the response contains an error message.
"""
status = response.get('status', None)
if status is None or status == ErrorCode.SUCCESS:
return
value = None
message = response.get("message", "")
screen = response.get("screen", "")
stacktrace = None
if isinstance(status, int):
value_json = response.get('value', None)
if value_json and isinstance(value_json, basestring):
import json
try:
value = json.loads(value_json)
if len(value.keys()) == 1:
value = value['value']
status = value.get('error', None)
if status is None:
status = value["status"]
message = value["value"]
if not isinstance(message, basestring):
value = message
message = message.get('message')
else:
message = value.get('message', None)
except ValueError:
pass
exception_class = ErrorInResponseException
if status in ErrorCode.NO_SUCH_ELEMENT:
exception_class = NoSuchElementException
elif status in ErrorCode.NO_SUCH_FRAME:
exception_class = NoSuchFrameException
elif status in ErrorCode.NO_SUCH_WINDOW:
exception_class = NoSuchWindowException
elif status in ErrorCode.STALE_ELEMENT_REFERENCE:
exception_class = StaleElementReferenceException
elif status in ErrorCode.ELEMENT_NOT_VISIBLE:
exception_class = ElementNotVisibleException
elif status in ErrorCode.INVALID_ELEMENT_STATE:
exception_class = InvalidElementStateException
elif status in ErrorCode.INVALID_SELECTOR \
or status in ErrorCode.INVALID_XPATH_SELECTOR \
or status in ErrorCode.INVALID_XPATH_SELECTOR_RETURN_TYPER:
exception_class = InvalidSelectorException
elif status in ErrorCode.ELEMENT_IS_NOT_SELECTABLE:
exception_class = ElementNotSelectableException
elif status in ErrorCode.ELEMENT_NOT_INTERACTABLE:
exception_class = ElementNotInteractableException
elif status in ErrorCode.INVALID_COOKIE_DOMAIN:
exception_class = WebDriverException
elif status in ErrorCode.UNABLE_TO_SET_COOKIE:
exception_class = WebDriverException
elif status in ErrorCode.TIMEOUT:
exception_class = TimeoutException
elif status in ErrorCode.SCRIPT_TIMEOUT:
exception_class = TimeoutException
elif status in ErrorCode.UNKNOWN_ERROR:
exception_class = WebDriverException
elif status in ErrorCode.UNEXPECTED_ALERT_OPEN:
exception_class = UnexpectedAlertPresentException
elif status in ErrorCode.NO_ALERT_OPEN:
exception_class = NoAlertPresentException
elif status in ErrorCode.IME_NOT_AVAILABLE:
exception_class = ImeNotAvailableException
elif status in ErrorCode.IME_ENGINE_ACTIVATION_FAILED:
exception_class = ImeActivationFailedException
elif status in ErrorCode.MOVE_TARGET_OUT_OF_BOUNDS:
exception_class = MoveTargetOutOfBoundsException
else:
exception_class = WebDriverException
if value == '' or value is None:
value = response['value']
if isinstance(value, basestring):
if exception_class == ErrorInResponseException:
raise exception_class(response, value)
raise exception_class(value)
if message == "" and 'message' in value:
message = value['message']
screen = None
if 'screen' in value:
screen = value['screen']
stacktrace = None
if 'stackTrace' in value and value['stackTrace']:
stacktrace = []
try:
for frame in value['stackTrace']:
line = self._value_or_default(frame, 'lineNumber', '')
file = self._value_or_default(frame, 'fileName', '<anonymous>')
if line:
file = "%s:%s" % (file, line)
meth = self._value_or_default(frame, 'methodName', '<anonymous>')
if 'className' in frame:
meth = "%s.%s" % (frame['className'], meth)
msg = " at %s (%s)"
msg = msg % (meth, file)
stacktrace.append(msg)
except TypeError:
pass
if exception_class == ErrorInResponseException:
raise exception_class(response, message)
elif exception_class == UnexpectedAlertPresentException and 'alert' in value:
raise exception_class(message, screen, stacktrace, value['alert'].get('text'))
> raise exception_class(message, screen, stacktrace)
E selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: {"method":"xpath","selector":"//span[contains(@aria-activedescedant,'select2-DIRECTION-result')]"}
E Stacktrace:
E at FirefoxDriver.prototype.findElementInternal_ (file:///C:/Users/IV29B4~1.KAL/AppData/Local/Temp/tmp_xsdeqzr/extensions/fxdriver@googlecode.com/components/driver-component.js:10484)
E at fxdriver.Timer.prototype.setTimeout/<.notify (file:///C:/Users/IV29B4~1.KAL/AppData/Local/Temp/tmp_xsdeqzr/extensions/fxdriver@googlecode.com/components/driver-component.js:740)
..\..\..\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\errorhandler.py:194: NoSuchElementException
================================== FAILURES ===================================
_______________________ Add_campaign.test_Add_campaign ________________________
self = <Add_campaign.Add_campaign testMethod=test_Add_campaign>
def test_Add_campaign(self):
success = True
wd = self.wd
wd.get("https://toprussianbloggers.ru/")
wd.find_element_by_link_text("войти").click()
wd.find_element_by_id("system-auth-form-login").click()
wd.find_element_by_id("system-auth-form-login").clear()
wd.find_element_by_id("system-auth-form-login").send_keys("maria9@toprussianbloggers.ru")
wd.find_element_by_id("system-auth-form-password").click()
wd.find_element_by_id("system-auth-form-password").clear()
wd.find_element_by_id("system-auth-form-password").send_keys("123456")
wd.find_element_by_xpath("//div[@class='modal-body']/form/div[4]/input").click()
wd.find_element_by_link_text("Maria").click()
wd.find_element_by_link_text("Мои PR-кампании").click()
wd.find_element_by_link_text("Добавить новую кампанию").click()
wd.find_element_by_id("NAME").click()
wd.find_element_by_id("NAME").clear()
wd.find_element_by_id("NAME").send_keys("maria way")
wd.find_element_by_id("DATE_START").click()
wd.find_element_by_id("DATE_START").clear()
wd.find_element_by_id("DATE_START").send_keys("27.12.2017")
wd.find_element_by_id("DATE_END").click()
wd.find_element_by_id("DATE_END").click()
wd.find_element_by_id("DATE_END").clear()
wd.find_element_by_id("DATE_END").send_keys("29.12.2017")
wd.find_element_by_id("SET_TO").click()
wd.find_element_by_id("SET_TO").clear()
wd.find_element_by_id("SET_TO").send_keys("26.12.2017")
wd.find_element_by_css_selector("input.select2-search__field").click()
> wd.find_element_by_xpath("//span[contains(@aria-activedescedant,'select2-DIRECTION-result')]").click()
Add_campaign.py:50:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
..\..\..\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\webdriver.py:365: in find_element_by_xpath
return self.find_element(by=By.XPATH, value=xpath)
..\..\..\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\webdriver.py:843: in find_element
'value': value})['value']
..\..\..\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\webdriver.py:308: in execute
self.error_handler.check_response(response)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x0401F4B0>
response = {'status': 500, 'value': '{"name":"findElement","sessionId":"24f1e6ec-1113-4292-87a6-4537b1814ce4","status":7,"value":.../tmp_xsdeqzr/extensions/fxdriver@googlecode.com/components/driver-component.js","lineNumber":740,"columnNumber":5}]}}'}
def check_response(self, response):
"""
Checks that a JSON response from the WebDriver does not have an error.
:Args:
- response - The JSON response from the WebDriver server as a dictionary
object.
:Raises: If the response contains an error message.
"""
status = response.get('status', None)
if status is None or status == ErrorCode.SUCCESS:
return
value = None
message = response.get("message", "")
screen = response.get("screen", "")
stacktrace = None
if isinstance(status, int):
value_json = response.get('value', None)
if value_json and isinstance(value_json, basestring):
import json
try:
value = json.loads(value_json)
if len(value.keys()) == 1:
value = value['value']
status = value.get('error', None)
if status is None:
status = value["status"]
message = value["value"]
if not isinstance(message, basestring):
value = message
message = message.get('message')
else:
message = value.get('message', None)
except ValueError:
pass
exception_class = ErrorInResponseException
if status in ErrorCode.NO_SUCH_ELEMENT:
exception_class = NoSuchElementException
elif status in ErrorCode.NO_SUCH_FRAME:
exception_class = NoSuchFrameException
elif status in ErrorCode.NO_SUCH_WINDOW:
exception_class = NoSuchWindowException
elif status in ErrorCode.STALE_ELEMENT_REFERENCE:
exception_class = StaleElementReferenceException
elif status in ErrorCode.ELEMENT_NOT_VISIBLE:
exception_class = ElementNotVisibleException
elif status in ErrorCode.INVALID_ELEMENT_STATE:
exception_class = InvalidElementStateException
elif status in ErrorCode.INVALID_SELECTOR \
or status in ErrorCode.INVALID_XPATH_SELECTOR \
or status in ErrorCode.INVALID_XPATH_SELECTOR_RETURN_TYPER:
exception_class = InvalidSelectorException
elif status in ErrorCode.ELEMENT_IS_NOT_SELECTABLE:
exception_class = ElementNotSelectableException
elif status in ErrorCode.ELEMENT_NOT_INTERACTABLE:
exception_class = ElementNotInteractableException
elif status in ErrorCode.INVALID_COOKIE_DOMAIN:
exception_class = WebDriverException
elif status in ErrorCode.UNABLE_TO_SET_COOKIE:
exception_class = WebDriverException
elif status in ErrorCode.TIMEOUT:
exception_class = TimeoutException
elif status in ErrorCode.SCRIPT_TIMEOUT:
exception_class = TimeoutException
elif status in ErrorCode.UNKNOWN_ERROR:
exception_class = WebDriverException
elif status in ErrorCode.UNEXPECTED_ALERT_OPEN:
exception_class = UnexpectedAlertPresentException
elif status in ErrorCode.NO_ALERT_OPEN:
exception_class = NoAlertPresentException
elif status in ErrorCode.IME_NOT_AVAILABLE:
exception_class = ImeNotAvailableException
elif status in ErrorCode.IME_ENGINE_ACTIVATION_FAILED:
exception_class = ImeActivationFailedException
elif status in ErrorCode.MOVE_TARGET_OUT_OF_BOUNDS:
exception_class = MoveTargetOutOfBoundsException
else:
exception_class = WebDriverException
if value == '' or value is None:
value = response['value']
if isinstance(value, basestring):
if exception_class == ErrorInResponseException:
raise exception_class(response, value)
raise exception_class(value)
if message == "" and 'message' in value:
message = value['message']
screen = None
if 'screen' in value:
screen = value['screen']
stacktrace = None
if 'stackTrace' in value and value['stackTrace']:
stacktrace = []
try:
for frame in value['stackTrace']:
line = self._value_or_default(frame, 'lineNumber', '')
file = self._value_or_default(frame, 'fileName', '<anonymous>')
if line:
file = "%s:%s" % (file, line)
meth = self._value_or_default(frame, 'methodName', '<anonymous>')
if 'className' in frame:
meth = "%s.%s" % (frame['className'], meth)
msg = " at %s (%s)"
msg = msg % (meth, file)
stacktrace.append(msg)
except TypeError:
pass
if exception_class == ErrorInResponseException:
raise exception_class(response, message)
elif exception_class == UnexpectedAlertPresentException and 'alert' in value:
raise exception_class(message, screen, stacktrace, value['alert'].get('text'))
> raise exception_class(message, screen, stacktrace)
E selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: {"method":"xpath","selector":"//span[contains(@aria-activedescedant,'select2-DIRECTION-result')]"}
E Stacktrace:
E at FirefoxDriver.prototype.findElementInternal_ (file:///C:/Users/IV29B4~1.KAL/AppData/Local/Temp/tmp_xsdeqzr/extensions/fxdriver@googlecode.com/components/driver-component.js:10484)
E at fxdriver.Timer.prototype.setTimeout/<.notify (file:///C:/Users/IV29B4~1.KAL/AppData/Local/Temp/tmp_xsdeqzr/extensions/fxdriver@googlecode.com/components/driver-component.js:740)
..\..\..\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\errorhandler.py:194: NoSuchElementException
========================== 1 failed in 73.69 seconds ==========================
Process finished with exit code 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.