report.html

Report generated on 15-Feb-2023 at 11:52:34 by pytest-html v2.1.1

Environment

Packages {"pluggy": "0.13.1", "py": "1.9.0", "pytest": "6.1.0"}
Platform Windows-10-10.0.19041-SP0
Plugins {"allure-pytest": "2.8.18", "datadir": "1.3.1", "html": "2.1.1", "metadata": "1.10.0"}
Python 3.8.5

Summary

25 tests ran in 23.41 seconds.

0 passed, 0 skipped, 25 failed, 1 errors, 0 expected failures, 0 unexpected passes

Results

Result Test Duration Links
Error test_SL_footer_check.py::TestSLFooterCheck::test_SL_Footer_check[Get the iOS App]::teardown 0.01
self = <allure_commons._allure.fixture object at 0x000002189862DAF0>, args = (), kwargs = {}

def __call__(self, *args, **kwargs):
self.parameters = func_parameters(self._fixture_function, *args, **kwargs)

with self:
> return self._fixture_function(*args, **kwargs)

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\allure_commons\_allure.py:185:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
test_prod\conftest.py:126: in setup
pytest.driver.close()
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:688: in close
self.execute(Command.CLOSE)
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:321: in execute
self.error_handler.check_response(response)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x000002189862D550>
response = {'status': 500, 'value': '{"value":{"error":"disconnected","message":"disconnected: not connected to DevTools\\n (fai...\n\\tRtlGetAppContainerNamedObjectPath [0x77187BBE+286]\\n\\tRtlGetAppContainerNamedObjectPath [0x77187B8E+238]\\n"}}'}

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 = InvalidCookieDomainException
elif status in ErrorCode.UNABLE_TO_SET_COOKIE:
exception_class = UnableToSetCookieException
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
elif status in ErrorCode.JAVASCRIPT_ERROR:
exception_class = JavascriptException
elif status in ErrorCode.SESSION_NOT_CREATED:
exception_class = SessionNotCreatedException
elif status in ErrorCode.INVALID_ARGUMENT:
exception_class = InvalidArgumentException
elif status in ErrorCode.NO_SUCH_COOKIE:
exception_class = NoSuchCookieException
elif status in ErrorCode.UNABLE_TO_CAPTURE_SCREEN:
exception_class = ScreenshotException
elif status in ErrorCode.ELEMENT_CLICK_INTERCEPTED:
exception_class = ElementClickInterceptedException
elif status in ErrorCode.INSECURE_CERTIFICATE:
exception_class = InsecureCertificateException
elif status in ErrorCode.INVALID_COORDINATES:
exception_class = InvalidCoordinatesException
elif status in ErrorCode.INVALID_SESSION_ID:
exception_class = InvalidSessionIdException
elif status in ErrorCode.UNKNOWN_METHOD:
exception_class = UnknownMethodException
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:
alert_text = None
if 'data' in value:
alert_text = value['data'].get('text')
elif 'alert' in value:
alert_text = value['alert'].get('text')
raise exception_class(message, screen, stacktrace, alert_text)
> raise exception_class(message, screen, stacktrace)
E selenium.common.exceptions.WebDriverException: Message: disconnected: not connected to DevTools
E (failed to check if window was closed: disconnected: not connected to DevTools)
E (Session info: chrome=110.0.5481.100)

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py:242: WebDriverException
-------------------------------Captured log call--------------------------------
INFO  setup:test_SL_footer_check.py:230 Get the iOS App INFO  setup:test_SL_footer_check.py:236 URL for Get the iOS App is : https://apps.apple.com/app/simplilearn/id963042747?ls=1 INFO  setup:test_SL_footer_check.py:264 Exception Occurred Traceback (most recent call last): File "C:\test_repos\pre_sales_test_python\test_prod\test_SL_footer_check.py", line 239, in test_SL_Footer_check pytest.driver.get(pytest.config['prod_url']) File "c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 333, in get self.execute(Command.GET, {'url': url}) File "c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute self.error_handler.check_response(response) File "c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.NoSuchWindowException: Message: no such window: target window already closed from unknown error: web view not found (Session info: chrome=110.0.5481.100)
Failed test_SL_footer_check.py::TestSLFooterCheck::test_SL_Footer_check[Refer and Earn] 12.08
self = <test_SL_footer_check.TestSLFooterCheck object at 0x000002189862D040>, value = 'Refer and Earn'
initialize_pages = None

@pytest.mark.test_details("SLUB-T0000","high","Sl Footer Check","Pradeep")
@pytest.mark.parametrize("value",_create_parameterised_data())
def test_SL_Footer_check(self,value,initialize_pages):
try:
logging.info(value)
with open('sl_footer_check_test_data.csv', 'r') as csv_file:
csv_data = csv.reader(csv_file)
for line in csv_data:
if line[0] == value:
url = line[1]
logging.info(f"URL for {value} is : {url}")
break

pytest.driver.get(pytest.config['prod_url'])
selenium_helper.wait_for_page_to_load(20,pytest.config['prod_url'])
dynamic_locator = f"(//div[starts-with(@class,'col-md-2')]//a[@title='{value}'])[1]"
logging.info(f"Dynamic Locator : {dynamic_locator}")
time.sleep(3)
WebDriverWait(pytest.driver, 20).until(EC.element_to_be_clickable((By.XPATH, dynamic_locator))).scroll_to_element()
time.sleep(2)
default_window = pytest.driver.current_window_handle
pytest.driver.find_element(By.XPATH,dynamic_locator).click()
time.sleep(5)
> window_handle = list(pytest.driver.window_handles)

test_prod\test_SL_footer_check.py:249:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.chrome.webdriver.WebDriver (session="7643857c856eba21654096eb2db552ee")>

@property
def window_handles(self):
"""
Returns the handles of all windows within the current session.

:Usage:
driver.window_handles
"""
if self.w3c:
> return self.execute(Command.W3C_GET_WINDOW_HANDLES)['value']

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:724:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.chrome.webdriver.WebDriver (session="7643857c856eba21654096eb2db552ee")>
driver_command = 'w3cGetWindowHandles', params = {}

def execute(self, driver_command, params=None):
"""
Sends a command to be executed by a command.CommandExecutor.

:Args:
- driver_command: The name of the command to execute as a string.
- params: A dictionary of named parameters to send with the command.

:Returns:
The command's JSON response loaded into a dictionary object.
"""
if self.session_id is not None:
if not params:
params = {'sessionId': self.session_id}
elif 'sessionId' not in params:
params['sessionId'] = self.session_id

params = self._wrap_value(params)
response = self.command_executor.execute(driver_command, params)
if response:
> self.error_handler.check_response(response)

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:321:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x000002189862D550>
response = {'status': 500, 'value': '{"value":{"error":"disconnected","message":"disconnected: not connected to DevTools\\n (fai...\n\\tRtlGetAppContainerNamedObjectPath [0x77187BBE+286]\\n\\tRtlGetAppContainerNamedObjectPath [0x77187B8E+238]\\n"}}'}

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 = InvalidCookieDomainException
elif status in ErrorCode.UNABLE_TO_SET_COOKIE:
exception_class = UnableToSetCookieException
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
elif status in ErrorCode.JAVASCRIPT_ERROR:
exception_class = JavascriptException
elif status in ErrorCode.SESSION_NOT_CREATED:
exception_class = SessionNotCreatedException
elif status in ErrorCode.INVALID_ARGUMENT:
exception_class = InvalidArgumentException
elif status in ErrorCode.NO_SUCH_COOKIE:
exception_class = NoSuchCookieException
elif status in ErrorCode.UNABLE_TO_CAPTURE_SCREEN:
exception_class = ScreenshotException
elif status in ErrorCode.ELEMENT_CLICK_INTERCEPTED:
exception_class = ElementClickInterceptedException
elif status in ErrorCode.INSECURE_CERTIFICATE:
exception_class = InsecureCertificateException
elif status in ErrorCode.INVALID_COORDINATES:
exception_class = InvalidCoordinatesException
elif status in ErrorCode.INVALID_SESSION_ID:
exception_class = InvalidSessionIdException
elif status in ErrorCode.UNKNOWN_METHOD:
exception_class = UnknownMethodException
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:
alert_text = None
if 'data' in value:
alert_text = value['data'].get('text')
elif 'alert' in value:
alert_text = value['alert'].get('text')
raise exception_class(message, screen, stacktrace, alert_text)
> raise exception_class(message, screen, stacktrace)
E selenium.common.exceptions.WebDriverException: Message: disconnected: not connected to DevTools
E (failed to check if window was closed: disconnected: not connected to DevTools)
E (Session info: chrome=110.0.5481.100)

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py:242: WebDriverException

During handling of the above exception, another exception occurred:

self = <test_SL_footer_check.TestSLFooterCheck object at 0x000002189862D040>, value = 'Refer and Earn'
initialize_pages = None

@pytest.mark.test_details("SLUB-T0000","high","Sl Footer Check","Pradeep")
@pytest.mark.parametrize("value",_create_parameterised_data())
def test_SL_Footer_check(self,value,initialize_pages):
try:
logging.info(value)
with open('sl_footer_check_test_data.csv', 'r') as csv_file:
csv_data = csv.reader(csv_file)
for line in csv_data:
if line[0] == value:
url = line[1]
logging.info(f"URL for {value} is : {url}")
break

pytest.driver.get(pytest.config['prod_url'])
selenium_helper.wait_for_page_to_load(20,pytest.config['prod_url'])
dynamic_locator = f"(//div[starts-with(@class,'col-md-2')]//a[@title='{value}'])[1]"
logging.info(f"Dynamic Locator : {dynamic_locator}")
time.sleep(3)
WebDriverWait(pytest.driver, 20).until(EC.element_to_be_clickable((By.XPATH, dynamic_locator))).scroll_to_element()
time.sleep(2)
default_window = pytest.driver.current_window_handle
pytest.driver.find_element(By.XPATH,dynamic_locator).click()
time.sleep(5)
window_handle = list(pytest.driver.window_handles)
if len(window_handle) > 1:
pytest.driver.close()
pytest.driver.switch_to.window(window_handle[-1])

url_opened,message = self.check_redirection(value,url)
rows = [[value,url,url_opened,message]]
with open("Report.csv", 'a', newline='\n') as csvfile:
csvwriter = csv.writer(csvfile)
csvwriter.writerows(rows)
if 'Not Working' in message:
pytest.driver.get_screenshot_as_file(os.path.join(os.path.dirname(os.curdir), "report\screenshot", f"{__name__}_{value}.jpeg"))
pytest.fail()

except:
logging.info("Exception Occurred", exc_info=True)
> pytest.driver.get_screenshot_as_file(os.path.join(os.path.dirname(os.curdir), "report\screenshot", f"{__name__}_{value}.jpeg"))

test_prod\test_SL_footer_check.py:265:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:1032: in get_screenshot_as_file
png = self.get_screenshot_as_png()
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:1064: in get_screenshot_as_png
return base64.b64decode(self.get_screenshot_as_base64().encode('ascii'))
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:1074: in get_screenshot_as_base64
return self.execute(Command.SCREENSHOT)['value']
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:321: in execute
self.error_handler.check_response(response)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x000002189862D550>
response = {'status': 404, 'value': '{"value":{"error":"no such window","message":"no such window: target window already closed\\...\n\\tRtlGetAppContainerNamedObjectPath [0x77187BBE+286]\\n\\tRtlGetAppContainerNamedObjectPath [0x77187B8E+238]\\n"}}'}

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 = InvalidCookieDomainException
elif status in ErrorCode.UNABLE_TO_SET_COOKIE:
exception_class = UnableToSetCookieException
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
elif status in ErrorCode.JAVASCRIPT_ERROR:
exception_class = JavascriptException
elif status in ErrorCode.SESSION_NOT_CREATED:
exception_class = SessionNotCreatedException
elif status in ErrorCode.INVALID_ARGUMENT:
exception_class = InvalidArgumentException
elif status in ErrorCode.NO_SUCH_COOKIE:
exception_class = NoSuchCookieException
elif status in ErrorCode.UNABLE_TO_CAPTURE_SCREEN:
exception_class = ScreenshotException
elif status in ErrorCode.ELEMENT_CLICK_INTERCEPTED:
exception_class = ElementClickInterceptedException
elif status in ErrorCode.INSECURE_CERTIFICATE:
exception_class = InsecureCertificateException
elif status in ErrorCode.INVALID_COORDINATES:
exception_class = InvalidCoordinatesException
elif status in ErrorCode.INVALID_SESSION_ID:
exception_class = InvalidSessionIdException
elif status in ErrorCode.UNKNOWN_METHOD:
exception_class = UnknownMethodException
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:
alert_text = None
if 'data' in value:
alert_text = value['data'].get('text')
elif 'alert' in value:
alert_text = value['alert'].get('text')
raise exception_class(message, screen, stacktrace, alert_text)
> raise exception_class(message, screen, stacktrace)
E selenium.common.exceptions.NoSuchWindowException: Message: no such window: target window already closed
E from unknown error: web view not found
E (Session info: chrome=110.0.5481.100)

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py:242: NoSuchWindowException
-------------------------------Captured log call--------------------------------
INFO  setup:test_SL_footer_check.py:230 Refer and Earn INFO  setup:test_SL_footer_check.py:236 URL for Refer and Earn is : https://www.simplilearn.com/refer-and-earn INFO  setup:test_SL_footer_check.py:242 Dynamic Locator : (//div[starts-with(@class,'col-md-2')]//a[@title='Refer and Earn'])[1] INFO  setup:test_SL_footer_check.py:264 Exception Occurred Traceback (most recent call last): File "C:\test_repos\pre_sales_test_python\test_prod\test_SL_footer_check.py", line 249, in test_SL_Footer_check window_handle = list(pytest.driver.window_handles) File "c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 724, in window_handles return self.execute(Command.W3C_GET_WINDOW_HANDLES)['value'] File "c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute self.error_handler.check_response(response) File "c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.WebDriverException: Message: disconnected: not connected to DevTools (failed to check if window was closed: disconnected: not connected to DevTools) (Session info: chrome=110.0.5481.100)
Failed test_SL_footer_check.py::TestSLFooterCheck::test_SL_Footer_check[Facebook] 0.00
self = <test_SL_footer_check.TestSLFooterCheck object at 0x000002189857F250>, value = 'Facebook'
initialize_pages = None

@pytest.mark.test_details("SLUB-T0000","high","Sl Footer Check","Pradeep")
@pytest.mark.parametrize("value",_create_parameterised_data())
def test_SL_Footer_check(self,value,initialize_pages):
try:
logging.info(value)
with open('sl_footer_check_test_data.csv', 'r') as csv_file:
csv_data = csv.reader(csv_file)
for line in csv_data:
if line[0] == value:
url = line[1]
logging.info(f"URL for {value} is : {url}")
break

> pytest.driver.get(pytest.config['prod_url'])

test_prod\test_SL_footer_check.py:239:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.chrome.webdriver.WebDriver (session="7643857c856eba21654096eb2db552ee")>
url = 'https://www.simplilearn.com/'

def get(self, url):
"""
Loads a web page in the current browser session.
"""
> self.execute(Command.GET, {'url': url})

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:333:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.chrome.webdriver.WebDriver (session="7643857c856eba21654096eb2db552ee")>
driver_command = 'get', params = {'url': 'https://www.simplilearn.com/'}

def execute(self, driver_command, params=None):
"""
Sends a command to be executed by a command.CommandExecutor.

:Args:
- driver_command: The name of the command to execute as a string.
- params: A dictionary of named parameters to send with the command.

:Returns:
The command's JSON response loaded into a dictionary object.
"""
if self.session_id is not None:
if not params:
params = {'sessionId': self.session_id}
elif 'sessionId' not in params:
params['sessionId'] = self.session_id

params = self._wrap_value(params)
response = self.command_executor.execute(driver_command, params)
if response:
> self.error_handler.check_response(response)

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:321:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x000002189862D550>
response = {'status': 404, 'value': '{"value":{"error":"no such window","message":"no such window: target window already closed\\...\n\\tRtlGetAppContainerNamedObjectPath [0x77187BBE+286]\\n\\tRtlGetAppContainerNamedObjectPath [0x77187B8E+238]\\n"}}'}

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 = InvalidCookieDomainException
elif status in ErrorCode.UNABLE_TO_SET_COOKIE:
exception_class = UnableToSetCookieException
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
elif status in ErrorCode.JAVASCRIPT_ERROR:
exception_class = JavascriptException
elif status in ErrorCode.SESSION_NOT_CREATED:
exception_class = SessionNotCreatedException
elif status in ErrorCode.INVALID_ARGUMENT:
exception_class = InvalidArgumentException
elif status in ErrorCode.NO_SUCH_COOKIE:
exception_class = NoSuchCookieException
elif status in ErrorCode.UNABLE_TO_CAPTURE_SCREEN:
exception_class = ScreenshotException
elif status in ErrorCode.ELEMENT_CLICK_INTERCEPTED:
exception_class = ElementClickInterceptedException
elif status in ErrorCode.INSECURE_CERTIFICATE:
exception_class = InsecureCertificateException
elif status in ErrorCode.INVALID_COORDINATES:
exception_class = InvalidCoordinatesException
elif status in ErrorCode.INVALID_SESSION_ID:
exception_class = InvalidSessionIdException
elif status in ErrorCode.UNKNOWN_METHOD:
exception_class = UnknownMethodException
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:
alert_text = None
if 'data' in value:
alert_text = value['data'].get('text')
elif 'alert' in value:
alert_text = value['alert'].get('text')
raise exception_class(message, screen, stacktrace, alert_text)
> raise exception_class(message, screen, stacktrace)
E selenium.common.exceptions.NoSuchWindowException: Message: no such window: target window already closed
E from unknown error: web view not found
E (Session info: chrome=110.0.5481.100)

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py:242: NoSuchWindowException

During handling of the above exception, another exception occurred:

self = <test_SL_footer_check.TestSLFooterCheck object at 0x000002189857F250>, value = 'Facebook'
initialize_pages = None

@pytest.mark.test_details("SLUB-T0000","high","Sl Footer Check","Pradeep")
@pytest.mark.parametrize("value",_create_parameterised_data())
def test_SL_Footer_check(self,value,initialize_pages):
try:
logging.info(value)
with open('sl_footer_check_test_data.csv', 'r') as csv_file:
csv_data = csv.reader(csv_file)
for line in csv_data:
if line[0] == value:
url = line[1]
logging.info(f"URL for {value} is : {url}")
break

pytest.driver.get(pytest.config['prod_url'])
selenium_helper.wait_for_page_to_load(20,pytest.config['prod_url'])
dynamic_locator = f"(//div[starts-with(@class,'col-md-2')]//a[@title='{value}'])[1]"
logging.info(f"Dynamic Locator : {dynamic_locator}")
time.sleep(3)
WebDriverWait(pytest.driver, 20).until(EC.element_to_be_clickable((By.XPATH, dynamic_locator))).scroll_to_element()
time.sleep(2)
default_window = pytest.driver.current_window_handle
pytest.driver.find_element(By.XPATH,dynamic_locator).click()
time.sleep(5)
window_handle = list(pytest.driver.window_handles)
if len(window_handle) > 1:
pytest.driver.close()
pytest.driver.switch_to.window(window_handle[-1])

url_opened,message = self.check_redirection(value,url)
rows = [[value,url,url_opened,message]]
with open("Report.csv", 'a', newline='\n') as csvfile:
csvwriter = csv.writer(csvfile)
csvwriter.writerows(rows)
if 'Not Working' in message:
pytest.driver.get_screenshot_as_file(os.path.join(os.path.dirname(os.curdir), "report\screenshot", f"{__name__}_{value}.jpeg"))
pytest.fail()

except:
logging.info("Exception Occurred", exc_info=True)
> pytest.driver.get_screenshot_as_file(os.path.join(os.path.dirname(os.curdir), "report\screenshot", f"{__name__}_{value}.jpeg"))

test_prod\test_SL_footer_check.py:265:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:1032: in get_screenshot_as_file
png = self.get_screenshot_as_png()
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:1064: in get_screenshot_as_png
return base64.b64decode(self.get_screenshot_as_base64().encode('ascii'))
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:1074: in get_screenshot_as_base64
return self.execute(Command.SCREENSHOT)['value']
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:321: in execute
self.error_handler.check_response(response)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x000002189862D550>
response = {'status': 404, 'value': '{"value":{"error":"no such window","message":"no such window: target window already closed\\...\n\\tRtlGetAppContainerNamedObjectPath [0x77187BBE+286]\\n\\tRtlGetAppContainerNamedObjectPath [0x77187B8E+238]\\n"}}'}

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 = InvalidCookieDomainException
elif status in ErrorCode.UNABLE_TO_SET_COOKIE:
exception_class = UnableToSetCookieException
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
elif status in ErrorCode.JAVASCRIPT_ERROR:
exception_class = JavascriptException
elif status in ErrorCode.SESSION_NOT_CREATED:
exception_class = SessionNotCreatedException
elif status in ErrorCode.INVALID_ARGUMENT:
exception_class = InvalidArgumentException
elif status in ErrorCode.NO_SUCH_COOKIE:
exception_class = NoSuchCookieException
elif status in ErrorCode.UNABLE_TO_CAPTURE_SCREEN:
exception_class = ScreenshotException
elif status in ErrorCode.ELEMENT_CLICK_INTERCEPTED:
exception_class = ElementClickInterceptedException
elif status in ErrorCode.INSECURE_CERTIFICATE:
exception_class = InsecureCertificateException
elif status in ErrorCode.INVALID_COORDINATES:
exception_class = InvalidCoordinatesException
elif status in ErrorCode.INVALID_SESSION_ID:
exception_class = InvalidSessionIdException
elif status in ErrorCode.UNKNOWN_METHOD:
exception_class = UnknownMethodException
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:
alert_text = None
if 'data' in value:
alert_text = value['data'].get('text')
elif 'alert' in value:
alert_text = value['alert'].get('text')
raise exception_class(message, screen, stacktrace, alert_text)
> raise exception_class(message, screen, stacktrace)
E selenium.common.exceptions.NoSuchWindowException: Message: no such window: target window already closed
E from unknown error: web view not found
E (Session info: chrome=110.0.5481.100)

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py:242: NoSuchWindowException
-------------------------------Captured log call--------------------------------
INFO  setup:test_SL_footer_check.py:230 Facebook INFO  setup:test_SL_footer_check.py:236 URL for Facebook is : https://www.facebook.com/simplilearn INFO  setup:test_SL_footer_check.py:264 Exception Occurred Traceback (most recent call last): File "C:\test_repos\pre_sales_test_python\test_prod\test_SL_footer_check.py", line 239, in test_SL_Footer_check pytest.driver.get(pytest.config['prod_url']) File "c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 333, in get self.execute(Command.GET, {'url': url}) File "c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute self.error_handler.check_response(response) File "c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.NoSuchWindowException: Message: no such window: target window already closed from unknown error: web view not found (Session info: chrome=110.0.5481.100)
Failed test_SL_footer_check.py::TestSLFooterCheck::test_SL_Footer_check[Twitter] 0.00
self = <test_SL_footer_check.TestSLFooterCheck object at 0x000002189862DCD0>, value = 'Twitter', initialize_pages = None

@pytest.mark.test_details("SLUB-T0000","high","Sl Footer Check","Pradeep")
@pytest.mark.parametrize("value",_create_parameterised_data())
def test_SL_Footer_check(self,value,initialize_pages):
try:
logging.info(value)
with open('sl_footer_check_test_data.csv', 'r') as csv_file:
csv_data = csv.reader(csv_file)
for line in csv_data:
if line[0] == value:
url = line[1]
logging.info(f"URL for {value} is : {url}")
break

> pytest.driver.get(pytest.config['prod_url'])

test_prod\test_SL_footer_check.py:239:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.chrome.webdriver.WebDriver (session="7643857c856eba21654096eb2db552ee")>
url = 'https://www.simplilearn.com/'

def get(self, url):
"""
Loads a web page in the current browser session.
"""
> self.execute(Command.GET, {'url': url})

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:333:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.chrome.webdriver.WebDriver (session="7643857c856eba21654096eb2db552ee")>
driver_command = 'get', params = {'url': 'https://www.simplilearn.com/'}

def execute(self, driver_command, params=None):
"""
Sends a command to be executed by a command.CommandExecutor.

:Args:
- driver_command: The name of the command to execute as a string.
- params: A dictionary of named parameters to send with the command.

:Returns:
The command's JSON response loaded into a dictionary object.
"""
if self.session_id is not None:
if not params:
params = {'sessionId': self.session_id}
elif 'sessionId' not in params:
params['sessionId'] = self.session_id

params = self._wrap_value(params)
response = self.command_executor.execute(driver_command, params)
if response:
> self.error_handler.check_response(response)

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:321:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x000002189862D550>
response = {'status': 404, 'value': '{"value":{"error":"no such window","message":"no such window: target window already closed\\...\n\\tRtlGetAppContainerNamedObjectPath [0x77187BBE+286]\\n\\tRtlGetAppContainerNamedObjectPath [0x77187B8E+238]\\n"}}'}

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 = InvalidCookieDomainException
elif status in ErrorCode.UNABLE_TO_SET_COOKIE:
exception_class = UnableToSetCookieException
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
elif status in ErrorCode.JAVASCRIPT_ERROR:
exception_class = JavascriptException
elif status in ErrorCode.SESSION_NOT_CREATED:
exception_class = SessionNotCreatedException
elif status in ErrorCode.INVALID_ARGUMENT:
exception_class = InvalidArgumentException
elif status in ErrorCode.NO_SUCH_COOKIE:
exception_class = NoSuchCookieException
elif status in ErrorCode.UNABLE_TO_CAPTURE_SCREEN:
exception_class = ScreenshotException
elif status in ErrorCode.ELEMENT_CLICK_INTERCEPTED:
exception_class = ElementClickInterceptedException
elif status in ErrorCode.INSECURE_CERTIFICATE:
exception_class = InsecureCertificateException
elif status in ErrorCode.INVALID_COORDINATES:
exception_class = InvalidCoordinatesException
elif status in ErrorCode.INVALID_SESSION_ID:
exception_class = InvalidSessionIdException
elif status in ErrorCode.UNKNOWN_METHOD:
exception_class = UnknownMethodException
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:
alert_text = None
if 'data' in value:
alert_text = value['data'].get('text')
elif 'alert' in value:
alert_text = value['alert'].get('text')
raise exception_class(message, screen, stacktrace, alert_text)
> raise exception_class(message, screen, stacktrace)
E selenium.common.exceptions.NoSuchWindowException: Message: no such window: target window already closed
E from unknown error: web view not found
E (Session info: chrome=110.0.5481.100)

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py:242: NoSuchWindowException

During handling of the above exception, another exception occurred:

self = <test_SL_footer_check.TestSLFooterCheck object at 0x000002189862DCD0>, value = 'Twitter', initialize_pages = None

@pytest.mark.test_details("SLUB-T0000","high","Sl Footer Check","Pradeep")
@pytest.mark.parametrize("value",_create_parameterised_data())
def test_SL_Footer_check(self,value,initialize_pages):
try:
logging.info(value)
with open('sl_footer_check_test_data.csv', 'r') as csv_file:
csv_data = csv.reader(csv_file)
for line in csv_data:
if line[0] == value:
url = line[1]
logging.info(f"URL for {value} is : {url}")
break

pytest.driver.get(pytest.config['prod_url'])
selenium_helper.wait_for_page_to_load(20,pytest.config['prod_url'])
dynamic_locator = f"(//div[starts-with(@class,'col-md-2')]//a[@title='{value}'])[1]"
logging.info(f"Dynamic Locator : {dynamic_locator}")
time.sleep(3)
WebDriverWait(pytest.driver, 20).until(EC.element_to_be_clickable((By.XPATH, dynamic_locator))).scroll_to_element()
time.sleep(2)
default_window = pytest.driver.current_window_handle
pytest.driver.find_element(By.XPATH,dynamic_locator).click()
time.sleep(5)
window_handle = list(pytest.driver.window_handles)
if len(window_handle) > 1:
pytest.driver.close()
pytest.driver.switch_to.window(window_handle[-1])

url_opened,message = self.check_redirection(value,url)
rows = [[value,url,url_opened,message]]
with open("Report.csv", 'a', newline='\n') as csvfile:
csvwriter = csv.writer(csvfile)
csvwriter.writerows(rows)
if 'Not Working' in message:
pytest.driver.get_screenshot_as_file(os.path.join(os.path.dirname(os.curdir), "report\screenshot", f"{__name__}_{value}.jpeg"))
pytest.fail()

except:
logging.info("Exception Occurred", exc_info=True)
> pytest.driver.get_screenshot_as_file(os.path.join(os.path.dirname(os.curdir), "report\screenshot", f"{__name__}_{value}.jpeg"))

test_prod\test_SL_footer_check.py:265:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:1032: in get_screenshot_as_file
png = self.get_screenshot_as_png()
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:1064: in get_screenshot_as_png
return base64.b64decode(self.get_screenshot_as_base64().encode('ascii'))
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:1074: in get_screenshot_as_base64
return self.execute(Command.SCREENSHOT)['value']
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:321: in execute
self.error_handler.check_response(response)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x000002189862D550>
response = {'status': 404, 'value': '{"value":{"error":"no such window","message":"no such window: target window already closed\\...\n\\tRtlGetAppContainerNamedObjectPath [0x77187BBE+286]\\n\\tRtlGetAppContainerNamedObjectPath [0x77187B8E+238]\\n"}}'}

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 = InvalidCookieDomainException
elif status in ErrorCode.UNABLE_TO_SET_COOKIE:
exception_class = UnableToSetCookieException
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
elif status in ErrorCode.JAVASCRIPT_ERROR:
exception_class = JavascriptException
elif status in ErrorCode.SESSION_NOT_CREATED:
exception_class = SessionNotCreatedException
elif status in ErrorCode.INVALID_ARGUMENT:
exception_class = InvalidArgumentException
elif status in ErrorCode.NO_SUCH_COOKIE:
exception_class = NoSuchCookieException
elif status in ErrorCode.UNABLE_TO_CAPTURE_SCREEN:
exception_class = ScreenshotException
elif status in ErrorCode.ELEMENT_CLICK_INTERCEPTED:
exception_class = ElementClickInterceptedException
elif status in ErrorCode.INSECURE_CERTIFICATE:
exception_class = InsecureCertificateException
elif status in ErrorCode.INVALID_COORDINATES:
exception_class = InvalidCoordinatesException
elif status in ErrorCode.INVALID_SESSION_ID:
exception_class = InvalidSessionIdException
elif status in ErrorCode.UNKNOWN_METHOD:
exception_class = UnknownMethodException
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:
alert_text = None
if 'data' in value:
alert_text = value['data'].get('text')
elif 'alert' in value:
alert_text = value['alert'].get('text')
raise exception_class(message, screen, stacktrace, alert_text)
> raise exception_class(message, screen, stacktrace)
E selenium.common.exceptions.NoSuchWindowException: Message: no such window: target window already closed
E from unknown error: web view not found
E (Session info: chrome=110.0.5481.100)

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py:242: NoSuchWindowException
-------------------------------Captured log call--------------------------------
INFO  setup:test_SL_footer_check.py:230 Twitter INFO  setup:test_SL_footer_check.py:236 URL for Twitter is : https://www.twitter.com/simplilearn INFO  setup:test_SL_footer_check.py:264 Exception Occurred Traceback (most recent call last): File "C:\test_repos\pre_sales_test_python\test_prod\test_SL_footer_check.py", line 239, in test_SL_Footer_check pytest.driver.get(pytest.config['prod_url']) File "c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 333, in get self.execute(Command.GET, {'url': url}) File "c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute self.error_handler.check_response(response) File "c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.NoSuchWindowException: Message: no such window: target window already closed from unknown error: web view not found (Session info: chrome=110.0.5481.100)
Failed test_SL_footer_check.py::TestSLFooterCheck::test_SL_Footer_check[YouTube] 0.00
self = <test_SL_footer_check.TestSLFooterCheck object at 0x0000021898835580>, value = 'YouTube', initialize_pages = None

@pytest.mark.test_details("SLUB-T0000","high","Sl Footer Check","Pradeep")
@pytest.mark.parametrize("value",_create_parameterised_data())
def test_SL_Footer_check(self,value,initialize_pages):
try:
logging.info(value)
with open('sl_footer_check_test_data.csv', 'r') as csv_file:
csv_data = csv.reader(csv_file)
for line in csv_data:
if line[0] == value:
url = line[1]
logging.info(f"URL for {value} is : {url}")
break

> pytest.driver.get(pytest.config['prod_url'])

test_prod\test_SL_footer_check.py:239:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.chrome.webdriver.WebDriver (session="7643857c856eba21654096eb2db552ee")>
url = 'https://www.simplilearn.com/'

def get(self, url):
"""
Loads a web page in the current browser session.
"""
> self.execute(Command.GET, {'url': url})

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:333:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.chrome.webdriver.WebDriver (session="7643857c856eba21654096eb2db552ee")>
driver_command = 'get', params = {'url': 'https://www.simplilearn.com/'}

def execute(self, driver_command, params=None):
"""
Sends a command to be executed by a command.CommandExecutor.

:Args:
- driver_command: The name of the command to execute as a string.
- params: A dictionary of named parameters to send with the command.

:Returns:
The command's JSON response loaded into a dictionary object.
"""
if self.session_id is not None:
if not params:
params = {'sessionId': self.session_id}
elif 'sessionId' not in params:
params['sessionId'] = self.session_id

params = self._wrap_value(params)
response = self.command_executor.execute(driver_command, params)
if response:
> self.error_handler.check_response(response)

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:321:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x000002189862D550>
response = {'status': 404, 'value': '{"value":{"error":"no such window","message":"no such window: target window already closed\\...\n\\tRtlGetAppContainerNamedObjectPath [0x77187BBE+286]\\n\\tRtlGetAppContainerNamedObjectPath [0x77187B8E+238]\\n"}}'}

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 = InvalidCookieDomainException
elif status in ErrorCode.UNABLE_TO_SET_COOKIE:
exception_class = UnableToSetCookieException
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
elif status in ErrorCode.JAVASCRIPT_ERROR:
exception_class = JavascriptException
elif status in ErrorCode.SESSION_NOT_CREATED:
exception_class = SessionNotCreatedException
elif status in ErrorCode.INVALID_ARGUMENT:
exception_class = InvalidArgumentException
elif status in ErrorCode.NO_SUCH_COOKIE:
exception_class = NoSuchCookieException
elif status in ErrorCode.UNABLE_TO_CAPTURE_SCREEN:
exception_class = ScreenshotException
elif status in ErrorCode.ELEMENT_CLICK_INTERCEPTED:
exception_class = ElementClickInterceptedException
elif status in ErrorCode.INSECURE_CERTIFICATE:
exception_class = InsecureCertificateException
elif status in ErrorCode.INVALID_COORDINATES:
exception_class = InvalidCoordinatesException
elif status in ErrorCode.INVALID_SESSION_ID:
exception_class = InvalidSessionIdException
elif status in ErrorCode.UNKNOWN_METHOD:
exception_class = UnknownMethodException
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:
alert_text = None
if 'data' in value:
alert_text = value['data'].get('text')
elif 'alert' in value:
alert_text = value['alert'].get('text')
raise exception_class(message, screen, stacktrace, alert_text)
> raise exception_class(message, screen, stacktrace)
E selenium.common.exceptions.NoSuchWindowException: Message: no such window: target window already closed
E from unknown error: web view not found
E (Session info: chrome=110.0.5481.100)

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py:242: NoSuchWindowException

During handling of the above exception, another exception occurred:

self = <test_SL_footer_check.TestSLFooterCheck object at 0x0000021898835580>, value = 'YouTube', initialize_pages = None

@pytest.mark.test_details("SLUB-T0000","high","Sl Footer Check","Pradeep")
@pytest.mark.parametrize("value",_create_parameterised_data())
def test_SL_Footer_check(self,value,initialize_pages):
try:
logging.info(value)
with open('sl_footer_check_test_data.csv', 'r') as csv_file:
csv_data = csv.reader(csv_file)
for line in csv_data:
if line[0] == value:
url = line[1]
logging.info(f"URL for {value} is : {url}")
break

pytest.driver.get(pytest.config['prod_url'])
selenium_helper.wait_for_page_to_load(20,pytest.config['prod_url'])
dynamic_locator = f"(//div[starts-with(@class,'col-md-2')]//a[@title='{value}'])[1]"
logging.info(f"Dynamic Locator : {dynamic_locator}")
time.sleep(3)
WebDriverWait(pytest.driver, 20).until(EC.element_to_be_clickable((By.XPATH, dynamic_locator))).scroll_to_element()
time.sleep(2)
default_window = pytest.driver.current_window_handle
pytest.driver.find_element(By.XPATH,dynamic_locator).click()
time.sleep(5)
window_handle = list(pytest.driver.window_handles)
if len(window_handle) > 1:
pytest.driver.close()
pytest.driver.switch_to.window(window_handle[-1])

url_opened,message = self.check_redirection(value,url)
rows = [[value,url,url_opened,message]]
with open("Report.csv", 'a', newline='\n') as csvfile:
csvwriter = csv.writer(csvfile)
csvwriter.writerows(rows)
if 'Not Working' in message:
pytest.driver.get_screenshot_as_file(os.path.join(os.path.dirname(os.curdir), "report\screenshot", f"{__name__}_{value}.jpeg"))
pytest.fail()

except:
logging.info("Exception Occurred", exc_info=True)
> pytest.driver.get_screenshot_as_file(os.path.join(os.path.dirname(os.curdir), "report\screenshot", f"{__name__}_{value}.jpeg"))

test_prod\test_SL_footer_check.py:265:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:1032: in get_screenshot_as_file
png = self.get_screenshot_as_png()
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:1064: in get_screenshot_as_png
return base64.b64decode(self.get_screenshot_as_base64().encode('ascii'))
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:1074: in get_screenshot_as_base64
return self.execute(Command.SCREENSHOT)['value']
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:321: in execute
self.error_handler.check_response(response)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x000002189862D550>
response = {'status': 404, 'value': '{"value":{"error":"no such window","message":"no such window: target window already closed\\...\n\\tRtlGetAppContainerNamedObjectPath [0x77187BBE+286]\\n\\tRtlGetAppContainerNamedObjectPath [0x77187B8E+238]\\n"}}'}

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 = InvalidCookieDomainException
elif status in ErrorCode.UNABLE_TO_SET_COOKIE:
exception_class = UnableToSetCookieException
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
elif status in ErrorCode.JAVASCRIPT_ERROR:
exception_class = JavascriptException
elif status in ErrorCode.SESSION_NOT_CREATED:
exception_class = SessionNotCreatedException
elif status in ErrorCode.INVALID_ARGUMENT:
exception_class = InvalidArgumentException
elif status in ErrorCode.NO_SUCH_COOKIE:
exception_class = NoSuchCookieException
elif status in ErrorCode.UNABLE_TO_CAPTURE_SCREEN:
exception_class = ScreenshotException
elif status in ErrorCode.ELEMENT_CLICK_INTERCEPTED:
exception_class = ElementClickInterceptedException
elif status in ErrorCode.INSECURE_CERTIFICATE:
exception_class = InsecureCertificateException
elif status in ErrorCode.INVALID_COORDINATES:
exception_class = InvalidCoordinatesException
elif status in ErrorCode.INVALID_SESSION_ID:
exception_class = InvalidSessionIdException
elif status in ErrorCode.UNKNOWN_METHOD:
exception_class = UnknownMethodException
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:
alert_text = None
if 'data' in value:
alert_text = value['data'].get('text')
elif 'alert' in value:
alert_text = value['alert'].get('text')
raise exception_class(message, screen, stacktrace, alert_text)
> raise exception_class(message, screen, stacktrace)
E selenium.common.exceptions.NoSuchWindowException: Message: no such window: target window already closed
E from unknown error: web view not found
E (Session info: chrome=110.0.5481.100)

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py:242: NoSuchWindowException
-------------------------------Captured log call--------------------------------
INFO  setup:test_SL_footer_check.py:230 YouTube INFO  setup:test_SL_footer_check.py:236 URL for YouTube is : https://www.youtube.com/user/Simplilearn INFO  setup:test_SL_footer_check.py:264 Exception Occurred Traceback (most recent call last): File "C:\test_repos\pre_sales_test_python\test_prod\test_SL_footer_check.py", line 239, in test_SL_Footer_check pytest.driver.get(pytest.config['prod_url']) File "c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 333, in get self.execute(Command.GET, {'url': url}) File "c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute self.error_handler.check_response(response) File "c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.NoSuchWindowException: Message: no such window: target window already closed from unknown error: web view not found (Session info: chrome=110.0.5481.100)
Failed test_SL_footer_check.py::TestSLFooterCheck::test_SL_Footer_check[LinkedIn] 0.00
self = <test_SL_footer_check.TestSLFooterCheck object at 0x00000218989C74F0>, value = 'LinkedIn'
initialize_pages = None

@pytest.mark.test_details("SLUB-T0000","high","Sl Footer Check","Pradeep")
@pytest.mark.parametrize("value",_create_parameterised_data())
def test_SL_Footer_check(self,value,initialize_pages):
try:
logging.info(value)
with open('sl_footer_check_test_data.csv', 'r') as csv_file:
csv_data = csv.reader(csv_file)
for line in csv_data:
if line[0] == value:
url = line[1]
logging.info(f"URL for {value} is : {url}")
break

> pytest.driver.get(pytest.config['prod_url'])

test_prod\test_SL_footer_check.py:239:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.chrome.webdriver.WebDriver (session="7643857c856eba21654096eb2db552ee")>
url = 'https://www.simplilearn.com/'

def get(self, url):
"""
Loads a web page in the current browser session.
"""
> self.execute(Command.GET, {'url': url})

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:333:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.chrome.webdriver.WebDriver (session="7643857c856eba21654096eb2db552ee")>
driver_command = 'get', params = {'url': 'https://www.simplilearn.com/'}

def execute(self, driver_command, params=None):
"""
Sends a command to be executed by a command.CommandExecutor.

:Args:
- driver_command: The name of the command to execute as a string.
- params: A dictionary of named parameters to send with the command.

:Returns:
The command's JSON response loaded into a dictionary object.
"""
if self.session_id is not None:
if not params:
params = {'sessionId': self.session_id}
elif 'sessionId' not in params:
params['sessionId'] = self.session_id

params = self._wrap_value(params)
response = self.command_executor.execute(driver_command, params)
if response:
> self.error_handler.check_response(response)

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:321:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x000002189862D550>
response = {'status': 404, 'value': '{"value":{"error":"no such window","message":"no such window: target window already closed\\...\n\\tRtlGetAppContainerNamedObjectPath [0x77187BBE+286]\\n\\tRtlGetAppContainerNamedObjectPath [0x77187B8E+238]\\n"}}'}

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 = InvalidCookieDomainException
elif status in ErrorCode.UNABLE_TO_SET_COOKIE:
exception_class = UnableToSetCookieException
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
elif status in ErrorCode.JAVASCRIPT_ERROR:
exception_class = JavascriptException
elif status in ErrorCode.SESSION_NOT_CREATED:
exception_class = SessionNotCreatedException
elif status in ErrorCode.INVALID_ARGUMENT:
exception_class = InvalidArgumentException
elif status in ErrorCode.NO_SUCH_COOKIE:
exception_class = NoSuchCookieException
elif status in ErrorCode.UNABLE_TO_CAPTURE_SCREEN:
exception_class = ScreenshotException
elif status in ErrorCode.ELEMENT_CLICK_INTERCEPTED:
exception_class = ElementClickInterceptedException
elif status in ErrorCode.INSECURE_CERTIFICATE:
exception_class = InsecureCertificateException
elif status in ErrorCode.INVALID_COORDINATES:
exception_class = InvalidCoordinatesException
elif status in ErrorCode.INVALID_SESSION_ID:
exception_class = InvalidSessionIdException
elif status in ErrorCode.UNKNOWN_METHOD:
exception_class = UnknownMethodException
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:
alert_text = None
if 'data' in value:
alert_text = value['data'].get('text')
elif 'alert' in value:
alert_text = value['alert'].get('text')
raise exception_class(message, screen, stacktrace, alert_text)
> raise exception_class(message, screen, stacktrace)
E selenium.common.exceptions.NoSuchWindowException: Message: no such window: target window already closed
E from unknown error: web view not found
E (Session info: chrome=110.0.5481.100)

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py:242: NoSuchWindowException

During handling of the above exception, another exception occurred:

self = <test_SL_footer_check.TestSLFooterCheck object at 0x00000218989C74F0>, value = 'LinkedIn'
initialize_pages = None

@pytest.mark.test_details("SLUB-T0000","high","Sl Footer Check","Pradeep")
@pytest.mark.parametrize("value",_create_parameterised_data())
def test_SL_Footer_check(self,value,initialize_pages):
try:
logging.info(value)
with open('sl_footer_check_test_data.csv', 'r') as csv_file:
csv_data = csv.reader(csv_file)
for line in csv_data:
if line[0] == value:
url = line[1]
logging.info(f"URL for {value} is : {url}")
break

pytest.driver.get(pytest.config['prod_url'])
selenium_helper.wait_for_page_to_load(20,pytest.config['prod_url'])
dynamic_locator = f"(//div[starts-with(@class,'col-md-2')]//a[@title='{value}'])[1]"
logging.info(f"Dynamic Locator : {dynamic_locator}")
time.sleep(3)
WebDriverWait(pytest.driver, 20).until(EC.element_to_be_clickable((By.XPATH, dynamic_locator))).scroll_to_element()
time.sleep(2)
default_window = pytest.driver.current_window_handle
pytest.driver.find_element(By.XPATH,dynamic_locator).click()
time.sleep(5)
window_handle = list(pytest.driver.window_handles)
if len(window_handle) > 1:
pytest.driver.close()
pytest.driver.switch_to.window(window_handle[-1])

url_opened,message = self.check_redirection(value,url)
rows = [[value,url,url_opened,message]]
with open("Report.csv", 'a', newline='\n') as csvfile:
csvwriter = csv.writer(csvfile)
csvwriter.writerows(rows)
if 'Not Working' in message:
pytest.driver.get_screenshot_as_file(os.path.join(os.path.dirname(os.curdir), "report\screenshot", f"{__name__}_{value}.jpeg"))
pytest.fail()

except:
logging.info("Exception Occurred", exc_info=True)
> pytest.driver.get_screenshot_as_file(os.path.join(os.path.dirname(os.curdir), "report\screenshot", f"{__name__}_{value}.jpeg"))

test_prod\test_SL_footer_check.py:265:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:1032: in get_screenshot_as_file
png = self.get_screenshot_as_png()
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:1064: in get_screenshot_as_png
return base64.b64decode(self.get_screenshot_as_base64().encode('ascii'))
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:1074: in get_screenshot_as_base64
return self.execute(Command.SCREENSHOT)['value']
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:321: in execute
self.error_handler.check_response(response)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x000002189862D550>
response = {'status': 404, 'value': '{"value":{"error":"no such window","message":"no such window: target window already closed\\...\n\\tRtlGetAppContainerNamedObjectPath [0x77187BBE+286]\\n\\tRtlGetAppContainerNamedObjectPath [0x77187B8E+238]\\n"}}'}

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 = InvalidCookieDomainException
elif status in ErrorCode.UNABLE_TO_SET_COOKIE:
exception_class = UnableToSetCookieException
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
elif status in ErrorCode.JAVASCRIPT_ERROR:
exception_class = JavascriptException
elif status in ErrorCode.SESSION_NOT_CREATED:
exception_class = SessionNotCreatedException
elif status in ErrorCode.INVALID_ARGUMENT:
exception_class = InvalidArgumentException
elif status in ErrorCode.NO_SUCH_COOKIE:
exception_class = NoSuchCookieException
elif status in ErrorCode.UNABLE_TO_CAPTURE_SCREEN:
exception_class = ScreenshotException
elif status in ErrorCode.ELEMENT_CLICK_INTERCEPTED:
exception_class = ElementClickInterceptedException
elif status in ErrorCode.INSECURE_CERTIFICATE:
exception_class = InsecureCertificateException
elif status in ErrorCode.INVALID_COORDINATES:
exception_class = InvalidCoordinatesException
elif status in ErrorCode.INVALID_SESSION_ID:
exception_class = InvalidSessionIdException
elif status in ErrorCode.UNKNOWN_METHOD:
exception_class = UnknownMethodException
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:
alert_text = None
if 'data' in value:
alert_text = value['data'].get('text')
elif 'alert' in value:
alert_text = value['alert'].get('text')
raise exception_class(message, screen, stacktrace, alert_text)
> raise exception_class(message, screen, stacktrace)
E selenium.common.exceptions.NoSuchWindowException: Message: no such window: target window already closed
E from unknown error: web view not found
E (Session info: chrome=110.0.5481.100)

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py:242: NoSuchWindowException
-------------------------------Captured log call--------------------------------
INFO  setup:test_SL_footer_check.py:230 LinkedIn INFO  setup:test_SL_footer_check.py:236 URL for LinkedIn is : https://www.linkedin.com/company/simplilearn INFO  setup:test_SL_footer_check.py:264 Exception Occurred Traceback (most recent call last): File "C:\test_repos\pre_sales_test_python\test_prod\test_SL_footer_check.py", line 239, in test_SL_Footer_check pytest.driver.get(pytest.config['prod_url']) File "c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 333, in get self.execute(Command.GET, {'url': url}) File "c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute self.error_handler.check_response(response) File "c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.NoSuchWindowException: Message: no such window: target window already closed from unknown error: web view not found (Session info: chrome=110.0.5481.100)
Failed test_SL_footer_check.py::TestSLFooterCheck::test_SL_Footer_check[Telegram] 0.00
self = <test_SL_footer_check.TestSLFooterCheck object at 0x00000218989CAFD0>, value = 'Telegram'
initialize_pages = None

@pytest.mark.test_details("SLUB-T0000","high","Sl Footer Check","Pradeep")
@pytest.mark.parametrize("value",_create_parameterised_data())
def test_SL_Footer_check(self,value,initialize_pages):
try:
logging.info(value)
with open('sl_footer_check_test_data.csv', 'r') as csv_file:
csv_data = csv.reader(csv_file)
for line in csv_data:
if line[0] == value:
url = line[1]
logging.info(f"URL for {value} is : {url}")
break

> pytest.driver.get(pytest.config['prod_url'])

test_prod\test_SL_footer_check.py:239:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.chrome.webdriver.WebDriver (session="7643857c856eba21654096eb2db552ee")>
url = 'https://www.simplilearn.com/'

def get(self, url):
"""
Loads a web page in the current browser session.
"""
> self.execute(Command.GET, {'url': url})

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:333:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.chrome.webdriver.WebDriver (session="7643857c856eba21654096eb2db552ee")>
driver_command = 'get', params = {'url': 'https://www.simplilearn.com/'}

def execute(self, driver_command, params=None):
"""
Sends a command to be executed by a command.CommandExecutor.

:Args:
- driver_command: The name of the command to execute as a string.
- params: A dictionary of named parameters to send with the command.

:Returns:
The command's JSON response loaded into a dictionary object.
"""
if self.session_id is not None:
if not params:
params = {'sessionId': self.session_id}
elif 'sessionId' not in params:
params['sessionId'] = self.session_id

params = self._wrap_value(params)
response = self.command_executor.execute(driver_command, params)
if response:
> self.error_handler.check_response(response)

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:321:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x000002189862D550>
response = {'status': 404, 'value': '{"value":{"error":"no such window","message":"no such window: target window already closed\\...\n\\tRtlGetAppContainerNamedObjectPath [0x77187BBE+286]\\n\\tRtlGetAppContainerNamedObjectPath [0x77187B8E+238]\\n"}}'}

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 = InvalidCookieDomainException
elif status in ErrorCode.UNABLE_TO_SET_COOKIE:
exception_class = UnableToSetCookieException
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
elif status in ErrorCode.JAVASCRIPT_ERROR:
exception_class = JavascriptException
elif status in ErrorCode.SESSION_NOT_CREATED:
exception_class = SessionNotCreatedException
elif status in ErrorCode.INVALID_ARGUMENT:
exception_class = InvalidArgumentException
elif status in ErrorCode.NO_SUCH_COOKIE:
exception_class = NoSuchCookieException
elif status in ErrorCode.UNABLE_TO_CAPTURE_SCREEN:
exception_class = ScreenshotException
elif status in ErrorCode.ELEMENT_CLICK_INTERCEPTED:
exception_class = ElementClickInterceptedException
elif status in ErrorCode.INSECURE_CERTIFICATE:
exception_class = InsecureCertificateException
elif status in ErrorCode.INVALID_COORDINATES:
exception_class = InvalidCoordinatesException
elif status in ErrorCode.INVALID_SESSION_ID:
exception_class = InvalidSessionIdException
elif status in ErrorCode.UNKNOWN_METHOD:
exception_class = UnknownMethodException
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:
alert_text = None
if 'data' in value:
alert_text = value['data'].get('text')
elif 'alert' in value:
alert_text = value['alert'].get('text')
raise exception_class(message, screen, stacktrace, alert_text)
> raise exception_class(message, screen, stacktrace)
E selenium.common.exceptions.NoSuchWindowException: Message: no such window: target window already closed
E from unknown error: web view not found
E (Session info: chrome=110.0.5481.100)

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py:242: NoSuchWindowException

During handling of the above exception, another exception occurred:

self = <test_SL_footer_check.TestSLFooterCheck object at 0x00000218989CAFD0>, value = 'Telegram'
initialize_pages = None

@pytest.mark.test_details("SLUB-T0000","high","Sl Footer Check","Pradeep")
@pytest.mark.parametrize("value",_create_parameterised_data())
def test_SL_Footer_check(self,value,initialize_pages):
try:
logging.info(value)
with open('sl_footer_check_test_data.csv', 'r') as csv_file:
csv_data = csv.reader(csv_file)
for line in csv_data:
if line[0] == value:
url = line[1]
logging.info(f"URL for {value} is : {url}")
break

pytest.driver.get(pytest.config['prod_url'])
selenium_helper.wait_for_page_to_load(20,pytest.config['prod_url'])
dynamic_locator = f"(//div[starts-with(@class,'col-md-2')]//a[@title='{value}'])[1]"
logging.info(f"Dynamic Locator : {dynamic_locator}")
time.sleep(3)
WebDriverWait(pytest.driver, 20).until(EC.element_to_be_clickable((By.XPATH, dynamic_locator))).scroll_to_element()
time.sleep(2)
default_window = pytest.driver.current_window_handle
pytest.driver.find_element(By.XPATH,dynamic_locator).click()
time.sleep(5)
window_handle = list(pytest.driver.window_handles)
if len(window_handle) > 1:
pytest.driver.close()
pytest.driver.switch_to.window(window_handle[-1])

url_opened,message = self.check_redirection(value,url)
rows = [[value,url,url_opened,message]]
with open("Report.csv", 'a', newline='\n') as csvfile:
csvwriter = csv.writer(csvfile)
csvwriter.writerows(rows)
if 'Not Working' in message:
pytest.driver.get_screenshot_as_file(os.path.join(os.path.dirname(os.curdir), "report\screenshot", f"{__name__}_{value}.jpeg"))
pytest.fail()

except:
logging.info("Exception Occurred", exc_info=True)
> pytest.driver.get_screenshot_as_file(os.path.join(os.path.dirname(os.curdir), "report\screenshot", f"{__name__}_{value}.jpeg"))

test_prod\test_SL_footer_check.py:265:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:1032: in get_screenshot_as_file
png = self.get_screenshot_as_png()
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:1064: in get_screenshot_as_png
return base64.b64decode(self.get_screenshot_as_base64().encode('ascii'))
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:1074: in get_screenshot_as_base64
return self.execute(Command.SCREENSHOT)['value']
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:321: in execute
self.error_handler.check_response(response)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x000002189862D550>
response = {'status': 404, 'value': '{"value":{"error":"no such window","message":"no such window: target window already closed\\...\n\\tRtlGetAppContainerNamedObjectPath [0x77187BBE+286]\\n\\tRtlGetAppContainerNamedObjectPath [0x77187B8E+238]\\n"}}'}

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 = InvalidCookieDomainException
elif status in ErrorCode.UNABLE_TO_SET_COOKIE:
exception_class = UnableToSetCookieException
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
elif status in ErrorCode.JAVASCRIPT_ERROR:
exception_class = JavascriptException
elif status in ErrorCode.SESSION_NOT_CREATED:
exception_class = SessionNotCreatedException
elif status in ErrorCode.INVALID_ARGUMENT:
exception_class = InvalidArgumentException
elif status in ErrorCode.NO_SUCH_COOKIE:
exception_class = NoSuchCookieException
elif status in ErrorCode.UNABLE_TO_CAPTURE_SCREEN:
exception_class = ScreenshotException
elif status in ErrorCode.ELEMENT_CLICK_INTERCEPTED:
exception_class = ElementClickInterceptedException
elif status in ErrorCode.INSECURE_CERTIFICATE:
exception_class = InsecureCertificateException
elif status in ErrorCode.INVALID_COORDINATES:
exception_class = InvalidCoordinatesException
elif status in ErrorCode.INVALID_SESSION_ID:
exception_class = InvalidSessionIdException
elif status in ErrorCode.UNKNOWN_METHOD:
exception_class = UnknownMethodException
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:
alert_text = None
if 'data' in value:
alert_text = value['data'].get('text')
elif 'alert' in value:
alert_text = value['alert'].get('text')
raise exception_class(message, screen, stacktrace, alert_text)
> raise exception_class(message, screen, stacktrace)
E selenium.common.exceptions.NoSuchWindowException: Message: no such window: target window already closed
E from unknown error: web view not found
E (Session info: chrome=110.0.5481.100)

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py:242: NoSuchWindowException
-------------------------------Captured log call--------------------------------
INFO  setup:test_SL_footer_check.py:230 Telegram INFO  setup:test_SL_footer_check.py:236 URL for Telegram is : https://web.telegram.org/#/im?p=@simplilearnupdates INFO  setup:test_SL_footer_check.py:264 Exception Occurred Traceback (most recent call last): File "C:\test_repos\pre_sales_test_python\test_prod\test_SL_footer_check.py", line 239, in test_SL_Footer_check pytest.driver.get(pytest.config['prod_url']) File "c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 333, in get self.execute(Command.GET, {'url': url}) File "c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute self.error_handler.check_response(response) File "c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.NoSuchWindowException: Message: no such window: target window already closed from unknown error: web view not found (Session info: chrome=110.0.5481.100)
Failed test_SL_footer_check.py::TestSLFooterCheck::test_SL_Footer_check[Instagram] 0.00
self = <test_SL_footer_check.TestSLFooterCheck object at 0x0000021898A03D60>, value = 'Instagram'
initialize_pages = None

@pytest.mark.test_details("SLUB-T0000","high","Sl Footer Check","Pradeep")
@pytest.mark.parametrize("value",_create_parameterised_data())
def test_SL_Footer_check(self,value,initialize_pages):
try:
logging.info(value)
with open('sl_footer_check_test_data.csv', 'r') as csv_file:
csv_data = csv.reader(csv_file)
for line in csv_data:
if line[0] == value:
url = line[1]
logging.info(f"URL for {value} is : {url}")
break

> pytest.driver.get(pytest.config['prod_url'])

test_prod\test_SL_footer_check.py:239:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.chrome.webdriver.WebDriver (session="7643857c856eba21654096eb2db552ee")>
url = 'https://www.simplilearn.com/'

def get(self, url):
"""
Loads a web page in the current browser session.
"""
> self.execute(Command.GET, {'url': url})

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:333:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.chrome.webdriver.WebDriver (session="7643857c856eba21654096eb2db552ee")>
driver_command = 'get', params = {'url': 'https://www.simplilearn.com/'}

def execute(self, driver_command, params=None):
"""
Sends a command to be executed by a command.CommandExecutor.

:Args:
- driver_command: The name of the command to execute as a string.
- params: A dictionary of named parameters to send with the command.

:Returns:
The command's JSON response loaded into a dictionary object.
"""
if self.session_id is not None:
if not params:
params = {'sessionId': self.session_id}
elif 'sessionId' not in params:
params['sessionId'] = self.session_id

params = self._wrap_value(params)
response = self.command_executor.execute(driver_command, params)
if response:
> self.error_handler.check_response(response)

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:321:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x000002189862D550>
response = {'status': 404, 'value': '{"value":{"error":"no such window","message":"no such window: target window already closed\\...\n\\tRtlGetAppContainerNamedObjectPath [0x77187BBE+286]\\n\\tRtlGetAppContainerNamedObjectPath [0x77187B8E+238]\\n"}}'}

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 = InvalidCookieDomainException
elif status in ErrorCode.UNABLE_TO_SET_COOKIE:
exception_class = UnableToSetCookieException
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
elif status in ErrorCode.JAVASCRIPT_ERROR:
exception_class = JavascriptException
elif status in ErrorCode.SESSION_NOT_CREATED:
exception_class = SessionNotCreatedException
elif status in ErrorCode.INVALID_ARGUMENT:
exception_class = InvalidArgumentException
elif status in ErrorCode.NO_SUCH_COOKIE:
exception_class = NoSuchCookieException
elif status in ErrorCode.UNABLE_TO_CAPTURE_SCREEN:
exception_class = ScreenshotException
elif status in ErrorCode.ELEMENT_CLICK_INTERCEPTED:
exception_class = ElementClickInterceptedException
elif status in ErrorCode.INSECURE_CERTIFICATE:
exception_class = InsecureCertificateException
elif status in ErrorCode.INVALID_COORDINATES:
exception_class = InvalidCoordinatesException
elif status in ErrorCode.INVALID_SESSION_ID:
exception_class = InvalidSessionIdException
elif status in ErrorCode.UNKNOWN_METHOD:
exception_class = UnknownMethodException
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:
alert_text = None
if 'data' in value:
alert_text = value['data'].get('text')
elif 'alert' in value:
alert_text = value['alert'].get('text')
raise exception_class(message, screen, stacktrace, alert_text)
> raise exception_class(message, screen, stacktrace)
E selenium.common.exceptions.NoSuchWindowException: Message: no such window: target window already closed
E from unknown error: web view not found
E (Session info: chrome=110.0.5481.100)

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py:242: NoSuchWindowException

During handling of the above exception, another exception occurred:

self = <test_SL_footer_check.TestSLFooterCheck object at 0x0000021898A03D60>, value = 'Instagram'
initialize_pages = None

@pytest.mark.test_details("SLUB-T0000","high","Sl Footer Check","Pradeep")
@pytest.mark.parametrize("value",_create_parameterised_data())
def test_SL_Footer_check(self,value,initialize_pages):
try:
logging.info(value)
with open('sl_footer_check_test_data.csv', 'r') as csv_file:
csv_data = csv.reader(csv_file)
for line in csv_data:
if line[0] == value:
url = line[1]
logging.info(f"URL for {value} is : {url}")
break

pytest.driver.get(pytest.config['prod_url'])
selenium_helper.wait_for_page_to_load(20,pytest.config['prod_url'])
dynamic_locator = f"(//div[starts-with(@class,'col-md-2')]//a[@title='{value}'])[1]"
logging.info(f"Dynamic Locator : {dynamic_locator}")
time.sleep(3)
WebDriverWait(pytest.driver, 20).until(EC.element_to_be_clickable((By.XPATH, dynamic_locator))).scroll_to_element()
time.sleep(2)
default_window = pytest.driver.current_window_handle
pytest.driver.find_element(By.XPATH,dynamic_locator).click()
time.sleep(5)
window_handle = list(pytest.driver.window_handles)
if len(window_handle) > 1:
pytest.driver.close()
pytest.driver.switch_to.window(window_handle[-1])

url_opened,message = self.check_redirection(value,url)
rows = [[value,url,url_opened,message]]
with open("Report.csv", 'a', newline='\n') as csvfile:
csvwriter = csv.writer(csvfile)
csvwriter.writerows(rows)
if 'Not Working' in message:
pytest.driver.get_screenshot_as_file(os.path.join(os.path.dirname(os.curdir), "report\screenshot", f"{__name__}_{value}.jpeg"))
pytest.fail()

except:
logging.info("Exception Occurred", exc_info=True)
> pytest.driver.get_screenshot_as_file(os.path.join(os.path.dirname(os.curdir), "report\screenshot", f"{__name__}_{value}.jpeg"))

test_prod\test_SL_footer_check.py:265:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:1032: in get_screenshot_as_file
png = self.get_screenshot_as_png()
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:1064: in get_screenshot_as_png
return base64.b64decode(self.get_screenshot_as_base64().encode('ascii'))
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:1074: in get_screenshot_as_base64
return self.execute(Command.SCREENSHOT)['value']
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:321: in execute
self.error_handler.check_response(response)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x000002189862D550>
response = {'status': 404, 'value': '{"value":{"error":"no such window","message":"no such window: target window already closed\\...\n\\tRtlGetAppContainerNamedObjectPath [0x77187BBE+286]\\n\\tRtlGetAppContainerNamedObjectPath [0x77187B8E+238]\\n"}}'}

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 = InvalidCookieDomainException
elif status in ErrorCode.UNABLE_TO_SET_COOKIE:
exception_class = UnableToSetCookieException
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
elif status in ErrorCode.JAVASCRIPT_ERROR:
exception_class = JavascriptException
elif status in ErrorCode.SESSION_NOT_CREATED:
exception_class = SessionNotCreatedException
elif status in ErrorCode.INVALID_ARGUMENT:
exception_class = InvalidArgumentException
elif status in ErrorCode.NO_SUCH_COOKIE:
exception_class = NoSuchCookieException
elif status in ErrorCode.UNABLE_TO_CAPTURE_SCREEN:
exception_class = ScreenshotException
elif status in ErrorCode.ELEMENT_CLICK_INTERCEPTED:
exception_class = ElementClickInterceptedException
elif status in ErrorCode.INSECURE_CERTIFICATE:
exception_class = InsecureCertificateException
elif status in ErrorCode.INVALID_COORDINATES:
exception_class = InvalidCoordinatesException
elif status in ErrorCode.INVALID_SESSION_ID:
exception_class = InvalidSessionIdException
elif status in ErrorCode.UNKNOWN_METHOD:
exception_class = UnknownMethodException
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:
alert_text = None
if 'data' in value:
alert_text = value['data'].get('text')
elif 'alert' in value:
alert_text = value['alert'].get('text')
raise exception_class(message, screen, stacktrace, alert_text)
> raise exception_class(message, screen, stacktrace)
E selenium.common.exceptions.NoSuchWindowException: Message: no such window: target window already closed
E from unknown error: web view not found
E (Session info: chrome=110.0.5481.100)

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py:242: NoSuchWindowException
-------------------------------Captured log call--------------------------------
INFO  setup:test_SL_footer_check.py:230 Instagram INFO  setup:test_SL_footer_check.py:236 URL for Instagram is : https://www.instagram.com/simplilearn_elearning/ INFO  setup:test_SL_footer_check.py:264 Exception Occurred Traceback (most recent call last): File "C:\test_repos\pre_sales_test_python\test_prod\test_SL_footer_check.py", line 239, in test_SL_Footer_check pytest.driver.get(pytest.config['prod_url']) File "c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 333, in get self.execute(Command.GET, {'url': url}) File "c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute self.error_handler.check_response(response) File "c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.NoSuchWindowException: Message: no such window: target window already closed from unknown error: web view not found (Session info: chrome=110.0.5481.100)
Failed test_SL_footer_check.py::TestSLFooterCheck::test_SL_Footer_check[About us] 0.00
self = <test_SL_footer_check.TestSLFooterCheck object at 0x0000021898B3DB20>, value = 'About us'
initialize_pages = None

@pytest.mark.test_details("SLUB-T0000","high","Sl Footer Check","Pradeep")
@pytest.mark.parametrize("value",_create_parameterised_data())
def test_SL_Footer_check(self,value,initialize_pages):
try:
logging.info(value)
with open('sl_footer_check_test_data.csv', 'r') as csv_file:
csv_data = csv.reader(csv_file)
for line in csv_data:
if line[0] == value:
url = line[1]
logging.info(f"URL for {value} is : {url}")
break

> pytest.driver.get(pytest.config['prod_url'])

test_prod\test_SL_footer_check.py:239:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.chrome.webdriver.WebDriver (session="7643857c856eba21654096eb2db552ee")>
url = 'https://www.simplilearn.com/'

def get(self, url):
"""
Loads a web page in the current browser session.
"""
> self.execute(Command.GET, {'url': url})

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:333:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.chrome.webdriver.WebDriver (session="7643857c856eba21654096eb2db552ee")>
driver_command = 'get', params = {'url': 'https://www.simplilearn.com/'}

def execute(self, driver_command, params=None):
"""
Sends a command to be executed by a command.CommandExecutor.

:Args:
- driver_command: The name of the command to execute as a string.
- params: A dictionary of named parameters to send with the command.

:Returns:
The command's JSON response loaded into a dictionary object.
"""
if self.session_id is not None:
if not params:
params = {'sessionId': self.session_id}
elif 'sessionId' not in params:
params['sessionId'] = self.session_id

params = self._wrap_value(params)
response = self.command_executor.execute(driver_command, params)
if response:
> self.error_handler.check_response(response)

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:321:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x000002189862D550>
response = {'status': 404, 'value': '{"value":{"error":"no such window","message":"no such window: target window already closed\\...\n\\tRtlGetAppContainerNamedObjectPath [0x77187BBE+286]\\n\\tRtlGetAppContainerNamedObjectPath [0x77187B8E+238]\\n"}}'}

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 = InvalidCookieDomainException
elif status in ErrorCode.UNABLE_TO_SET_COOKIE:
exception_class = UnableToSetCookieException
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
elif status in ErrorCode.JAVASCRIPT_ERROR:
exception_class = JavascriptException
elif status in ErrorCode.SESSION_NOT_CREATED:
exception_class = SessionNotCreatedException
elif status in ErrorCode.INVALID_ARGUMENT:
exception_class = InvalidArgumentException
elif status in ErrorCode.NO_SUCH_COOKIE:
exception_class = NoSuchCookieException
elif status in ErrorCode.UNABLE_TO_CAPTURE_SCREEN:
exception_class = ScreenshotException
elif status in ErrorCode.ELEMENT_CLICK_INTERCEPTED:
exception_class = ElementClickInterceptedException
elif status in ErrorCode.INSECURE_CERTIFICATE:
exception_class = InsecureCertificateException
elif status in ErrorCode.INVALID_COORDINATES:
exception_class = InvalidCoordinatesException
elif status in ErrorCode.INVALID_SESSION_ID:
exception_class = InvalidSessionIdException
elif status in ErrorCode.UNKNOWN_METHOD:
exception_class = UnknownMethodException
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:
alert_text = None
if 'data' in value:
alert_text = value['data'].get('text')
elif 'alert' in value:
alert_text = value['alert'].get('text')
raise exception_class(message, screen, stacktrace, alert_text)
> raise exception_class(message, screen, stacktrace)
E selenium.common.exceptions.NoSuchWindowException: Message: no such window: target window already closed
E from unknown error: web view not found
E (Session info: chrome=110.0.5481.100)

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py:242: NoSuchWindowException

During handling of the above exception, another exception occurred:

self = <test_SL_footer_check.TestSLFooterCheck object at 0x0000021898B3DB20>, value = 'About us'
initialize_pages = None

@pytest.mark.test_details("SLUB-T0000","high","Sl Footer Check","Pradeep")
@pytest.mark.parametrize("value",_create_parameterised_data())
def test_SL_Footer_check(self,value,initialize_pages):
try:
logging.info(value)
with open('sl_footer_check_test_data.csv', 'r') as csv_file:
csv_data = csv.reader(csv_file)
for line in csv_data:
if line[0] == value:
url = line[1]
logging.info(f"URL for {value} is : {url}")
break

pytest.driver.get(pytest.config['prod_url'])
selenium_helper.wait_for_page_to_load(20,pytest.config['prod_url'])
dynamic_locator = f"(//div[starts-with(@class,'col-md-2')]//a[@title='{value}'])[1]"
logging.info(f"Dynamic Locator : {dynamic_locator}")
time.sleep(3)
WebDriverWait(pytest.driver, 20).until(EC.element_to_be_clickable((By.XPATH, dynamic_locator))).scroll_to_element()
time.sleep(2)
default_window = pytest.driver.current_window_handle
pytest.driver.find_element(By.XPATH,dynamic_locator).click()
time.sleep(5)
window_handle = list(pytest.driver.window_handles)
if len(window_handle) > 1:
pytest.driver.close()
pytest.driver.switch_to.window(window_handle[-1])

url_opened,message = self.check_redirection(value,url)
rows = [[value,url,url_opened,message]]
with open("Report.csv", 'a', newline='\n') as csvfile:
csvwriter = csv.writer(csvfile)
csvwriter.writerows(rows)
if 'Not Working' in message:
pytest.driver.get_screenshot_as_file(os.path.join(os.path.dirname(os.curdir), "report\screenshot", f"{__name__}_{value}.jpeg"))
pytest.fail()

except:
logging.info("Exception Occurred", exc_info=True)
> pytest.driver.get_screenshot_as_file(os.path.join(os.path.dirname(os.curdir), "report\screenshot", f"{__name__}_{value}.jpeg"))

test_prod\test_SL_footer_check.py:265:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:1032: in get_screenshot_as_file
png = self.get_screenshot_as_png()
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:1064: in get_screenshot_as_png
return base64.b64decode(self.get_screenshot_as_base64().encode('ascii'))
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:1074: in get_screenshot_as_base64
return self.execute(Command.SCREENSHOT)['value']
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:321: in execute
self.error_handler.check_response(response)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x000002189862D550>
response = {'status': 404, 'value': '{"value":{"error":"no such window","message":"no such window: target window already closed\\...\n\\tRtlGetAppContainerNamedObjectPath [0x77187BBE+286]\\n\\tRtlGetAppContainerNamedObjectPath [0x77187B8E+238]\\n"}}'}

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 = InvalidCookieDomainException
elif status in ErrorCode.UNABLE_TO_SET_COOKIE:
exception_class = UnableToSetCookieException
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
elif status in ErrorCode.JAVASCRIPT_ERROR:
exception_class = JavascriptException
elif status in ErrorCode.SESSION_NOT_CREATED:
exception_class = SessionNotCreatedException
elif status in ErrorCode.INVALID_ARGUMENT:
exception_class = InvalidArgumentException
elif status in ErrorCode.NO_SUCH_COOKIE:
exception_class = NoSuchCookieException
elif status in ErrorCode.UNABLE_TO_CAPTURE_SCREEN:
exception_class = ScreenshotException
elif status in ErrorCode.ELEMENT_CLICK_INTERCEPTED:
exception_class = ElementClickInterceptedException
elif status in ErrorCode.INSECURE_CERTIFICATE:
exception_class = InsecureCertificateException
elif status in ErrorCode.INVALID_COORDINATES:
exception_class = InvalidCoordinatesException
elif status in ErrorCode.INVALID_SESSION_ID:
exception_class = InvalidSessionIdException
elif status in ErrorCode.UNKNOWN_METHOD:
exception_class = UnknownMethodException
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:
alert_text = None
if 'data' in value:
alert_text = value['data'].get('text')
elif 'alert' in value:
alert_text = value['alert'].get('text')
raise exception_class(message, screen, stacktrace, alert_text)
> raise exception_class(message, screen, stacktrace)
E selenium.common.exceptions.NoSuchWindowException: Message: no such window: target window already closed
E from unknown error: web view not found
E (Session info: chrome=110.0.5481.100)

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py:242: NoSuchWindowException
-------------------------------Captured log call--------------------------------
INFO  setup:test_SL_footer_check.py:230 About us INFO  setup:test_SL_footer_check.py:236 URL for About us is : https://www.simplilearn.com/about-us INFO  setup:test_SL_footer_check.py:264 Exception Occurred Traceback (most recent call last): File "C:\test_repos\pre_sales_test_python\test_prod\test_SL_footer_check.py", line 239, in test_SL_Footer_check pytest.driver.get(pytest.config['prod_url']) File "c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 333, in get self.execute(Command.GET, {'url': url}) File "c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute self.error_handler.check_response(response) File "c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.NoSuchWindowException: Message: no such window: target window already closed from unknown error: web view not found (Session info: chrome=110.0.5481.100)
Failed test_SL_footer_check.py::TestSLFooterCheck::test_SL_Footer_check[Careers] 0.00
self = <test_SL_footer_check.TestSLFooterCheck object at 0x000002189898AEE0>, value = 'Careers', initialize_pages = None

@pytest.mark.test_details("SLUB-T0000","high","Sl Footer Check","Pradeep")
@pytest.mark.parametrize("value",_create_parameterised_data())
def test_SL_Footer_check(self,value,initialize_pages):
try:
logging.info(value)
with open('sl_footer_check_test_data.csv', 'r') as csv_file:
csv_data = csv.reader(csv_file)
for line in csv_data:
if line[0] == value:
url = line[1]
logging.info(f"URL for {value} is : {url}")
break

> pytest.driver.get(pytest.config['prod_url'])

test_prod\test_SL_footer_check.py:239:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.chrome.webdriver.WebDriver (session="7643857c856eba21654096eb2db552ee")>
url = 'https://www.simplilearn.com/'

def get(self, url):
"""
Loads a web page in the current browser session.
"""
> self.execute(Command.GET, {'url': url})

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:333:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.chrome.webdriver.WebDriver (session="7643857c856eba21654096eb2db552ee")>
driver_command = 'get', params = {'url': 'https://www.simplilearn.com/'}

def execute(self, driver_command, params=None):
"""
Sends a command to be executed by a command.CommandExecutor.

:Args:
- driver_command: The name of the command to execute as a string.
- params: A dictionary of named parameters to send with the command.

:Returns:
The command's JSON response loaded into a dictionary object.
"""
if self.session_id is not None:
if not params:
params = {'sessionId': self.session_id}
elif 'sessionId' not in params:
params['sessionId'] = self.session_id

params = self._wrap_value(params)
response = self.command_executor.execute(driver_command, params)
if response:
> self.error_handler.check_response(response)

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:321:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x000002189862D550>
response = {'status': 404, 'value': '{"value":{"error":"no such window","message":"no such window: target window already closed\\...\n\\tRtlGetAppContainerNamedObjectPath [0x77187BBE+286]\\n\\tRtlGetAppContainerNamedObjectPath [0x77187B8E+238]\\n"}}'}

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 = InvalidCookieDomainException
elif status in ErrorCode.UNABLE_TO_SET_COOKIE:
exception_class = UnableToSetCookieException
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
elif status in ErrorCode.JAVASCRIPT_ERROR:
exception_class = JavascriptException
elif status in ErrorCode.SESSION_NOT_CREATED:
exception_class = SessionNotCreatedException
elif status in ErrorCode.INVALID_ARGUMENT:
exception_class = InvalidArgumentException
elif status in ErrorCode.NO_SUCH_COOKIE:
exception_class = NoSuchCookieException
elif status in ErrorCode.UNABLE_TO_CAPTURE_SCREEN:
exception_class = ScreenshotException
elif status in ErrorCode.ELEMENT_CLICK_INTERCEPTED:
exception_class = ElementClickInterceptedException
elif status in ErrorCode.INSECURE_CERTIFICATE:
exception_class = InsecureCertificateException
elif status in ErrorCode.INVALID_COORDINATES:
exception_class = InvalidCoordinatesException
elif status in ErrorCode.INVALID_SESSION_ID:
exception_class = InvalidSessionIdException
elif status in ErrorCode.UNKNOWN_METHOD:
exception_class = UnknownMethodException
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:
alert_text = None
if 'data' in value:
alert_text = value['data'].get('text')
elif 'alert' in value:
alert_text = value['alert'].get('text')
raise exception_class(message, screen, stacktrace, alert_text)
> raise exception_class(message, screen, stacktrace)
E selenium.common.exceptions.NoSuchWindowException: Message: no such window: target window already closed
E from unknown error: web view not found
E (Session info: chrome=110.0.5481.100)

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py:242: NoSuchWindowException

During handling of the above exception, another exception occurred:

self = <test_SL_footer_check.TestSLFooterCheck object at 0x000002189898AEE0>, value = 'Careers', initialize_pages = None

@pytest.mark.test_details("SLUB-T0000","high","Sl Footer Check","Pradeep")
@pytest.mark.parametrize("value",_create_parameterised_data())
def test_SL_Footer_check(self,value,initialize_pages):
try:
logging.info(value)
with open('sl_footer_check_test_data.csv', 'r') as csv_file:
csv_data = csv.reader(csv_file)
for line in csv_data:
if line[0] == value:
url = line[1]
logging.info(f"URL for {value} is : {url}")
break

pytest.driver.get(pytest.config['prod_url'])
selenium_helper.wait_for_page_to_load(20,pytest.config['prod_url'])
dynamic_locator = f"(//div[starts-with(@class,'col-md-2')]//a[@title='{value}'])[1]"
logging.info(f"Dynamic Locator : {dynamic_locator}")
time.sleep(3)
WebDriverWait(pytest.driver, 20).until(EC.element_to_be_clickable((By.XPATH, dynamic_locator))).scroll_to_element()
time.sleep(2)
default_window = pytest.driver.current_window_handle
pytest.driver.find_element(By.XPATH,dynamic_locator).click()
time.sleep(5)
window_handle = list(pytest.driver.window_handles)
if len(window_handle) > 1:
pytest.driver.close()
pytest.driver.switch_to.window(window_handle[-1])

url_opened,message = self.check_redirection(value,url)
rows = [[value,url,url_opened,message]]
with open("Report.csv", 'a', newline='\n') as csvfile:
csvwriter = csv.writer(csvfile)
csvwriter.writerows(rows)
if 'Not Working' in message:
pytest.driver.get_screenshot_as_file(os.path.join(os.path.dirname(os.curdir), "report\screenshot", f"{__name__}_{value}.jpeg"))
pytest.fail()

except:
logging.info("Exception Occurred", exc_info=True)
> pytest.driver.get_screenshot_as_file(os.path.join(os.path.dirname(os.curdir), "report\screenshot", f"{__name__}_{value}.jpeg"))

test_prod\test_SL_footer_check.py:265:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:1032: in get_screenshot_as_file
png = self.get_screenshot_as_png()
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:1064: in get_screenshot_as_png
return base64.b64decode(self.get_screenshot_as_base64().encode('ascii'))
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:1074: in get_screenshot_as_base64
return self.execute(Command.SCREENSHOT)['value']
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:321: in execute
self.error_handler.check_response(response)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x000002189862D550>
response = {'status': 404, 'value': '{"value":{"error":"no such window","message":"no such window: target window already closed\\...\n\\tRtlGetAppContainerNamedObjectPath [0x77187BBE+286]\\n\\tRtlGetAppContainerNamedObjectPath [0x77187B8E+238]\\n"}}'}

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 = InvalidCookieDomainException
elif status in ErrorCode.UNABLE_TO_SET_COOKIE:
exception_class = UnableToSetCookieException
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
elif status in ErrorCode.JAVASCRIPT_ERROR:
exception_class = JavascriptException
elif status in ErrorCode.SESSION_NOT_CREATED:
exception_class = SessionNotCreatedException
elif status in ErrorCode.INVALID_ARGUMENT:
exception_class = InvalidArgumentException
elif status in ErrorCode.NO_SUCH_COOKIE:
exception_class = NoSuchCookieException
elif status in ErrorCode.UNABLE_TO_CAPTURE_SCREEN:
exception_class = ScreenshotException
elif status in ErrorCode.ELEMENT_CLICK_INTERCEPTED:
exception_class = ElementClickInterceptedException
elif status in ErrorCode.INSECURE_CERTIFICATE:
exception_class = InsecureCertificateException
elif status in ErrorCode.INVALID_COORDINATES:
exception_class = InvalidCoordinatesException
elif status in ErrorCode.INVALID_SESSION_ID:
exception_class = InvalidSessionIdException
elif status in ErrorCode.UNKNOWN_METHOD:
exception_class = UnknownMethodException
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:
alert_text = None
if 'data' in value:
alert_text = value['data'].get('text')
elif 'alert' in value:
alert_text = value['alert'].get('text')
raise exception_class(message, screen, stacktrace, alert_text)
> raise exception_class(message, screen, stacktrace)
E selenium.common.exceptions.NoSuchWindowException: Message: no such window: target window already closed
E from unknown error: web view not found
E (Session info: chrome=110.0.5481.100)

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py:242: NoSuchWindowException
-------------------------------Captured log call--------------------------------
INFO  setup:test_SL_footer_check.py:230 Careers INFO  setup:test_SL_footer_check.py:236 URL for Careers is : https://www.simplilearn.com/careers INFO  setup:test_SL_footer_check.py:264 Exception Occurred Traceback (most recent call last): File "C:\test_repos\pre_sales_test_python\test_prod\test_SL_footer_check.py", line 239, in test_SL_Footer_check pytest.driver.get(pytest.config['prod_url']) File "c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 333, in get self.execute(Command.GET, {'url': url}) File "c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute self.error_handler.check_response(response) File "c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.NoSuchWindowException: Message: no such window: target window already closed from unknown error: web view not found (Session info: chrome=110.0.5481.100)
Failed test_SL_footer_check.py::TestSLFooterCheck::test_SL_Footer_check[In the media] 0.00
self = <test_SL_footer_check.TestSLFooterCheck object at 0x0000021898BE92E0>, value = 'In the media'
initialize_pages = None

@pytest.mark.test_details("SLUB-T0000","high","Sl Footer Check","Pradeep")
@pytest.mark.parametrize("value",_create_parameterised_data())
def test_SL_Footer_check(self,value,initialize_pages):
try:
logging.info(value)
with open('sl_footer_check_test_data.csv', 'r') as csv_file:
csv_data = csv.reader(csv_file)
for line in csv_data:
if line[0] == value:
url = line[1]
logging.info(f"URL for {value} is : {url}")
break

> pytest.driver.get(pytest.config['prod_url'])

test_prod\test_SL_footer_check.py:239:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.chrome.webdriver.WebDriver (session="7643857c856eba21654096eb2db552ee")>
url = 'https://www.simplilearn.com/'

def get(self, url):
"""
Loads a web page in the current browser session.
"""
> self.execute(Command.GET, {'url': url})

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:333:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.chrome.webdriver.WebDriver (session="7643857c856eba21654096eb2db552ee")>
driver_command = 'get', params = {'url': 'https://www.simplilearn.com/'}

def execute(self, driver_command, params=None):
"""
Sends a command to be executed by a command.CommandExecutor.

:Args:
- driver_command: The name of the command to execute as a string.
- params: A dictionary of named parameters to send with the command.

:Returns:
The command's JSON response loaded into a dictionary object.
"""
if self.session_id is not None:
if not params:
params = {'sessionId': self.session_id}
elif 'sessionId' not in params:
params['sessionId'] = self.session_id

params = self._wrap_value(params)
response = self.command_executor.execute(driver_command, params)
if response:
> self.error_handler.check_response(response)

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:321:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x000002189862D550>
response = {'status': 404, 'value': '{"value":{"error":"no such window","message":"no such window: target window already closed\\...\n\\tRtlGetAppContainerNamedObjectPath [0x77187BBE+286]\\n\\tRtlGetAppContainerNamedObjectPath [0x77187B8E+238]\\n"}}'}

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 = InvalidCookieDomainException
elif status in ErrorCode.UNABLE_TO_SET_COOKIE:
exception_class = UnableToSetCookieException
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
elif status in ErrorCode.JAVASCRIPT_ERROR:
exception_class = JavascriptException
elif status in ErrorCode.SESSION_NOT_CREATED:
exception_class = SessionNotCreatedException
elif status in ErrorCode.INVALID_ARGUMENT:
exception_class = InvalidArgumentException
elif status in ErrorCode.NO_SUCH_COOKIE:
exception_class = NoSuchCookieException
elif status in ErrorCode.UNABLE_TO_CAPTURE_SCREEN:
exception_class = ScreenshotException
elif status in ErrorCode.ELEMENT_CLICK_INTERCEPTED:
exception_class = ElementClickInterceptedException
elif status in ErrorCode.INSECURE_CERTIFICATE:
exception_class = InsecureCertificateException
elif status in ErrorCode.INVALID_COORDINATES:
exception_class = InvalidCoordinatesException
elif status in ErrorCode.INVALID_SESSION_ID:
exception_class = InvalidSessionIdException
elif status in ErrorCode.UNKNOWN_METHOD:
exception_class = UnknownMethodException
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:
alert_text = None
if 'data' in value:
alert_text = value['data'].get('text')
elif 'alert' in value:
alert_text = value['alert'].get('text')
raise exception_class(message, screen, stacktrace, alert_text)
> raise exception_class(message, screen, stacktrace)
E selenium.common.exceptions.NoSuchWindowException: Message: no such window: target window already closed
E from unknown error: web view not found
E (Session info: chrome=110.0.5481.100)

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py:242: NoSuchWindowException

During handling of the above exception, another exception occurred:

self = <test_SL_footer_check.TestSLFooterCheck object at 0x0000021898BE92E0>, value = 'In the media'
initialize_pages = None

@pytest.mark.test_details("SLUB-T0000","high","Sl Footer Check","Pradeep")
@pytest.mark.parametrize("value",_create_parameterised_data())
def test_SL_Footer_check(self,value,initialize_pages):
try:
logging.info(value)
with open('sl_footer_check_test_data.csv', 'r') as csv_file:
csv_data = csv.reader(csv_file)
for line in csv_data:
if line[0] == value:
url = line[1]
logging.info(f"URL for {value} is : {url}")
break

pytest.driver.get(pytest.config['prod_url'])
selenium_helper.wait_for_page_to_load(20,pytest.config['prod_url'])
dynamic_locator = f"(//div[starts-with(@class,'col-md-2')]//a[@title='{value}'])[1]"
logging.info(f"Dynamic Locator : {dynamic_locator}")
time.sleep(3)
WebDriverWait(pytest.driver, 20).until(EC.element_to_be_clickable((By.XPATH, dynamic_locator))).scroll_to_element()
time.sleep(2)
default_window = pytest.driver.current_window_handle
pytest.driver.find_element(By.XPATH,dynamic_locator).click()
time.sleep(5)
window_handle = list(pytest.driver.window_handles)
if len(window_handle) > 1:
pytest.driver.close()
pytest.driver.switch_to.window(window_handle[-1])

url_opened,message = self.check_redirection(value,url)
rows = [[value,url,url_opened,message]]
with open("Report.csv", 'a', newline='\n') as csvfile:
csvwriter = csv.writer(csvfile)
csvwriter.writerows(rows)
if 'Not Working' in message:
pytest.driver.get_screenshot_as_file(os.path.join(os.path.dirname(os.curdir), "report\screenshot", f"{__name__}_{value}.jpeg"))
pytest.fail()

except:
logging.info("Exception Occurred", exc_info=True)
> pytest.driver.get_screenshot_as_file(os.path.join(os.path.dirname(os.curdir), "report\screenshot", f"{__name__}_{value}.jpeg"))

test_prod\test_SL_footer_check.py:265:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:1032: in get_screenshot_as_file
png = self.get_screenshot_as_png()
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:1064: in get_screenshot_as_png
return base64.b64decode(self.get_screenshot_as_base64().encode('ascii'))
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:1074: in get_screenshot_as_base64
return self.execute(Command.SCREENSHOT)['value']
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:321: in execute
self.error_handler.check_response(response)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x000002189862D550>
response = {'status': 404, 'value': '{"value":{"error":"no such window","message":"no such window: target window already closed\\...\n\\tRtlGetAppContainerNamedObjectPath [0x77187BBE+286]\\n\\tRtlGetAppContainerNamedObjectPath [0x77187B8E+238]\\n"}}'}

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 = InvalidCookieDomainException
elif status in ErrorCode.UNABLE_TO_SET_COOKIE:
exception_class = UnableToSetCookieException
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
elif status in ErrorCode.JAVASCRIPT_ERROR:
exception_class = JavascriptException
elif status in ErrorCode.SESSION_NOT_CREATED:
exception_class = SessionNotCreatedException
elif status in ErrorCode.INVALID_ARGUMENT:
exception_class = InvalidArgumentException
elif status in ErrorCode.NO_SUCH_COOKIE:
exception_class = NoSuchCookieException
elif status in ErrorCode.UNABLE_TO_CAPTURE_SCREEN:
exception_class = ScreenshotException
elif status in ErrorCode.ELEMENT_CLICK_INTERCEPTED:
exception_class = ElementClickInterceptedException
elif status in ErrorCode.INSECURE_CERTIFICATE:
exception_class = InsecureCertificateException
elif status in ErrorCode.INVALID_COORDINATES:
exception_class = InvalidCoordinatesException
elif status in ErrorCode.INVALID_SESSION_ID:
exception_class = InvalidSessionIdException
elif status in ErrorCode.UNKNOWN_METHOD:
exception_class = UnknownMethodException
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:
alert_text = None
if 'data' in value:
alert_text = value['data'].get('text')
elif 'alert' in value:
alert_text = value['alert'].get('text')
raise exception_class(message, screen, stacktrace, alert_text)
> raise exception_class(message, screen, stacktrace)
E selenium.common.exceptions.NoSuchWindowException: Message: no such window: target window already closed
E from unknown error: web view not found
E (Session info: chrome=110.0.5481.100)

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py:242: NoSuchWindowException
-------------------------------Captured log call--------------------------------
INFO  setup:test_SL_footer_check.py:230 In the media INFO  setup:test_SL_footer_check.py:236 URL for In the media is : https://www.simplilearn.com/media INFO  setup:test_SL_footer_check.py:264 Exception Occurred Traceback (most recent call last): File "C:\test_repos\pre_sales_test_python\test_prod\test_SL_footer_check.py", line 239, in test_SL_Footer_check pytest.driver.get(pytest.config['prod_url']) File "c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 333, in get self.execute(Command.GET, {'url': url}) File "c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute self.error_handler.check_response(response) File "c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.NoSuchWindowException: Message: no such window: target window already closed from unknown error: web view not found (Session info: chrome=110.0.5481.100)
Failed test_SL_footer_check.py::TestSLFooterCheck::test_SL_Footer_check[Alumni speak] 0.00
self = <test_SL_footer_check.TestSLFooterCheck object at 0x0000021898AADAC0>, value = 'Alumni speak'
initialize_pages = None

@pytest.mark.test_details("SLUB-T0000","high","Sl Footer Check","Pradeep")
@pytest.mark.parametrize("value",_create_parameterised_data())
def test_SL_Footer_check(self,value,initialize_pages):
try:
logging.info(value)
with open('sl_footer_check_test_data.csv', 'r') as csv_file:
csv_data = csv.reader(csv_file)
for line in csv_data:
if line[0] == value:
url = line[1]
logging.info(f"URL for {value} is : {url}")
break

> pytest.driver.get(pytest.config['prod_url'])

test_prod\test_SL_footer_check.py:239:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.chrome.webdriver.WebDriver (session="7643857c856eba21654096eb2db552ee")>
url = 'https://www.simplilearn.com/'

def get(self, url):
"""
Loads a web page in the current browser session.
"""
> self.execute(Command.GET, {'url': url})

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:333:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.chrome.webdriver.WebDriver (session="7643857c856eba21654096eb2db552ee")>
driver_command = 'get', params = {'url': 'https://www.simplilearn.com/'}

def execute(self, driver_command, params=None):
"""
Sends a command to be executed by a command.CommandExecutor.

:Args:
- driver_command: The name of the command to execute as a string.
- params: A dictionary of named parameters to send with the command.

:Returns:
The command's JSON response loaded into a dictionary object.
"""
if self.session_id is not None:
if not params:
params = {'sessionId': self.session_id}
elif 'sessionId' not in params:
params['sessionId'] = self.session_id

params = self._wrap_value(params)
response = self.command_executor.execute(driver_command, params)
if response:
> self.error_handler.check_response(response)

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:321:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x000002189862D550>
response = {'status': 404, 'value': '{"value":{"error":"no such window","message":"no such window: target window already closed\\...\n\\tRtlGetAppContainerNamedObjectPath [0x77187BBE+286]\\n\\tRtlGetAppContainerNamedObjectPath [0x77187B8E+238]\\n"}}'}

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 = InvalidCookieDomainException
elif status in ErrorCode.UNABLE_TO_SET_COOKIE:
exception_class = UnableToSetCookieException
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
elif status in ErrorCode.JAVASCRIPT_ERROR:
exception_class = JavascriptException
elif status in ErrorCode.SESSION_NOT_CREATED:
exception_class = SessionNotCreatedException
elif status in ErrorCode.INVALID_ARGUMENT:
exception_class = InvalidArgumentException
elif status in ErrorCode.NO_SUCH_COOKIE:
exception_class = NoSuchCookieException
elif status in ErrorCode.UNABLE_TO_CAPTURE_SCREEN:
exception_class = ScreenshotException
elif status in ErrorCode.ELEMENT_CLICK_INTERCEPTED:
exception_class = ElementClickInterceptedException
elif status in ErrorCode.INSECURE_CERTIFICATE:
exception_class = InsecureCertificateException
elif status in ErrorCode.INVALID_COORDINATES:
exception_class = InvalidCoordinatesException
elif status in ErrorCode.INVALID_SESSION_ID:
exception_class = InvalidSessionIdException
elif status in ErrorCode.UNKNOWN_METHOD:
exception_class = UnknownMethodException
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:
alert_text = None
if 'data' in value:
alert_text = value['data'].get('text')
elif 'alert' in value:
alert_text = value['alert'].get('text')
raise exception_class(message, screen, stacktrace, alert_text)
> raise exception_class(message, screen, stacktrace)
E selenium.common.exceptions.NoSuchWindowException: Message: no such window: target window already closed
E from unknown error: web view not found
E (Session info: chrome=110.0.5481.100)

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py:242: NoSuchWindowException

During handling of the above exception, another exception occurred:

self = <test_SL_footer_check.TestSLFooterCheck object at 0x0000021898AADAC0>, value = 'Alumni speak'
initialize_pages = None

@pytest.mark.test_details("SLUB-T0000","high","Sl Footer Check","Pradeep")
@pytest.mark.parametrize("value",_create_parameterised_data())
def test_SL_Footer_check(self,value,initialize_pages):
try:
logging.info(value)
with open('sl_footer_check_test_data.csv', 'r') as csv_file:
csv_data = csv.reader(csv_file)
for line in csv_data:
if line[0] == value:
url = line[1]
logging.info(f"URL for {value} is : {url}")
break

pytest.driver.get(pytest.config['prod_url'])
selenium_helper.wait_for_page_to_load(20,pytest.config['prod_url'])
dynamic_locator = f"(//div[starts-with(@class,'col-md-2')]//a[@title='{value}'])[1]"
logging.info(f"Dynamic Locator : {dynamic_locator}")
time.sleep(3)
WebDriverWait(pytest.driver, 20).until(EC.element_to_be_clickable((By.XPATH, dynamic_locator))).scroll_to_element()
time.sleep(2)
default_window = pytest.driver.current_window_handle
pytest.driver.find_element(By.XPATH,dynamic_locator).click()
time.sleep(5)
window_handle = list(pytest.driver.window_handles)
if len(window_handle) > 1:
pytest.driver.close()
pytest.driver.switch_to.window(window_handle[-1])

url_opened,message = self.check_redirection(value,url)
rows = [[value,url,url_opened,message]]
with open("Report.csv", 'a', newline='\n') as csvfile:
csvwriter = csv.writer(csvfile)
csvwriter.writerows(rows)
if 'Not Working' in message:
pytest.driver.get_screenshot_as_file(os.path.join(os.path.dirname(os.curdir), "report\screenshot", f"{__name__}_{value}.jpeg"))
pytest.fail()

except:
logging.info("Exception Occurred", exc_info=True)
> pytest.driver.get_screenshot_as_file(os.path.join(os.path.dirname(os.curdir), "report\screenshot", f"{__name__}_{value}.jpeg"))

test_prod\test_SL_footer_check.py:265:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:1032: in get_screenshot_as_file
png = self.get_screenshot_as_png()
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:1064: in get_screenshot_as_png
return base64.b64decode(self.get_screenshot_as_base64().encode('ascii'))
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:1074: in get_screenshot_as_base64
return self.execute(Command.SCREENSHOT)['value']
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:321: in execute
self.error_handler.check_response(response)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x000002189862D550>
response = {'status': 404, 'value': '{"value":{"error":"no such window","message":"no such window: target window already closed\\...\n\\tRtlGetAppContainerNamedObjectPath [0x77187BBE+286]\\n\\tRtlGetAppContainerNamedObjectPath [0x77187B8E+238]\\n"}}'}

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 = InvalidCookieDomainException
elif status in ErrorCode.UNABLE_TO_SET_COOKIE:
exception_class = UnableToSetCookieException
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
elif status in ErrorCode.JAVASCRIPT_ERROR:
exception_class = JavascriptException
elif status in ErrorCode.SESSION_NOT_CREATED:
exception_class = SessionNotCreatedException
elif status in ErrorCode.INVALID_ARGUMENT:
exception_class = InvalidArgumentException
elif status in ErrorCode.NO_SUCH_COOKIE:
exception_class = NoSuchCookieException
elif status in ErrorCode.UNABLE_TO_CAPTURE_SCREEN:
exception_class = ScreenshotException
elif status in ErrorCode.ELEMENT_CLICK_INTERCEPTED:
exception_class = ElementClickInterceptedException
elif status in ErrorCode.INSECURE_CERTIFICATE:
exception_class = InsecureCertificateException
elif status in ErrorCode.INVALID_COORDINATES:
exception_class = InvalidCoordinatesException
elif status in ErrorCode.INVALID_SESSION_ID:
exception_class = InvalidSessionIdException
elif status in ErrorCode.UNKNOWN_METHOD:
exception_class = UnknownMethodException
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:
alert_text = None
if 'data' in value:
alert_text = value['data'].get('text')
elif 'alert' in value:
alert_text = value['alert'].get('text')
raise exception_class(message, screen, stacktrace, alert_text)
> raise exception_class(message, screen, stacktrace)
E selenium.common.exceptions.NoSuchWindowException: Message: no such window: target window already closed
E from unknown error: web view not found
E (Session info: chrome=110.0.5481.100)

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py:242: NoSuchWindowException
-------------------------------Captured log call--------------------------------
INFO  setup:test_SL_footer_check.py:230 Alumni speak INFO  setup:test_SL_footer_check.py:236 URL for Alumni speak is : https://www.simplilearn.com/reviews INFO  setup:test_SL_footer_check.py:264 Exception Occurred Traceback (most recent call last): File "C:\test_repos\pre_sales_test_python\test_prod\test_SL_footer_check.py", line 239, in test_SL_Footer_check pytest.driver.get(pytest.config['prod_url']) File "c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 333, in get self.execute(Command.GET, {'url': url}) File "c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute self.error_handler.check_response(response) File "c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.NoSuchWindowException: Message: no such window: target window already closed from unknown error: web view not found (Session info: chrome=110.0.5481.100)
Failed test_SL_footer_check.py::TestSLFooterCheck::test_SL_Footer_check[Grievance redressal] 0.00
self = <test_SL_footer_check.TestSLFooterCheck object at 0x00000218989ADCD0>, value = 'Grievance redressal'
initialize_pages = None

@pytest.mark.test_details("SLUB-T0000","high","Sl Footer Check","Pradeep")
@pytest.mark.parametrize("value",_create_parameterised_data())
def test_SL_Footer_check(self,value,initialize_pages):
try:
logging.info(value)
with open('sl_footer_check_test_data.csv', 'r') as csv_file:
csv_data = csv.reader(csv_file)
for line in csv_data:
if line[0] == value:
url = line[1]
logging.info(f"URL for {value} is : {url}")
break

> pytest.driver.get(pytest.config['prod_url'])

test_prod\test_SL_footer_check.py:239:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.chrome.webdriver.WebDriver (session="7643857c856eba21654096eb2db552ee")>
url = 'https://www.simplilearn.com/'

def get(self, url):
"""
Loads a web page in the current browser session.
"""
> self.execute(Command.GET, {'url': url})

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:333:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.chrome.webdriver.WebDriver (session="7643857c856eba21654096eb2db552ee")>
driver_command = 'get', params = {'url': 'https://www.simplilearn.com/'}

def execute(self, driver_command, params=None):
"""
Sends a command to be executed by a command.CommandExecutor.

:Args:
- driver_command: The name of the command to execute as a string.
- params: A dictionary of named parameters to send with the command.

:Returns:
The command's JSON response loaded into a dictionary object.
"""
if self.session_id is not None:
if not params:
params = {'sessionId': self.session_id}
elif 'sessionId' not in params:
params['sessionId'] = self.session_id

params = self._wrap_value(params)
response = self.command_executor.execute(driver_command, params)
if response:
> self.error_handler.check_response(response)

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:321:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x000002189862D550>
response = {'status': 404, 'value': '{"value":{"error":"no such window","message":"no such window: target window already closed\\...\n\\tRtlGetAppContainerNamedObjectPath [0x77187BBE+286]\\n\\tRtlGetAppContainerNamedObjectPath [0x77187B8E+238]\\n"}}'}

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 = InvalidCookieDomainException
elif status in ErrorCode.UNABLE_TO_SET_COOKIE:
exception_class = UnableToSetCookieException
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
elif status in ErrorCode.JAVASCRIPT_ERROR:
exception_class = JavascriptException
elif status in ErrorCode.SESSION_NOT_CREATED:
exception_class = SessionNotCreatedException
elif status in ErrorCode.INVALID_ARGUMENT:
exception_class = InvalidArgumentException
elif status in ErrorCode.NO_SUCH_COOKIE:
exception_class = NoSuchCookieException
elif status in ErrorCode.UNABLE_TO_CAPTURE_SCREEN:
exception_class = ScreenshotException
elif status in ErrorCode.ELEMENT_CLICK_INTERCEPTED:
exception_class = ElementClickInterceptedException
elif status in ErrorCode.INSECURE_CERTIFICATE:
exception_class = InsecureCertificateException
elif status in ErrorCode.INVALID_COORDINATES:
exception_class = InvalidCoordinatesException
elif status in ErrorCode.INVALID_SESSION_ID:
exception_class = InvalidSessionIdException
elif status in ErrorCode.UNKNOWN_METHOD:
exception_class = UnknownMethodException
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:
alert_text = None
if 'data' in value:
alert_text = value['data'].get('text')
elif 'alert' in value:
alert_text = value['alert'].get('text')
raise exception_class(message, screen, stacktrace, alert_text)
> raise exception_class(message, screen, stacktrace)
E selenium.common.exceptions.NoSuchWindowException: Message: no such window: target window already closed
E from unknown error: web view not found
E (Session info: chrome=110.0.5481.100)

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py:242: NoSuchWindowException

During handling of the above exception, another exception occurred:

self = <test_SL_footer_check.TestSLFooterCheck object at 0x00000218989ADCD0>, value = 'Grievance redressal'
initialize_pages = None

@pytest.mark.test_details("SLUB-T0000","high","Sl Footer Check","Pradeep")
@pytest.mark.parametrize("value",_create_parameterised_data())
def test_SL_Footer_check(self,value,initialize_pages):
try:
logging.info(value)
with open('sl_footer_check_test_data.csv', 'r') as csv_file:
csv_data = csv.reader(csv_file)
for line in csv_data:
if line[0] == value:
url = line[1]
logging.info(f"URL for {value} is : {url}")
break

pytest.driver.get(pytest.config['prod_url'])
selenium_helper.wait_for_page_to_load(20,pytest.config['prod_url'])
dynamic_locator = f"(//div[starts-with(@class,'col-md-2')]//a[@title='{value}'])[1]"
logging.info(f"Dynamic Locator : {dynamic_locator}")
time.sleep(3)
WebDriverWait(pytest.driver, 20).until(EC.element_to_be_clickable((By.XPATH, dynamic_locator))).scroll_to_element()
time.sleep(2)
default_window = pytest.driver.current_window_handle
pytest.driver.find_element(By.XPATH,dynamic_locator).click()
time.sleep(5)
window_handle = list(pytest.driver.window_handles)
if len(window_handle) > 1:
pytest.driver.close()
pytest.driver.switch_to.window(window_handle[-1])

url_opened,message = self.check_redirection(value,url)
rows = [[value,url,url_opened,message]]
with open("Report.csv", 'a', newline='\n') as csvfile:
csvwriter = csv.writer(csvfile)
csvwriter.writerows(rows)
if 'Not Working' in message:
pytest.driver.get_screenshot_as_file(os.path.join(os.path.dirname(os.curdir), "report\screenshot", f"{__name__}_{value}.jpeg"))
pytest.fail()

except:
logging.info("Exception Occurred", exc_info=True)
> pytest.driver.get_screenshot_as_file(os.path.join(os.path.dirname(os.curdir), "report\screenshot", f"{__name__}_{value}.jpeg"))

test_prod\test_SL_footer_check.py:265:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:1032: in get_screenshot_as_file
png = self.get_screenshot_as_png()
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:1064: in get_screenshot_as_png
return base64.b64decode(self.get_screenshot_as_base64().encode('ascii'))
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:1074: in get_screenshot_as_base64
return self.execute(Command.SCREENSHOT)['value']
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:321: in execute
self.error_handler.check_response(response)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x000002189862D550>
response = {'status': 404, 'value': '{"value":{"error":"no such window","message":"no such window: target window already closed\\...\n\\tRtlGetAppContainerNamedObjectPath [0x77187BBE+286]\\n\\tRtlGetAppContainerNamedObjectPath [0x77187B8E+238]\\n"}}'}

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 = InvalidCookieDomainException
elif status in ErrorCode.UNABLE_TO_SET_COOKIE:
exception_class = UnableToSetCookieException
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
elif status in ErrorCode.JAVASCRIPT_ERROR:
exception_class = JavascriptException
elif status in ErrorCode.SESSION_NOT_CREATED:
exception_class = SessionNotCreatedException
elif status in ErrorCode.INVALID_ARGUMENT:
exception_class = InvalidArgumentException
elif status in ErrorCode.NO_SUCH_COOKIE:
exception_class = NoSuchCookieException
elif status in ErrorCode.UNABLE_TO_CAPTURE_SCREEN:
exception_class = ScreenshotException
elif status in ErrorCode.ELEMENT_CLICK_INTERCEPTED:
exception_class = ElementClickInterceptedException
elif status in ErrorCode.INSECURE_CERTIFICATE:
exception_class = InsecureCertificateException
elif status in ErrorCode.INVALID_COORDINATES:
exception_class = InvalidCoordinatesException
elif status in ErrorCode.INVALID_SESSION_ID:
exception_class = InvalidSessionIdException
elif status in ErrorCode.UNKNOWN_METHOD:
exception_class = UnknownMethodException
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:
alert_text = None
if 'data' in value:
alert_text = value['data'].get('text')
elif 'alert' in value:
alert_text = value['alert'].get('text')
raise exception_class(message, screen, stacktrace, alert_text)
> raise exception_class(message, screen, stacktrace)
E selenium.common.exceptions.NoSuchWindowException: Message: no such window: target window already closed
E from unknown error: web view not found
E (Session info: chrome=110.0.5481.100)

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py:242: NoSuchWindowException
-------------------------------Captured log call--------------------------------
INFO  setup:test_SL_footer_check.py:230 Grievance redressal INFO  setup:test_SL_footer_check.py:236 URL for Grievance redressal is : https://www.simplilearn.com/grievance-redressal INFO  setup:test_SL_footer_check.py:264 Exception Occurred Traceback (most recent call last): File "C:\test_repos\pre_sales_test_python\test_prod\test_SL_footer_check.py", line 239, in test_SL_Footer_check pytest.driver.get(pytest.config['prod_url']) File "c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 333, in get self.execute(Command.GET, {'url': url}) File "c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute self.error_handler.check_response(response) File "c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.NoSuchWindowException: Message: no such window: target window already closed from unknown error: web view not found (Session info: chrome=110.0.5481.100)
Failed test_SL_footer_check.py::TestSLFooterCheck::test_SL_Footer_check[Contact us] 0.01
self = <test_SL_footer_check.TestSLFooterCheck object at 0x0000021898BCDA00>, value = 'Contact us'
initialize_pages = None

@pytest.mark.test_details("SLUB-T0000","high","Sl Footer Check","Pradeep")
@pytest.mark.parametrize("value",_create_parameterised_data())
def test_SL_Footer_check(self,value,initialize_pages):
try:
logging.info(value)
with open('sl_footer_check_test_data.csv', 'r') as csv_file:
csv_data = csv.reader(csv_file)
for line in csv_data:
if line[0] == value:
url = line[1]
logging.info(f"URL for {value} is : {url}")
break

> pytest.driver.get(pytest.config['prod_url'])

test_prod\test_SL_footer_check.py:239:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.chrome.webdriver.WebDriver (session="7643857c856eba21654096eb2db552ee")>
url = 'https://www.simplilearn.com/'

def get(self, url):
"""
Loads a web page in the current browser session.
"""
> self.execute(Command.GET, {'url': url})

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:333:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.chrome.webdriver.WebDriver (session="7643857c856eba21654096eb2db552ee")>
driver_command = 'get', params = {'url': 'https://www.simplilearn.com/'}

def execute(self, driver_command, params=None):
"""
Sends a command to be executed by a command.CommandExecutor.

:Args:
- driver_command: The name of the command to execute as a string.
- params: A dictionary of named parameters to send with the command.

:Returns:
The command's JSON response loaded into a dictionary object.
"""
if self.session_id is not None:
if not params:
params = {'sessionId': self.session_id}
elif 'sessionId' not in params:
params['sessionId'] = self.session_id

params = self._wrap_value(params)
response = self.command_executor.execute(driver_command, params)
if response:
> self.error_handler.check_response(response)

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:321:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x000002189862D550>
response = {'status': 404, 'value': '{"value":{"error":"no such window","message":"no such window: target window already closed\\...\n\\tRtlGetAppContainerNamedObjectPath [0x77187BBE+286]\\n\\tRtlGetAppContainerNamedObjectPath [0x77187B8E+238]\\n"}}'}

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 = InvalidCookieDomainException
elif status in ErrorCode.UNABLE_TO_SET_COOKIE:
exception_class = UnableToSetCookieException
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
elif status in ErrorCode.JAVASCRIPT_ERROR:
exception_class = JavascriptException
elif status in ErrorCode.SESSION_NOT_CREATED:
exception_class = SessionNotCreatedException
elif status in ErrorCode.INVALID_ARGUMENT:
exception_class = InvalidArgumentException
elif status in ErrorCode.NO_SUCH_COOKIE:
exception_class = NoSuchCookieException
elif status in ErrorCode.UNABLE_TO_CAPTURE_SCREEN:
exception_class = ScreenshotException
elif status in ErrorCode.ELEMENT_CLICK_INTERCEPTED:
exception_class = ElementClickInterceptedException
elif status in ErrorCode.INSECURE_CERTIFICATE:
exception_class = InsecureCertificateException
elif status in ErrorCode.INVALID_COORDINATES:
exception_class = InvalidCoordinatesException
elif status in ErrorCode.INVALID_SESSION_ID:
exception_class = InvalidSessionIdException
elif status in ErrorCode.UNKNOWN_METHOD:
exception_class = UnknownMethodException
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:
alert_text = None
if 'data' in value:
alert_text = value['data'].get('text')
elif 'alert' in value:
alert_text = value['alert'].get('text')
raise exception_class(message, screen, stacktrace, alert_text)
> raise exception_class(message, screen, stacktrace)
E selenium.common.exceptions.NoSuchWindowException: Message: no such window: target window already closed
E from unknown error: web view not found
E (Session info: chrome=110.0.5481.100)

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py:242: NoSuchWindowException

During handling of the above exception, another exception occurred:

self = <test_SL_footer_check.TestSLFooterCheck object at 0x0000021898BCDA00>, value = 'Contact us'
initialize_pages = None

@pytest.mark.test_details("SLUB-T0000","high","Sl Footer Check","Pradeep")
@pytest.mark.parametrize("value",_create_parameterised_data())
def test_SL_Footer_check(self,value,initialize_pages):
try:
logging.info(value)
with open('sl_footer_check_test_data.csv', 'r') as csv_file:
csv_data = csv.reader(csv_file)
for line in csv_data:
if line[0] == value:
url = line[1]
logging.info(f"URL for {value} is : {url}")
break

pytest.driver.get(pytest.config['prod_url'])
selenium_helper.wait_for_page_to_load(20,pytest.config['prod_url'])
dynamic_locator = f"(//div[starts-with(@class,'col-md-2')]//a[@title='{value}'])[1]"
logging.info(f"Dynamic Locator : {dynamic_locator}")
time.sleep(3)
WebDriverWait(pytest.driver, 20).until(EC.element_to_be_clickable((By.XPATH, dynamic_locator))).scroll_to_element()
time.sleep(2)
default_window = pytest.driver.current_window_handle
pytest.driver.find_element(By.XPATH,dynamic_locator).click()
time.sleep(5)
window_handle = list(pytest.driver.window_handles)
if len(window_handle) > 1:
pytest.driver.close()
pytest.driver.switch_to.window(window_handle[-1])

url_opened,message = self.check_redirection(value,url)
rows = [[value,url,url_opened,message]]
with open("Report.csv", 'a', newline='\n') as csvfile:
csvwriter = csv.writer(csvfile)
csvwriter.writerows(rows)
if 'Not Working' in message:
pytest.driver.get_screenshot_as_file(os.path.join(os.path.dirname(os.curdir), "report\screenshot", f"{__name__}_{value}.jpeg"))
pytest.fail()

except:
logging.info("Exception Occurred", exc_info=True)
> pytest.driver.get_screenshot_as_file(os.path.join(os.path.dirname(os.curdir), "report\screenshot", f"{__name__}_{value}.jpeg"))

test_prod\test_SL_footer_check.py:265:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:1032: in get_screenshot_as_file
png = self.get_screenshot_as_png()
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:1064: in get_screenshot_as_png
return base64.b64decode(self.get_screenshot_as_base64().encode('ascii'))
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:1074: in get_screenshot_as_base64
return self.execute(Command.SCREENSHOT)['value']
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:321: in execute
self.error_handler.check_response(response)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x000002189862D550>
response = {'status': 404, 'value': '{"value":{"error":"no such window","message":"no such window: target window already closed\\...\n\\tRtlGetAppContainerNamedObjectPath [0x77187BBE+286]\\n\\tRtlGetAppContainerNamedObjectPath [0x77187B8E+238]\\n"}}'}

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 = InvalidCookieDomainException
elif status in ErrorCode.UNABLE_TO_SET_COOKIE:
exception_class = UnableToSetCookieException
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
elif status in ErrorCode.JAVASCRIPT_ERROR:
exception_class = JavascriptException
elif status in ErrorCode.SESSION_NOT_CREATED:
exception_class = SessionNotCreatedException
elif status in ErrorCode.INVALID_ARGUMENT:
exception_class = InvalidArgumentException
elif status in ErrorCode.NO_SUCH_COOKIE:
exception_class = NoSuchCookieException
elif status in ErrorCode.UNABLE_TO_CAPTURE_SCREEN:
exception_class = ScreenshotException
elif status in ErrorCode.ELEMENT_CLICK_INTERCEPTED:
exception_class = ElementClickInterceptedException
elif status in ErrorCode.INSECURE_CERTIFICATE:
exception_class = InsecureCertificateException
elif status in ErrorCode.INVALID_COORDINATES:
exception_class = InvalidCoordinatesException
elif status in ErrorCode.INVALID_SESSION_ID:
exception_class = InvalidSessionIdException
elif status in ErrorCode.UNKNOWN_METHOD:
exception_class = UnknownMethodException
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:
alert_text = None
if 'data' in value:
alert_text = value['data'].get('text')
elif 'alert' in value:
alert_text = value['alert'].get('text')
raise exception_class(message, screen, stacktrace, alert_text)
> raise exception_class(message, screen, stacktrace)
E selenium.common.exceptions.NoSuchWindowException: Message: no such window: target window already closed
E from unknown error: web view not found
E (Session info: chrome=110.0.5481.100)

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py:242: NoSuchWindowException
-------------------------------Captured log call--------------------------------
INFO  setup:test_SL_footer_check.py:230 Contact us INFO  setup:test_SL_footer_check.py:236 URL for Contact us is : https://www.simplilearn.com/contact-us INFO  setup:test_SL_footer_check.py:264 Exception Occurred Traceback (most recent call last): File "C:\test_repos\pre_sales_test_python\test_prod\test_SL_footer_check.py", line 239, in test_SL_Footer_check pytest.driver.get(pytest.config['prod_url']) File "c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 333, in get self.execute(Command.GET, {'url': url}) File "c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute self.error_handler.check_response(response) File "c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.NoSuchWindowException: Message: no such window: target window already closed from unknown error: web view not found (Session info: chrome=110.0.5481.100)
Failed test_SL_footer_check.py::TestSLFooterCheck::test_SL_Footer_check[Become an instructor] 0.00
self = <test_SL_footer_check.TestSLFooterCheck object at 0x0000021898BE46D0>, value = 'Become an instructor'
initialize_pages = None

@pytest.mark.test_details("SLUB-T0000","high","Sl Footer Check","Pradeep")
@pytest.mark.parametrize("value",_create_parameterised_data())
def test_SL_Footer_check(self,value,initialize_pages):
try:
logging.info(value)
with open('sl_footer_check_test_data.csv', 'r') as csv_file:
csv_data = csv.reader(csv_file)
for line in csv_data:
if line[0] == value:
url = line[1]
logging.info(f"URL for {value} is : {url}")
break

> pytest.driver.get(pytest.config['prod_url'])

test_prod\test_SL_footer_check.py:239:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.chrome.webdriver.WebDriver (session="7643857c856eba21654096eb2db552ee")>
url = 'https://www.simplilearn.com/'

def get(self, url):
"""
Loads a web page in the current browser session.
"""
> self.execute(Command.GET, {'url': url})

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:333:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.chrome.webdriver.WebDriver (session="7643857c856eba21654096eb2db552ee")>
driver_command = 'get', params = {'url': 'https://www.simplilearn.com/'}

def execute(self, driver_command, params=None):
"""
Sends a command to be executed by a command.CommandExecutor.

:Args:
- driver_command: The name of the command to execute as a string.
- params: A dictionary of named parameters to send with the command.

:Returns:
The command's JSON response loaded into a dictionary object.
"""
if self.session_id is not None:
if not params:
params = {'sessionId': self.session_id}
elif 'sessionId' not in params:
params['sessionId'] = self.session_id

params = self._wrap_value(params)
response = self.command_executor.execute(driver_command, params)
if response:
> self.error_handler.check_response(response)

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:321:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x000002189862D550>
response = {'status': 404, 'value': '{"value":{"error":"no such window","message":"no such window: target window already closed\\...\n\\tRtlGetAppContainerNamedObjectPath [0x77187BBE+286]\\n\\tRtlGetAppContainerNamedObjectPath [0x77187B8E+238]\\n"}}'}

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 = InvalidCookieDomainException
elif status in ErrorCode.UNABLE_TO_SET_COOKIE:
exception_class = UnableToSetCookieException
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
elif status in ErrorCode.JAVASCRIPT_ERROR:
exception_class = JavascriptException
elif status in ErrorCode.SESSION_NOT_CREATED:
exception_class = SessionNotCreatedException
elif status in ErrorCode.INVALID_ARGUMENT:
exception_class = InvalidArgumentException
elif status in ErrorCode.NO_SUCH_COOKIE:
exception_class = NoSuchCookieException
elif status in ErrorCode.UNABLE_TO_CAPTURE_SCREEN:
exception_class = ScreenshotException
elif status in ErrorCode.ELEMENT_CLICK_INTERCEPTED:
exception_class = ElementClickInterceptedException
elif status in ErrorCode.INSECURE_CERTIFICATE:
exception_class = InsecureCertificateException
elif status in ErrorCode.INVALID_COORDINATES:
exception_class = InvalidCoordinatesException
elif status in ErrorCode.INVALID_SESSION_ID:
exception_class = InvalidSessionIdException
elif status in ErrorCode.UNKNOWN_METHOD:
exception_class = UnknownMethodException
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:
alert_text = None
if 'data' in value:
alert_text = value['data'].get('text')
elif 'alert' in value:
alert_text = value['alert'].get('text')
raise exception_class(message, screen, stacktrace, alert_text)
> raise exception_class(message, screen, stacktrace)
E selenium.common.exceptions.NoSuchWindowException: Message: no such window: target window already closed
E from unknown error: web view not found
E (Session info: chrome=110.0.5481.100)

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py:242: NoSuchWindowException

During handling of the above exception, another exception occurred:

self = <test_SL_footer_check.TestSLFooterCheck object at 0x0000021898BE46D0>, value = 'Become an instructor'
initialize_pages = None

@pytest.mark.test_details("SLUB-T0000","high","Sl Footer Check","Pradeep")
@pytest.mark.parametrize("value",_create_parameterised_data())
def test_SL_Footer_check(self,value,initialize_pages):
try:
logging.info(value)
with open('sl_footer_check_test_data.csv', 'r') as csv_file:
csv_data = csv.reader(csv_file)
for line in csv_data:
if line[0] == value:
url = line[1]
logging.info(f"URL for {value} is : {url}")
break

pytest.driver.get(pytest.config['prod_url'])
selenium_helper.wait_for_page_to_load(20,pytest.config['prod_url'])
dynamic_locator = f"(//div[starts-with(@class,'col-md-2')]//a[@title='{value}'])[1]"
logging.info(f"Dynamic Locator : {dynamic_locator}")
time.sleep(3)
WebDriverWait(pytest.driver, 20).until(EC.element_to_be_clickable((By.XPATH, dynamic_locator))).scroll_to_element()
time.sleep(2)
default_window = pytest.driver.current_window_handle
pytest.driver.find_element(By.XPATH,dynamic_locator).click()
time.sleep(5)
window_handle = list(pytest.driver.window_handles)
if len(window_handle) > 1:
pytest.driver.close()
pytest.driver.switch_to.window(window_handle[-1])

url_opened,message = self.check_redirection(value,url)
rows = [[value,url,url_opened,message]]
with open("Report.csv", 'a', newline='\n') as csvfile:
csvwriter = csv.writer(csvfile)
csvwriter.writerows(rows)
if 'Not Working' in message:
pytest.driver.get_screenshot_as_file(os.path.join(os.path.dirname(os.curdir), "report\screenshot", f"{__name__}_{value}.jpeg"))
pytest.fail()

except:
logging.info("Exception Occurred", exc_info=True)
> pytest.driver.get_screenshot_as_file(os.path.join(os.path.dirname(os.curdir), "report\screenshot", f"{__name__}_{value}.jpeg"))

test_prod\test_SL_footer_check.py:265:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:1032: in get_screenshot_as_file
png = self.get_screenshot_as_png()
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:1064: in get_screenshot_as_png
return base64.b64decode(self.get_screenshot_as_base64().encode('ascii'))
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:1074: in get_screenshot_as_base64
return self.execute(Command.SCREENSHOT)['value']
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:321: in execute
self.error_handler.check_response(response)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x000002189862D550>
response = {'status': 404, 'value': '{"value":{"error":"no such window","message":"no such window: target window already closed\\...\n\\tRtlGetAppContainerNamedObjectPath [0x77187BBE+286]\\n\\tRtlGetAppContainerNamedObjectPath [0x77187B8E+238]\\n"}}'}

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 = InvalidCookieDomainException
elif status in ErrorCode.UNABLE_TO_SET_COOKIE:
exception_class = UnableToSetCookieException
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
elif status in ErrorCode.JAVASCRIPT_ERROR:
exception_class = JavascriptException
elif status in ErrorCode.SESSION_NOT_CREATED:
exception_class = SessionNotCreatedException
elif status in ErrorCode.INVALID_ARGUMENT:
exception_class = InvalidArgumentException
elif status in ErrorCode.NO_SUCH_COOKIE:
exception_class = NoSuchCookieException
elif status in ErrorCode.UNABLE_TO_CAPTURE_SCREEN:
exception_class = ScreenshotException
elif status in ErrorCode.ELEMENT_CLICK_INTERCEPTED:
exception_class = ElementClickInterceptedException
elif status in ErrorCode.INSECURE_CERTIFICATE:
exception_class = InsecureCertificateException
elif status in ErrorCode.INVALID_COORDINATES:
exception_class = InvalidCoordinatesException
elif status in ErrorCode.INVALID_SESSION_ID:
exception_class = InvalidSessionIdException
elif status in ErrorCode.UNKNOWN_METHOD:
exception_class = UnknownMethodException
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:
alert_text = None
if 'data' in value:
alert_text = value['data'].get('text')
elif 'alert' in value:
alert_text = value['alert'].get('text')
raise exception_class(message, screen, stacktrace, alert_text)
> raise exception_class(message, screen, stacktrace)
E selenium.common.exceptions.NoSuchWindowException: Message: no such window: target window already closed
E from unknown error: web view not found
E (Session info: chrome=110.0.5481.100)

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py:242: NoSuchWindowException
-------------------------------Captured log call--------------------------------
INFO  setup:test_SL_footer_check.py:230 Become an instructor INFO  setup:test_SL_footer_check.py:236 URL for Become an instructor is : https://www.simplilearn.com/become-our-trainer INFO  setup:test_SL_footer_check.py:264 Exception Occurred Traceback (most recent call last): File "C:\test_repos\pre_sales_test_python\test_prod\test_SL_footer_check.py", line 239, in test_SL_Footer_check pytest.driver.get(pytest.config['prod_url']) File "c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 333, in get self.execute(Command.GET, {'url': url}) File "c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute self.error_handler.check_response(response) File "c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.NoSuchWindowException: Message: no such window: target window already closed from unknown error: web view not found (Session info: chrome=110.0.5481.100)
Failed test_SL_footer_check.py::TestSLFooterCheck::test_SL_Footer_check[Blog as guest] 0.00
self = <test_SL_footer_check.TestSLFooterCheck object at 0x0000021898CC7EB0>, value = 'Blog as guest'
initialize_pages = None

@pytest.mark.test_details("SLUB-T0000","high","Sl Footer Check","Pradeep")
@pytest.mark.parametrize("value",_create_parameterised_data())
def test_SL_Footer_check(self,value,initialize_pages):
try:
logging.info(value)
with open('sl_footer_check_test_data.csv', 'r') as csv_file:
csv_data = csv.reader(csv_file)
for line in csv_data:
if line[0] == value:
url = line[1]
logging.info(f"URL for {value} is : {url}")
break

> pytest.driver.get(pytest.config['prod_url'])

test_prod\test_SL_footer_check.py:239:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.chrome.webdriver.WebDriver (session="7643857c856eba21654096eb2db552ee")>
url = 'https://www.simplilearn.com/'

def get(self, url):
"""
Loads a web page in the current browser session.
"""
> self.execute(Command.GET, {'url': url})

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:333:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.chrome.webdriver.WebDriver (session="7643857c856eba21654096eb2db552ee")>
driver_command = 'get', params = {'url': 'https://www.simplilearn.com/'}

def execute(self, driver_command, params=None):
"""
Sends a command to be executed by a command.CommandExecutor.

:Args:
- driver_command: The name of the command to execute as a string.
- params: A dictionary of named parameters to send with the command.

:Returns:
The command's JSON response loaded into a dictionary object.
"""
if self.session_id is not None:
if not params:
params = {'sessionId': self.session_id}
elif 'sessionId' not in params:
params['sessionId'] = self.session_id

params = self._wrap_value(params)
response = self.command_executor.execute(driver_command, params)
if response:
> self.error_handler.check_response(response)

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:321:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x000002189862D550>
response = {'status': 404, 'value': '{"value":{"error":"no such window","message":"no such window: target window already closed\\...\n\\tRtlGetAppContainerNamedObjectPath [0x77187BBE+286]\\n\\tRtlGetAppContainerNamedObjectPath [0x77187B8E+238]\\n"}}'}

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 = InvalidCookieDomainException
elif status in ErrorCode.UNABLE_TO_SET_COOKIE:
exception_class = UnableToSetCookieException
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
elif status in ErrorCode.JAVASCRIPT_ERROR:
exception_class = JavascriptException
elif status in ErrorCode.SESSION_NOT_CREATED:
exception_class = SessionNotCreatedException
elif status in ErrorCode.INVALID_ARGUMENT:
exception_class = InvalidArgumentException
elif status in ErrorCode.NO_SUCH_COOKIE:
exception_class = NoSuchCookieException
elif status in ErrorCode.UNABLE_TO_CAPTURE_SCREEN:
exception_class = ScreenshotException
elif status in ErrorCode.ELEMENT_CLICK_INTERCEPTED:
exception_class = ElementClickInterceptedException
elif status in ErrorCode.INSECURE_CERTIFICATE:
exception_class = InsecureCertificateException
elif status in ErrorCode.INVALID_COORDINATES:
exception_class = InvalidCoordinatesException
elif status in ErrorCode.INVALID_SESSION_ID:
exception_class = InvalidSessionIdException
elif status in ErrorCode.UNKNOWN_METHOD:
exception_class = UnknownMethodException
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:
alert_text = None
if 'data' in value:
alert_text = value['data'].get('text')
elif 'alert' in value:
alert_text = value['alert'].get('text')
raise exception_class(message, screen, stacktrace, alert_text)
> raise exception_class(message, screen, stacktrace)
E selenium.common.exceptions.NoSuchWindowException: Message: no such window: target window already closed
E from unknown error: web view not found
E (Session info: chrome=110.0.5481.100)

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py:242: NoSuchWindowException

During handling of the above exception, another exception occurred:

self = <test_SL_footer_check.TestSLFooterCheck object at 0x0000021898CC7EB0>, value = 'Blog as guest'
initialize_pages = None

@pytest.mark.test_details("SLUB-T0000","high","Sl Footer Check","Pradeep")
@pytest.mark.parametrize("value",_create_parameterised_data())
def test_SL_Footer_check(self,value,initialize_pages):
try:
logging.info(value)
with open('sl_footer_check_test_data.csv', 'r') as csv_file:
csv_data = csv.reader(csv_file)
for line in csv_data:
if line[0] == value:
url = line[1]
logging.info(f"URL for {value} is : {url}")
break

pytest.driver.get(pytest.config['prod_url'])
selenium_helper.wait_for_page_to_load(20,pytest.config['prod_url'])
dynamic_locator = f"(//div[starts-with(@class,'col-md-2')]//a[@title='{value}'])[1]"
logging.info(f"Dynamic Locator : {dynamic_locator}")
time.sleep(3)
WebDriverWait(pytest.driver, 20).until(EC.element_to_be_clickable((By.XPATH, dynamic_locator))).scroll_to_element()
time.sleep(2)
default_window = pytest.driver.current_window_handle
pytest.driver.find_element(By.XPATH,dynamic_locator).click()
time.sleep(5)
window_handle = list(pytest.driver.window_handles)
if len(window_handle) > 1:
pytest.driver.close()
pytest.driver.switch_to.window(window_handle[-1])

url_opened,message = self.check_redirection(value,url)
rows = [[value,url,url_opened,message]]
with open("Report.csv", 'a', newline='\n') as csvfile:
csvwriter = csv.writer(csvfile)
csvwriter.writerows(rows)
if 'Not Working' in message:
pytest.driver.get_screenshot_as_file(os.path.join(os.path.dirname(os.curdir), "report\screenshot", f"{__name__}_{value}.jpeg"))
pytest.fail()

except:
logging.info("Exception Occurred", exc_info=True)
> pytest.driver.get_screenshot_as_file(os.path.join(os.path.dirname(os.curdir), "report\screenshot", f"{__name__}_{value}.jpeg"))

test_prod\test_SL_footer_check.py:265:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:1032: in get_screenshot_as_file
png = self.get_screenshot_as_png()
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:1064: in get_screenshot_as_png
return base64.b64decode(self.get_screenshot_as_base64().encode('ascii'))
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:1074: in get_screenshot_as_base64
return self.execute(Command.SCREENSHOT)['value']
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:321: in execute
self.error_handler.check_response(response)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x000002189862D550>
response = {'status': 404, 'value': '{"value":{"error":"no such window","message":"no such window: target window already closed\\...\n\\tRtlGetAppContainerNamedObjectPath [0x77187BBE+286]\\n\\tRtlGetAppContainerNamedObjectPath [0x77187B8E+238]\\n"}}'}

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 = InvalidCookieDomainException
elif status in ErrorCode.UNABLE_TO_SET_COOKIE:
exception_class = UnableToSetCookieException
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
elif status in ErrorCode.JAVASCRIPT_ERROR:
exception_class = JavascriptException
elif status in ErrorCode.SESSION_NOT_CREATED:
exception_class = SessionNotCreatedException
elif status in ErrorCode.INVALID_ARGUMENT:
exception_class = InvalidArgumentException
elif status in ErrorCode.NO_SUCH_COOKIE:
exception_class = NoSuchCookieException
elif status in ErrorCode.UNABLE_TO_CAPTURE_SCREEN:
exception_class = ScreenshotException
elif status in ErrorCode.ELEMENT_CLICK_INTERCEPTED:
exception_class = ElementClickInterceptedException
elif status in ErrorCode.INSECURE_CERTIFICATE:
exception_class = InsecureCertificateException
elif status in ErrorCode.INVALID_COORDINATES:
exception_class = InvalidCoordinatesException
elif status in ErrorCode.INVALID_SESSION_ID:
exception_class = InvalidSessionIdException
elif status in ErrorCode.UNKNOWN_METHOD:
exception_class = UnknownMethodException
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:
alert_text = None
if 'data' in value:
alert_text = value['data'].get('text')
elif 'alert' in value:
alert_text = value['alert'].get('text')
raise exception_class(message, screen, stacktrace, alert_text)
> raise exception_class(message, screen, stacktrace)
E selenium.common.exceptions.NoSuchWindowException: Message: no such window: target window already closed
E from unknown error: web view not found
E (Session info: chrome=110.0.5481.100)

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py:242: NoSuchWindowException
-------------------------------Captured log call--------------------------------
INFO  setup:test_SL_footer_check.py:230 Blog as guest INFO  setup:test_SL_footer_check.py:236 URL for Blog as guest is : https://www.simplilearn.com/guest-blogging INFO  setup:test_SL_footer_check.py:264 Exception Occurred Traceback (most recent call last): File "C:\test_repos\pre_sales_test_python\test_prod\test_SL_footer_check.py", line 239, in test_SL_Footer_check pytest.driver.get(pytest.config['prod_url']) File "c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 333, in get self.execute(Command.GET, {'url': url}) File "c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute self.error_handler.check_response(response) File "c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.NoSuchWindowException: Message: no such window: target window already closed from unknown error: web view not found (Session info: chrome=110.0.5481.100)
Failed test_SL_footer_check.py::TestSLFooterCheck::test_SL_Footer_check[Skillup] 0.00
self = <test_SL_footer_check.TestSLFooterCheck object at 0x0000021898C63C10>, value = 'Skillup', initialize_pages = None

@pytest.mark.test_details("SLUB-T0000","high","Sl Footer Check","Pradeep")
@pytest.mark.parametrize("value",_create_parameterised_data())
def test_SL_Footer_check(self,value,initialize_pages):
try:
logging.info(value)
with open('sl_footer_check_test_data.csv', 'r') as csv_file:
csv_data = csv.reader(csv_file)
for line in csv_data:
if line[0] == value:
url = line[1]
logging.info(f"URL for {value} is : {url}")
break

> pytest.driver.get(pytest.config['prod_url'])

test_prod\test_SL_footer_check.py:239:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.chrome.webdriver.WebDriver (session="7643857c856eba21654096eb2db552ee")>
url = 'https://www.simplilearn.com/'

def get(self, url):
"""
Loads a web page in the current browser session.
"""
> self.execute(Command.GET, {'url': url})

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:333:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.chrome.webdriver.WebDriver (session="7643857c856eba21654096eb2db552ee")>
driver_command = 'get', params = {'url': 'https://www.simplilearn.com/'}

def execute(self, driver_command, params=None):
"""
Sends a command to be executed by a command.CommandExecutor.

:Args:
- driver_command: The name of the command to execute as a string.
- params: A dictionary of named parameters to send with the command.

:Returns:
The command's JSON response loaded into a dictionary object.
"""
if self.session_id is not None:
if not params:
params = {'sessionId': self.session_id}
elif 'sessionId' not in params:
params['sessionId'] = self.session_id

params = self._wrap_value(params)
response = self.command_executor.execute(driver_command, params)
if response:
> self.error_handler.check_response(response)

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:321:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x000002189862D550>
response = {'status': 404, 'value': '{"value":{"error":"no such window","message":"no such window: target window already closed\\...\n\\tRtlGetAppContainerNamedObjectPath [0x77187BBE+286]\\n\\tRtlGetAppContainerNamedObjectPath [0x77187B8E+238]\\n"}}'}

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 = InvalidCookieDomainException
elif status in ErrorCode.UNABLE_TO_SET_COOKIE:
exception_class = UnableToSetCookieException
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
elif status in ErrorCode.JAVASCRIPT_ERROR:
exception_class = JavascriptException
elif status in ErrorCode.SESSION_NOT_CREATED:
exception_class = SessionNotCreatedException
elif status in ErrorCode.INVALID_ARGUMENT:
exception_class = InvalidArgumentException
elif status in ErrorCode.NO_SUCH_COOKIE:
exception_class = NoSuchCookieException
elif status in ErrorCode.UNABLE_TO_CAPTURE_SCREEN:
exception_class = ScreenshotException
elif status in ErrorCode.ELEMENT_CLICK_INTERCEPTED:
exception_class = ElementClickInterceptedException
elif status in ErrorCode.INSECURE_CERTIFICATE:
exception_class = InsecureCertificateException
elif status in ErrorCode.INVALID_COORDINATES:
exception_class = InvalidCoordinatesException
elif status in ErrorCode.INVALID_SESSION_ID:
exception_class = InvalidSessionIdException
elif status in ErrorCode.UNKNOWN_METHOD:
exception_class = UnknownMethodException
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:
alert_text = None
if 'data' in value:
alert_text = value['data'].get('text')
elif 'alert' in value:
alert_text = value['alert'].get('text')
raise exception_class(message, screen, stacktrace, alert_text)
> raise exception_class(message, screen, stacktrace)
E selenium.common.exceptions.NoSuchWindowException: Message: no such window: target window already closed
E from unknown error: web view not found
E (Session info: chrome=110.0.5481.100)

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py:242: NoSuchWindowException

During handling of the above exception, another exception occurred:

self = <test_SL_footer_check.TestSLFooterCheck object at 0x0000021898C63C10>, value = 'Skillup', initialize_pages = None

@pytest.mark.test_details("SLUB-T0000","high","Sl Footer Check","Pradeep")
@pytest.mark.parametrize("value",_create_parameterised_data())
def test_SL_Footer_check(self,value,initialize_pages):
try:
logging.info(value)
with open('sl_footer_check_test_data.csv', 'r') as csv_file:
csv_data = csv.reader(csv_file)
for line in csv_data:
if line[0] == value:
url = line[1]
logging.info(f"URL for {value} is : {url}")
break

pytest.driver.get(pytest.config['prod_url'])
selenium_helper.wait_for_page_to_load(20,pytest.config['prod_url'])
dynamic_locator = f"(//div[starts-with(@class,'col-md-2')]//a[@title='{value}'])[1]"
logging.info(f"Dynamic Locator : {dynamic_locator}")
time.sleep(3)
WebDriverWait(pytest.driver, 20).until(EC.element_to_be_clickable((By.XPATH, dynamic_locator))).scroll_to_element()
time.sleep(2)
default_window = pytest.driver.current_window_handle
pytest.driver.find_element(By.XPATH,dynamic_locator).click()
time.sleep(5)
window_handle = list(pytest.driver.window_handles)
if len(window_handle) > 1:
pytest.driver.close()
pytest.driver.switch_to.window(window_handle[-1])

url_opened,message = self.check_redirection(value,url)
rows = [[value,url,url_opened,message]]
with open("Report.csv", 'a', newline='\n') as csvfile:
csvwriter = csv.writer(csvfile)
csvwriter.writerows(rows)
if 'Not Working' in message:
pytest.driver.get_screenshot_as_file(os.path.join(os.path.dirname(os.curdir), "report\screenshot", f"{__name__}_{value}.jpeg"))
pytest.fail()

except:
logging.info("Exception Occurred", exc_info=True)
> pytest.driver.get_screenshot_as_file(os.path.join(os.path.dirname(os.curdir), "report\screenshot", f"{__name__}_{value}.jpeg"))

test_prod\test_SL_footer_check.py:265:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:1032: in get_screenshot_as_file
png = self.get_screenshot_as_png()
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:1064: in get_screenshot_as_png
return base64.b64decode(self.get_screenshot_as_base64().encode('ascii'))
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:1074: in get_screenshot_as_base64
return self.execute(Command.SCREENSHOT)['value']
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:321: in execute
self.error_handler.check_response(response)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x000002189862D550>
response = {'status': 404, 'value': '{"value":{"error":"no such window","message":"no such window: target window already closed\\...\n\\tRtlGetAppContainerNamedObjectPath [0x77187BBE+286]\\n\\tRtlGetAppContainerNamedObjectPath [0x77187B8E+238]\\n"}}'}

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 = InvalidCookieDomainException
elif status in ErrorCode.UNABLE_TO_SET_COOKIE:
exception_class = UnableToSetCookieException
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
elif status in ErrorCode.JAVASCRIPT_ERROR:
exception_class = JavascriptException
elif status in ErrorCode.SESSION_NOT_CREATED:
exception_class = SessionNotCreatedException
elif status in ErrorCode.INVALID_ARGUMENT:
exception_class = InvalidArgumentException
elif status in ErrorCode.NO_SUCH_COOKIE:
exception_class = NoSuchCookieException
elif status in ErrorCode.UNABLE_TO_CAPTURE_SCREEN:
exception_class = ScreenshotException
elif status in ErrorCode.ELEMENT_CLICK_INTERCEPTED:
exception_class = ElementClickInterceptedException
elif status in ErrorCode.INSECURE_CERTIFICATE:
exception_class = InsecureCertificateException
elif status in ErrorCode.INVALID_COORDINATES:
exception_class = InvalidCoordinatesException
elif status in ErrorCode.INVALID_SESSION_ID:
exception_class = InvalidSessionIdException
elif status in ErrorCode.UNKNOWN_METHOD:
exception_class = UnknownMethodException
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:
alert_text = None
if 'data' in value:
alert_text = value['data'].get('text')
elif 'alert' in value:
alert_text = value['alert'].get('text')
raise exception_class(message, screen, stacktrace, alert_text)
> raise exception_class(message, screen, stacktrace)
E selenium.common.exceptions.NoSuchWindowException: Message: no such window: target window already closed
E from unknown error: web view not found
E (Session info: chrome=110.0.5481.100)

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py:242: NoSuchWindowException
-------------------------------Captured log call--------------------------------
INFO  setup:test_SL_footer_check.py:230 Skillup INFO  setup:test_SL_footer_check.py:236 URL for Skillup is : https://www.simplilearn.com/skillup-free-online-courses INFO  setup:test_SL_footer_check.py:264 Exception Occurred Traceback (most recent call last): File "C:\test_repos\pre_sales_test_python\test_prod\test_SL_footer_check.py", line 239, in test_SL_Footer_check pytest.driver.get(pytest.config['prod_url']) File "c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 333, in get self.execute(Command.GET, {'url': url}) File "c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute self.error_handler.check_response(response) File "c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.NoSuchWindowException: Message: no such window: target window already closed from unknown error: web view not found (Session info: chrome=110.0.5481.100)
Failed test_SL_footer_check.py::TestSLFooterCheck::test_SL_Footer_check[Skillup Sitemap] 0.00
self = <test_SL_footer_check.TestSLFooterCheck object at 0x0000021898DC8910>, value = 'Skillup Sitemap'
initialize_pages = None

@pytest.mark.test_details("SLUB-T0000","high","Sl Footer Check","Pradeep")
@pytest.mark.parametrize("value",_create_parameterised_data())
def test_SL_Footer_check(self,value,initialize_pages):
try:
logging.info(value)
with open('sl_footer_check_test_data.csv', 'r') as csv_file:
csv_data = csv.reader(csv_file)
for line in csv_data:
if line[0] == value:
url = line[1]
logging.info(f"URL for {value} is : {url}")
break

> pytest.driver.get(pytest.config['prod_url'])

test_prod\test_SL_footer_check.py:239:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.chrome.webdriver.WebDriver (session="7643857c856eba21654096eb2db552ee")>
url = 'https://www.simplilearn.com/'

def get(self, url):
"""
Loads a web page in the current browser session.
"""
> self.execute(Command.GET, {'url': url})

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:333:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.chrome.webdriver.WebDriver (session="7643857c856eba21654096eb2db552ee")>
driver_command = 'get', params = {'url': 'https://www.simplilearn.com/'}

def execute(self, driver_command, params=None):
"""
Sends a command to be executed by a command.CommandExecutor.

:Args:
- driver_command: The name of the command to execute as a string.
- params: A dictionary of named parameters to send with the command.

:Returns:
The command's JSON response loaded into a dictionary object.
"""
if self.session_id is not None:
if not params:
params = {'sessionId': self.session_id}
elif 'sessionId' not in params:
params['sessionId'] = self.session_id

params = self._wrap_value(params)
response = self.command_executor.execute(driver_command, params)
if response:
> self.error_handler.check_response(response)

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:321:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x000002189862D550>
response = {'status': 404, 'value': '{"value":{"error":"no such window","message":"no such window: target window already closed\\...\n\\tRtlGetAppContainerNamedObjectPath [0x77187BBE+286]\\n\\tRtlGetAppContainerNamedObjectPath [0x77187B8E+238]\\n"}}'}

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 = InvalidCookieDomainException
elif status in ErrorCode.UNABLE_TO_SET_COOKIE:
exception_class = UnableToSetCookieException
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
elif status in ErrorCode.JAVASCRIPT_ERROR:
exception_class = JavascriptException
elif status in ErrorCode.SESSION_NOT_CREATED:
exception_class = SessionNotCreatedException
elif status in ErrorCode.INVALID_ARGUMENT:
exception_class = InvalidArgumentException
elif status in ErrorCode.NO_SUCH_COOKIE:
exception_class = NoSuchCookieException
elif status in ErrorCode.UNABLE_TO_CAPTURE_SCREEN:
exception_class = ScreenshotException
elif status in ErrorCode.ELEMENT_CLICK_INTERCEPTED:
exception_class = ElementClickInterceptedException
elif status in ErrorCode.INSECURE_CERTIFICATE:
exception_class = InsecureCertificateException
elif status in ErrorCode.INVALID_COORDINATES:
exception_class = InvalidCoordinatesException
elif status in ErrorCode.INVALID_SESSION_ID:
exception_class = InvalidSessionIdException
elif status in ErrorCode.UNKNOWN_METHOD:
exception_class = UnknownMethodException
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:
alert_text = None
if 'data' in value:
alert_text = value['data'].get('text')
elif 'alert' in value:
alert_text = value['alert'].get('text')
raise exception_class(message, screen, stacktrace, alert_text)
> raise exception_class(message, screen, stacktrace)
E selenium.common.exceptions.NoSuchWindowException: Message: no such window: target window already closed
E from unknown error: web view not found
E (Session info: chrome=110.0.5481.100)

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py:242: NoSuchWindowException

During handling of the above exception, another exception occurred:

self = <test_SL_footer_check.TestSLFooterCheck object at 0x0000021898DC8910>, value = 'Skillup Sitemap'
initialize_pages = None

@pytest.mark.test_details("SLUB-T0000","high","Sl Footer Check","Pradeep")
@pytest.mark.parametrize("value",_create_parameterised_data())
def test_SL_Footer_check(self,value,initialize_pages):
try:
logging.info(value)
with open('sl_footer_check_test_data.csv', 'r') as csv_file:
csv_data = csv.reader(csv_file)
for line in csv_data:
if line[0] == value:
url = line[1]
logging.info(f"URL for {value} is : {url}")
break

pytest.driver.get(pytest.config['prod_url'])
selenium_helper.wait_for_page_to_load(20,pytest.config['prod_url'])
dynamic_locator = f"(//div[starts-with(@class,'col-md-2')]//a[@title='{value}'])[1]"
logging.info(f"Dynamic Locator : {dynamic_locator}")
time.sleep(3)
WebDriverWait(pytest.driver, 20).until(EC.element_to_be_clickable((By.XPATH, dynamic_locator))).scroll_to_element()
time.sleep(2)
default_window = pytest.driver.current_window_handle
pytest.driver.find_element(By.XPATH,dynamic_locator).click()
time.sleep(5)
window_handle = list(pytest.driver.window_handles)
if len(window_handle) > 1:
pytest.driver.close()
pytest.driver.switch_to.window(window_handle[-1])

url_opened,message = self.check_redirection(value,url)
rows = [[value,url,url_opened,message]]
with open("Report.csv", 'a', newline='\n') as csvfile:
csvwriter = csv.writer(csvfile)
csvwriter.writerows(rows)
if 'Not Working' in message:
pytest.driver.get_screenshot_as_file(os.path.join(os.path.dirname(os.curdir), "report\screenshot", f"{__name__}_{value}.jpeg"))
pytest.fail()

except:
logging.info("Exception Occurred", exc_info=True)
> pytest.driver.get_screenshot_as_file(os.path.join(os.path.dirname(os.curdir), "report\screenshot", f"{__name__}_{value}.jpeg"))

test_prod\test_SL_footer_check.py:265:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:1032: in get_screenshot_as_file
png = self.get_screenshot_as_png()
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:1064: in get_screenshot_as_png
return base64.b64decode(self.get_screenshot_as_base64().encode('ascii'))
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:1074: in get_screenshot_as_base64
return self.execute(Command.SCREENSHOT)['value']
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:321: in execute
self.error_handler.check_response(response)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x000002189862D550>
response = {'status': 404, 'value': '{"value":{"error":"no such window","message":"no such window: target window already closed\\...\n\\tRtlGetAppContainerNamedObjectPath [0x77187BBE+286]\\n\\tRtlGetAppContainerNamedObjectPath [0x77187B8E+238]\\n"}}'}

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 = InvalidCookieDomainException
elif status in ErrorCode.UNABLE_TO_SET_COOKIE:
exception_class = UnableToSetCookieException
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
elif status in ErrorCode.JAVASCRIPT_ERROR:
exception_class = JavascriptException
elif status in ErrorCode.SESSION_NOT_CREATED:
exception_class = SessionNotCreatedException
elif status in ErrorCode.INVALID_ARGUMENT:
exception_class = InvalidArgumentException
elif status in ErrorCode.NO_SUCH_COOKIE:
exception_class = NoSuchCookieException
elif status in ErrorCode.UNABLE_TO_CAPTURE_SCREEN:
exception_class = ScreenshotException
elif status in ErrorCode.ELEMENT_CLICK_INTERCEPTED:
exception_class = ElementClickInterceptedException
elif status in ErrorCode.INSECURE_CERTIFICATE:
exception_class = InsecureCertificateException
elif status in ErrorCode.INVALID_COORDINATES:
exception_class = InvalidCoordinatesException
elif status in ErrorCode.INVALID_SESSION_ID:
exception_class = InvalidSessionIdException
elif status in ErrorCode.UNKNOWN_METHOD:
exception_class = UnknownMethodException
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:
alert_text = None
if 'data' in value:
alert_text = value['data'].get('text')
elif 'alert' in value:
alert_text = value['alert'].get('text')
raise exception_class(message, screen, stacktrace, alert_text)
> raise exception_class(message, screen, stacktrace)
E selenium.common.exceptions.NoSuchWindowException: Message: no such window: target window already closed
E from unknown error: web view not found
E (Session info: chrome=110.0.5481.100)

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py:242: NoSuchWindowException
-------------------------------Captured log call--------------------------------
INFO  setup:test_SL_footer_check.py:230 Skillup Sitemap INFO  setup:test_SL_footer_check.py:236 URL for Skillup Sitemap is : https://www.simplilearn.com/skillup-sitemap INFO  setup:test_SL_footer_check.py:264 Exception Occurred Traceback (most recent call last): File "C:\test_repos\pre_sales_test_python\test_prod\test_SL_footer_check.py", line 239, in test_SL_Footer_check pytest.driver.get(pytest.config['prod_url']) File "c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 333, in get self.execute(Command.GET, {'url': url}) File "c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute self.error_handler.check_response(response) File "c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.NoSuchWindowException: Message: no such window: target window already closed from unknown error: web view not found (Session info: chrome=110.0.5481.100)
Failed test_SL_footer_check.py::TestSLFooterCheck::test_SL_Footer_check[Resources] 0.00
self = <test_SL_footer_check.TestSLFooterCheck object at 0x0000021898DC7730>, value = 'Resources'
initialize_pages = None

@pytest.mark.test_details("SLUB-T0000","high","Sl Footer Check","Pradeep")
@pytest.mark.parametrize("value",_create_parameterised_data())
def test_SL_Footer_check(self,value,initialize_pages):
try:
logging.info(value)
with open('sl_footer_check_test_data.csv', 'r') as csv_file:
csv_data = csv.reader(csv_file)
for line in csv_data:
if line[0] == value:
url = line[1]
logging.info(f"URL for {value} is : {url}")
break

> pytest.driver.get(pytest.config['prod_url'])

test_prod\test_SL_footer_check.py:239:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.chrome.webdriver.WebDriver (session="7643857c856eba21654096eb2db552ee")>
url = 'https://www.simplilearn.com/'

def get(self, url):
"""
Loads a web page in the current browser session.
"""
> self.execute(Command.GET, {'url': url})

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:333:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.chrome.webdriver.WebDriver (session="7643857c856eba21654096eb2db552ee")>
driver_command = 'get', params = {'url': 'https://www.simplilearn.com/'}

def execute(self, driver_command, params=None):
"""
Sends a command to be executed by a command.CommandExecutor.

:Args:
- driver_command: The name of the command to execute as a string.
- params: A dictionary of named parameters to send with the command.

:Returns:
The command's JSON response loaded into a dictionary object.
"""
if self.session_id is not None:
if not params:
params = {'sessionId': self.session_id}
elif 'sessionId' not in params:
params['sessionId'] = self.session_id

params = self._wrap_value(params)
response = self.command_executor.execute(driver_command, params)
if response:
> self.error_handler.check_response(response)

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:321:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x000002189862D550>
response = {'status': 404, 'value': '{"value":{"error":"no such window","message":"no such window: target window already closed\\...\n\\tRtlGetAppContainerNamedObjectPath [0x77187BBE+286]\\n\\tRtlGetAppContainerNamedObjectPath [0x77187B8E+238]\\n"}}'}

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 = InvalidCookieDomainException
elif status in ErrorCode.UNABLE_TO_SET_COOKIE:
exception_class = UnableToSetCookieException
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
elif status in ErrorCode.JAVASCRIPT_ERROR:
exception_class = JavascriptException
elif status in ErrorCode.SESSION_NOT_CREATED:
exception_class = SessionNotCreatedException
elif status in ErrorCode.INVALID_ARGUMENT:
exception_class = InvalidArgumentException
elif status in ErrorCode.NO_SUCH_COOKIE:
exception_class = NoSuchCookieException
elif status in ErrorCode.UNABLE_TO_CAPTURE_SCREEN:
exception_class = ScreenshotException
elif status in ErrorCode.ELEMENT_CLICK_INTERCEPTED:
exception_class = ElementClickInterceptedException
elif status in ErrorCode.INSECURE_CERTIFICATE:
exception_class = InsecureCertificateException
elif status in ErrorCode.INVALID_COORDINATES:
exception_class = InvalidCoordinatesException
elif status in ErrorCode.INVALID_SESSION_ID:
exception_class = InvalidSessionIdException
elif status in ErrorCode.UNKNOWN_METHOD:
exception_class = UnknownMethodException
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:
alert_text = None
if 'data' in value:
alert_text = value['data'].get('text')
elif 'alert' in value:
alert_text = value['alert'].get('text')
raise exception_class(message, screen, stacktrace, alert_text)
> raise exception_class(message, screen, stacktrace)
E selenium.common.exceptions.NoSuchWindowException: Message: no such window: target window already closed
E from unknown error: web view not found
E (Session info: chrome=110.0.5481.100)

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py:242: NoSuchWindowException

During handling of the above exception, another exception occurred:

self = <test_SL_footer_check.TestSLFooterCheck object at 0x0000021898DC7730>, value = 'Resources'
initialize_pages = None

@pytest.mark.test_details("SLUB-T0000","high","Sl Footer Check","Pradeep")
@pytest.mark.parametrize("value",_create_parameterised_data())
def test_SL_Footer_check(self,value,initialize_pages):
try:
logging.info(value)
with open('sl_footer_check_test_data.csv', 'r') as csv_file:
csv_data = csv.reader(csv_file)
for line in csv_data:
if line[0] == value:
url = line[1]
logging.info(f"URL for {value} is : {url}")
break

pytest.driver.get(pytest.config['prod_url'])
selenium_helper.wait_for_page_to_load(20,pytest.config['prod_url'])
dynamic_locator = f"(//div[starts-with(@class,'col-md-2')]//a[@title='{value}'])[1]"
logging.info(f"Dynamic Locator : {dynamic_locator}")
time.sleep(3)
WebDriverWait(pytest.driver, 20).until(EC.element_to_be_clickable((By.XPATH, dynamic_locator))).scroll_to_element()
time.sleep(2)
default_window = pytest.driver.current_window_handle
pytest.driver.find_element(By.XPATH,dynamic_locator).click()
time.sleep(5)
window_handle = list(pytest.driver.window_handles)
if len(window_handle) > 1:
pytest.driver.close()
pytest.driver.switch_to.window(window_handle[-1])

url_opened,message = self.check_redirection(value,url)
rows = [[value,url,url_opened,message]]
with open("Report.csv", 'a', newline='\n') as csvfile:
csvwriter = csv.writer(csvfile)
csvwriter.writerows(rows)
if 'Not Working' in message:
pytest.driver.get_screenshot_as_file(os.path.join(os.path.dirname(os.curdir), "report\screenshot", f"{__name__}_{value}.jpeg"))
pytest.fail()

except:
logging.info("Exception Occurred", exc_info=True)
> pytest.driver.get_screenshot_as_file(os.path.join(os.path.dirname(os.curdir), "report\screenshot", f"{__name__}_{value}.jpeg"))

test_prod\test_SL_footer_check.py:265:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:1032: in get_screenshot_as_file
png = self.get_screenshot_as_png()
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:1064: in get_screenshot_as_png
return base64.b64decode(self.get_screenshot_as_base64().encode('ascii'))
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:1074: in get_screenshot_as_base64
return self.execute(Command.SCREENSHOT)['value']
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:321: in execute
self.error_handler.check_response(response)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x000002189862D550>
response = {'status': 404, 'value': '{"value":{"error":"no such window","message":"no such window: target window already closed\\...\n\\tRtlGetAppContainerNamedObjectPath [0x77187BBE+286]\\n\\tRtlGetAppContainerNamedObjectPath [0x77187B8E+238]\\n"}}'}

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 = InvalidCookieDomainException
elif status in ErrorCode.UNABLE_TO_SET_COOKIE:
exception_class = UnableToSetCookieException
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
elif status in ErrorCode.JAVASCRIPT_ERROR:
exception_class = JavascriptException
elif status in ErrorCode.SESSION_NOT_CREATED:
exception_class = SessionNotCreatedException
elif status in ErrorCode.INVALID_ARGUMENT:
exception_class = InvalidArgumentException
elif status in ErrorCode.NO_SUCH_COOKIE:
exception_class = NoSuchCookieException
elif status in ErrorCode.UNABLE_TO_CAPTURE_SCREEN:
exception_class = ScreenshotException
elif status in ErrorCode.ELEMENT_CLICK_INTERCEPTED:
exception_class = ElementClickInterceptedException
elif status in ErrorCode.INSECURE_CERTIFICATE:
exception_class = InsecureCertificateException
elif status in ErrorCode.INVALID_COORDINATES:
exception_class = InvalidCoordinatesException
elif status in ErrorCode.INVALID_SESSION_ID:
exception_class = InvalidSessionIdException
elif status in ErrorCode.UNKNOWN_METHOD:
exception_class = UnknownMethodException
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:
alert_text = None
if 'data' in value:
alert_text = value['data'].get('text')
elif 'alert' in value:
alert_text = value['alert'].get('text')
raise exception_class(message, screen, stacktrace, alert_text)
> raise exception_class(message, screen, stacktrace)
E selenium.common.exceptions.NoSuchWindowException: Message: no such window: target window already closed
E from unknown error: web view not found
E (Session info: chrome=110.0.5481.100)

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py:242: NoSuchWindowException
-------------------------------Captured log call--------------------------------
INFO  setup:test_SL_footer_check.py:230 Resources INFO  setup:test_SL_footer_check.py:236 URL for Resources is : https://www.simplilearn.com/resources INFO  setup:test_SL_footer_check.py:264 Exception Occurred Traceback (most recent call last): File "C:\test_repos\pre_sales_test_python\test_prod\test_SL_footer_check.py", line 239, in test_SL_Footer_check pytest.driver.get(pytest.config['prod_url']) File "c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 333, in get self.execute(Command.GET, {'url': url}) File "c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute self.error_handler.check_response(response) File "c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.NoSuchWindowException: Message: no such window: target window already closed from unknown error: web view not found (Session info: chrome=110.0.5481.100)
Failed test_SL_footer_check.py::TestSLFooterCheck::test_SL_Footer_check[RSS feed] 0.00
self = <test_SL_footer_check.TestSLFooterCheck object at 0x0000021898D83D30>, value = 'RSS feed'
initialize_pages = None

@pytest.mark.test_details("SLUB-T0000","high","Sl Footer Check","Pradeep")
@pytest.mark.parametrize("value",_create_parameterised_data())
def test_SL_Footer_check(self,value,initialize_pages):
try:
logging.info(value)
with open('sl_footer_check_test_data.csv', 'r') as csv_file:
csv_data = csv.reader(csv_file)
for line in csv_data:
if line[0] == value:
url = line[1]
logging.info(f"URL for {value} is : {url}")
break

> pytest.driver.get(pytest.config['prod_url'])

test_prod\test_SL_footer_check.py:239:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.chrome.webdriver.WebDriver (session="7643857c856eba21654096eb2db552ee")>
url = 'https://www.simplilearn.com/'

def get(self, url):
"""
Loads a web page in the current browser session.
"""
> self.execute(Command.GET, {'url': url})

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:333:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.chrome.webdriver.WebDriver (session="7643857c856eba21654096eb2db552ee")>
driver_command = 'get', params = {'url': 'https://www.simplilearn.com/'}

def execute(self, driver_command, params=None):
"""
Sends a command to be executed by a command.CommandExecutor.

:Args:
- driver_command: The name of the command to execute as a string.
- params: A dictionary of named parameters to send with the command.

:Returns:
The command's JSON response loaded into a dictionary object.
"""
if self.session_id is not None:
if not params:
params = {'sessionId': self.session_id}
elif 'sessionId' not in params:
params['sessionId'] = self.session_id

params = self._wrap_value(params)
response = self.command_executor.execute(driver_command, params)
if response:
> self.error_handler.check_response(response)

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:321:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x000002189862D550>
response = {'status': 404, 'value': '{"value":{"error":"no such window","message":"no such window: target window already closed\\...\n\\tRtlGetAppContainerNamedObjectPath [0x77187BBE+286]\\n\\tRtlGetAppContainerNamedObjectPath [0x77187B8E+238]\\n"}}'}

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 = InvalidCookieDomainException
elif status in ErrorCode.UNABLE_TO_SET_COOKIE:
exception_class = UnableToSetCookieException
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
elif status in ErrorCode.JAVASCRIPT_ERROR:
exception_class = JavascriptException
elif status in ErrorCode.SESSION_NOT_CREATED:
exception_class = SessionNotCreatedException
elif status in ErrorCode.INVALID_ARGUMENT:
exception_class = InvalidArgumentException
elif status in ErrorCode.NO_SUCH_COOKIE:
exception_class = NoSuchCookieException
elif status in ErrorCode.UNABLE_TO_CAPTURE_SCREEN:
exception_class = ScreenshotException
elif status in ErrorCode.ELEMENT_CLICK_INTERCEPTED:
exception_class = ElementClickInterceptedException
elif status in ErrorCode.INSECURE_CERTIFICATE:
exception_class = InsecureCertificateException
elif status in ErrorCode.INVALID_COORDINATES:
exception_class = InvalidCoordinatesException
elif status in ErrorCode.INVALID_SESSION_ID:
exception_class = InvalidSessionIdException
elif status in ErrorCode.UNKNOWN_METHOD:
exception_class = UnknownMethodException
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:
alert_text = None
if 'data' in value:
alert_text = value['data'].get('text')
elif 'alert' in value:
alert_text = value['alert'].get('text')
raise exception_class(message, screen, stacktrace, alert_text)
> raise exception_class(message, screen, stacktrace)
E selenium.common.exceptions.NoSuchWindowException: Message: no such window: target window already closed
E from unknown error: web view not found
E (Session info: chrome=110.0.5481.100)

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py:242: NoSuchWindowException

During handling of the above exception, another exception occurred:

self = <test_SL_footer_check.TestSLFooterCheck object at 0x0000021898D83D30>, value = 'RSS feed'
initialize_pages = None

@pytest.mark.test_details("SLUB-T0000","high","Sl Footer Check","Pradeep")
@pytest.mark.parametrize("value",_create_parameterised_data())
def test_SL_Footer_check(self,value,initialize_pages):
try:
logging.info(value)
with open('sl_footer_check_test_data.csv', 'r') as csv_file:
csv_data = csv.reader(csv_file)
for line in csv_data:
if line[0] == value:
url = line[1]
logging.info(f"URL for {value} is : {url}")
break

pytest.driver.get(pytest.config['prod_url'])
selenium_helper.wait_for_page_to_load(20,pytest.config['prod_url'])
dynamic_locator = f"(//div[starts-with(@class,'col-md-2')]//a[@title='{value}'])[1]"
logging.info(f"Dynamic Locator : {dynamic_locator}")
time.sleep(3)
WebDriverWait(pytest.driver, 20).until(EC.element_to_be_clickable((By.XPATH, dynamic_locator))).scroll_to_element()
time.sleep(2)
default_window = pytest.driver.current_window_handle
pytest.driver.find_element(By.XPATH,dynamic_locator).click()
time.sleep(5)
window_handle = list(pytest.driver.window_handles)
if len(window_handle) > 1:
pytest.driver.close()
pytest.driver.switch_to.window(window_handle[-1])

url_opened,message = self.check_redirection(value,url)
rows = [[value,url,url_opened,message]]
with open("Report.csv", 'a', newline='\n') as csvfile:
csvwriter = csv.writer(csvfile)
csvwriter.writerows(rows)
if 'Not Working' in message:
pytest.driver.get_screenshot_as_file(os.path.join(os.path.dirname(os.curdir), "report\screenshot", f"{__name__}_{value}.jpeg"))
pytest.fail()

except:
logging.info("Exception Occurred", exc_info=True)
> pytest.driver.get_screenshot_as_file(os.path.join(os.path.dirname(os.curdir), "report\screenshot", f"{__name__}_{value}.jpeg"))

test_prod\test_SL_footer_check.py:265:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:1032: in get_screenshot_as_file
png = self.get_screenshot_as_png()
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:1064: in get_screenshot_as_png
return base64.b64decode(self.get_screenshot_as_base64().encode('ascii'))
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:1074: in get_screenshot_as_base64
return self.execute(Command.SCREENSHOT)['value']
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:321: in execute
self.error_handler.check_response(response)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x000002189862D550>
response = {'status': 404, 'value': '{"value":{"error":"no such window","message":"no such window: target window already closed\\...\n\\tRtlGetAppContainerNamedObjectPath [0x77187BBE+286]\\n\\tRtlGetAppContainerNamedObjectPath [0x77187B8E+238]\\n"}}'}

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 = InvalidCookieDomainException
elif status in ErrorCode.UNABLE_TO_SET_COOKIE:
exception_class = UnableToSetCookieException
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
elif status in ErrorCode.JAVASCRIPT_ERROR:
exception_class = JavascriptException
elif status in ErrorCode.SESSION_NOT_CREATED:
exception_class = SessionNotCreatedException
elif status in ErrorCode.INVALID_ARGUMENT:
exception_class = InvalidArgumentException
elif status in ErrorCode.NO_SUCH_COOKIE:
exception_class = NoSuchCookieException
elif status in ErrorCode.UNABLE_TO_CAPTURE_SCREEN:
exception_class = ScreenshotException
elif status in ErrorCode.ELEMENT_CLICK_INTERCEPTED:
exception_class = ElementClickInterceptedException
elif status in ErrorCode.INSECURE_CERTIFICATE:
exception_class = InsecureCertificateException
elif status in ErrorCode.INVALID_COORDINATES:
exception_class = InvalidCoordinatesException
elif status in ErrorCode.INVALID_SESSION_ID:
exception_class = InvalidSessionIdException
elif status in ErrorCode.UNKNOWN_METHOD:
exception_class = UnknownMethodException
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:
alert_text = None
if 'data' in value:
alert_text = value['data'].get('text')
elif 'alert' in value:
alert_text = value['alert'].get('text')
raise exception_class(message, screen, stacktrace, alert_text)
> raise exception_class(message, screen, stacktrace)
E selenium.common.exceptions.NoSuchWindowException: Message: no such window: target window already closed
E from unknown error: web view not found
E (Session info: chrome=110.0.5481.100)

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py:242: NoSuchWindowException
-------------------------------Captured log call--------------------------------
INFO  setup:test_SL_footer_check.py:230 RSS feed INFO  setup:test_SL_footer_check.py:236 URL for RSS feed is : https://www.simplilearn.com/feed INFO  setup:test_SL_footer_check.py:264 Exception Occurred Traceback (most recent call last): File "C:\test_repos\pre_sales_test_python\test_prod\test_SL_footer_check.py", line 239, in test_SL_Footer_check pytest.driver.get(pytest.config['prod_url']) File "c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 333, in get self.execute(Command.GET, {'url': url}) File "c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute self.error_handler.check_response(response) File "c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.NoSuchWindowException: Message: no such window: target window already closed from unknown error: web view not found (Session info: chrome=110.0.5481.100)
Failed test_SL_footer_check.py::TestSLFooterCheck::test_SL_Footer_check[City Sitemap] 0.00
self = <test_SL_footer_check.TestSLFooterCheck object at 0x0000021898B9EA90>, value = 'City Sitemap'
initialize_pages = None

@pytest.mark.test_details("SLUB-T0000","high","Sl Footer Check","Pradeep")
@pytest.mark.parametrize("value",_create_parameterised_data())
def test_SL_Footer_check(self,value,initialize_pages):
try:
logging.info(value)
with open('sl_footer_check_test_data.csv', 'r') as csv_file:
csv_data = csv.reader(csv_file)
for line in csv_data:
if line[0] == value:
url = line[1]
logging.info(f"URL for {value} is : {url}")
break

> pytest.driver.get(pytest.config['prod_url'])

test_prod\test_SL_footer_check.py:239:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.chrome.webdriver.WebDriver (session="7643857c856eba21654096eb2db552ee")>
url = 'https://www.simplilearn.com/'

def get(self, url):
"""
Loads a web page in the current browser session.
"""
> self.execute(Command.GET, {'url': url})

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:333:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.chrome.webdriver.WebDriver (session="7643857c856eba21654096eb2db552ee")>
driver_command = 'get', params = {'url': 'https://www.simplilearn.com/'}

def execute(self, driver_command, params=None):
"""
Sends a command to be executed by a command.CommandExecutor.

:Args:
- driver_command: The name of the command to execute as a string.
- params: A dictionary of named parameters to send with the command.

:Returns:
The command's JSON response loaded into a dictionary object.
"""
if self.session_id is not None:
if not params:
params = {'sessionId': self.session_id}
elif 'sessionId' not in params:
params['sessionId'] = self.session_id

params = self._wrap_value(params)
response = self.command_executor.execute(driver_command, params)
if response:
> self.error_handler.check_response(response)

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:321:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x000002189862D550>
response = {'status': 404, 'value': '{"value":{"error":"no such window","message":"no such window: target window already closed\\...\n\\tRtlGetAppContainerNamedObjectPath [0x77187BBE+286]\\n\\tRtlGetAppContainerNamedObjectPath [0x77187B8E+238]\\n"}}'}

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 = InvalidCookieDomainException
elif status in ErrorCode.UNABLE_TO_SET_COOKIE:
exception_class = UnableToSetCookieException
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
elif status in ErrorCode.JAVASCRIPT_ERROR:
exception_class = JavascriptException
elif status in ErrorCode.SESSION_NOT_CREATED:
exception_class = SessionNotCreatedException
elif status in ErrorCode.INVALID_ARGUMENT:
exception_class = InvalidArgumentException
elif status in ErrorCode.NO_SUCH_COOKIE:
exception_class = NoSuchCookieException
elif status in ErrorCode.UNABLE_TO_CAPTURE_SCREEN:
exception_class = ScreenshotException
elif status in ErrorCode.ELEMENT_CLICK_INTERCEPTED:
exception_class = ElementClickInterceptedException
elif status in ErrorCode.INSECURE_CERTIFICATE:
exception_class = InsecureCertificateException
elif status in ErrorCode.INVALID_COORDINATES:
exception_class = InvalidCoordinatesException
elif status in ErrorCode.INVALID_SESSION_ID:
exception_class = InvalidSessionIdException
elif status in ErrorCode.UNKNOWN_METHOD:
exception_class = UnknownMethodException
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:
alert_text = None
if 'data' in value:
alert_text = value['data'].get('text')
elif 'alert' in value:
alert_text = value['alert'].get('text')
raise exception_class(message, screen, stacktrace, alert_text)
> raise exception_class(message, screen, stacktrace)
E selenium.common.exceptions.NoSuchWindowException: Message: no such window: target window already closed
E from unknown error: web view not found
E (Session info: chrome=110.0.5481.100)

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py:242: NoSuchWindowException

During handling of the above exception, another exception occurred:

self = <test_SL_footer_check.TestSLFooterCheck object at 0x0000021898B9EA90>, value = 'City Sitemap'
initialize_pages = None

@pytest.mark.test_details("SLUB-T0000","high","Sl Footer Check","Pradeep")
@pytest.mark.parametrize("value",_create_parameterised_data())
def test_SL_Footer_check(self,value,initialize_pages):
try:
logging.info(value)
with open('sl_footer_check_test_data.csv', 'r') as csv_file:
csv_data = csv.reader(csv_file)
for line in csv_data:
if line[0] == value:
url = line[1]
logging.info(f"URL for {value} is : {url}")
break

pytest.driver.get(pytest.config['prod_url'])
selenium_helper.wait_for_page_to_load(20,pytest.config['prod_url'])
dynamic_locator = f"(//div[starts-with(@class,'col-md-2')]//a[@title='{value}'])[1]"
logging.info(f"Dynamic Locator : {dynamic_locator}")
time.sleep(3)
WebDriverWait(pytest.driver, 20).until(EC.element_to_be_clickable((By.XPATH, dynamic_locator))).scroll_to_element()
time.sleep(2)
default_window = pytest.driver.current_window_handle
pytest.driver.find_element(By.XPATH,dynamic_locator).click()
time.sleep(5)
window_handle = list(pytest.driver.window_handles)
if len(window_handle) > 1:
pytest.driver.close()
pytest.driver.switch_to.window(window_handle[-1])

url_opened,message = self.check_redirection(value,url)
rows = [[value,url,url_opened,message]]
with open("Report.csv", 'a', newline='\n') as csvfile:
csvwriter = csv.writer(csvfile)
csvwriter.writerows(rows)
if 'Not Working' in message:
pytest.driver.get_screenshot_as_file(os.path.join(os.path.dirname(os.curdir), "report\screenshot", f"{__name__}_{value}.jpeg"))
pytest.fail()

except:
logging.info("Exception Occurred", exc_info=True)
> pytest.driver.get_screenshot_as_file(os.path.join(os.path.dirname(os.curdir), "report\screenshot", f"{__name__}_{value}.jpeg"))

test_prod\test_SL_footer_check.py:265:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:1032: in get_screenshot_as_file
png = self.get_screenshot_as_png()
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:1064: in get_screenshot_as_png
return base64.b64decode(self.get_screenshot_as_base64().encode('ascii'))
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:1074: in get_screenshot_as_base64
return self.execute(Command.SCREENSHOT)['value']
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:321: in execute
self.error_handler.check_response(response)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x000002189862D550>
response = {'status': 404, 'value': '{"value":{"error":"no such window","message":"no such window: target window already closed\\...\n\\tRtlGetAppContainerNamedObjectPath [0x77187BBE+286]\\n\\tRtlGetAppContainerNamedObjectPath [0x77187B8E+238]\\n"}}'}

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 = InvalidCookieDomainException
elif status in ErrorCode.UNABLE_TO_SET_COOKIE:
exception_class = UnableToSetCookieException
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
elif status in ErrorCode.JAVASCRIPT_ERROR:
exception_class = JavascriptException
elif status in ErrorCode.SESSION_NOT_CREATED:
exception_class = SessionNotCreatedException
elif status in ErrorCode.INVALID_ARGUMENT:
exception_class = InvalidArgumentException
elif status in ErrorCode.NO_SUCH_COOKIE:
exception_class = NoSuchCookieException
elif status in ErrorCode.UNABLE_TO_CAPTURE_SCREEN:
exception_class = ScreenshotException
elif status in ErrorCode.ELEMENT_CLICK_INTERCEPTED:
exception_class = ElementClickInterceptedException
elif status in ErrorCode.INSECURE_CERTIFICATE:
exception_class = InsecureCertificateException
elif status in ErrorCode.INVALID_COORDINATES:
exception_class = InvalidCoordinatesException
elif status in ErrorCode.INVALID_SESSION_ID:
exception_class = InvalidSessionIdException
elif status in ErrorCode.UNKNOWN_METHOD:
exception_class = UnknownMethodException
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:
alert_text = None
if 'data' in value:
alert_text = value['data'].get('text')
elif 'alert' in value:
alert_text = value['alert'].get('text')
raise exception_class(message, screen, stacktrace, alert_text)
> raise exception_class(message, screen, stacktrace)
E selenium.common.exceptions.NoSuchWindowException: Message: no such window: target window already closed
E from unknown error: web view not found
E (Session info: chrome=110.0.5481.100)

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py:242: NoSuchWindowException
-------------------------------Captured log call--------------------------------
INFO  setup:test_SL_footer_check.py:230 City Sitemap INFO  setup:test_SL_footer_check.py:236 URL for City Sitemap is : https://www.simplilearn.com/city-sitemap INFO  setup:test_SL_footer_check.py:264 Exception Occurred Traceback (most recent call last): File "C:\test_repos\pre_sales_test_python\test_prod\test_SL_footer_check.py", line 239, in test_SL_Footer_check pytest.driver.get(pytest.config['prod_url']) File "c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 333, in get self.execute(Command.GET, {'url': url}) File "c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute self.error_handler.check_response(response) File "c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.NoSuchWindowException: Message: no such window: target window already closed from unknown error: web view not found (Session info: chrome=110.0.5481.100)
Failed test_SL_footer_check.py::TestSLFooterCheck::test_SL_Footer_check[Corporate training] 0.00
self = <test_SL_footer_check.TestSLFooterCheck object at 0x0000021898BB7940>, value = 'Corporate training'
initialize_pages = None

@pytest.mark.test_details("SLUB-T0000","high","Sl Footer Check","Pradeep")
@pytest.mark.parametrize("value",_create_parameterised_data())
def test_SL_Footer_check(self,value,initialize_pages):
try:
logging.info(value)
with open('sl_footer_check_test_data.csv', 'r') as csv_file:
csv_data = csv.reader(csv_file)
for line in csv_data:
if line[0] == value:
url = line[1]
logging.info(f"URL for {value} is : {url}")
break

> pytest.driver.get(pytest.config['prod_url'])

test_prod\test_SL_footer_check.py:239:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.chrome.webdriver.WebDriver (session="7643857c856eba21654096eb2db552ee")>
url = 'https://www.simplilearn.com/'

def get(self, url):
"""
Loads a web page in the current browser session.
"""
> self.execute(Command.GET, {'url': url})

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:333:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.chrome.webdriver.WebDriver (session="7643857c856eba21654096eb2db552ee")>
driver_command = 'get', params = {'url': 'https://www.simplilearn.com/'}

def execute(self, driver_command, params=None):
"""
Sends a command to be executed by a command.CommandExecutor.

:Args:
- driver_command: The name of the command to execute as a string.
- params: A dictionary of named parameters to send with the command.

:Returns:
The command's JSON response loaded into a dictionary object.
"""
if self.session_id is not None:
if not params:
params = {'sessionId': self.session_id}
elif 'sessionId' not in params:
params['sessionId'] = self.session_id

params = self._wrap_value(params)
response = self.command_executor.execute(driver_command, params)
if response:
> self.error_handler.check_response(response)

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:321:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x000002189862D550>
response = {'status': 404, 'value': '{"value":{"error":"no such window","message":"no such window: target window already closed\\...\n\\tRtlGetAppContainerNamedObjectPath [0x77187BBE+286]\\n\\tRtlGetAppContainerNamedObjectPath [0x77187B8E+238]\\n"}}'}

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 = InvalidCookieDomainException
elif status in ErrorCode.UNABLE_TO_SET_COOKIE:
exception_class = UnableToSetCookieException
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
elif status in ErrorCode.JAVASCRIPT_ERROR:
exception_class = JavascriptException
elif status in ErrorCode.SESSION_NOT_CREATED:
exception_class = SessionNotCreatedException
elif status in ErrorCode.INVALID_ARGUMENT:
exception_class = InvalidArgumentException
elif status in ErrorCode.NO_SUCH_COOKIE:
exception_class = NoSuchCookieException
elif status in ErrorCode.UNABLE_TO_CAPTURE_SCREEN:
exception_class = ScreenshotException
elif status in ErrorCode.ELEMENT_CLICK_INTERCEPTED:
exception_class = ElementClickInterceptedException
elif status in ErrorCode.INSECURE_CERTIFICATE:
exception_class = InsecureCertificateException
elif status in ErrorCode.INVALID_COORDINATES:
exception_class = InvalidCoordinatesException
elif status in ErrorCode.INVALID_SESSION_ID:
exception_class = InvalidSessionIdException
elif status in ErrorCode.UNKNOWN_METHOD:
exception_class = UnknownMethodException
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:
alert_text = None
if 'data' in value:
alert_text = value['data'].get('text')
elif 'alert' in value:
alert_text = value['alert'].get('text')
raise exception_class(message, screen, stacktrace, alert_text)
> raise exception_class(message, screen, stacktrace)
E selenium.common.exceptions.NoSuchWindowException: Message: no such window: target window already closed
E from unknown error: web view not found
E (Session info: chrome=110.0.5481.100)

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py:242: NoSuchWindowException

During handling of the above exception, another exception occurred:

self = <test_SL_footer_check.TestSLFooterCheck object at 0x0000021898BB7940>, value = 'Corporate training'
initialize_pages = None

@pytest.mark.test_details("SLUB-T0000","high","Sl Footer Check","Pradeep")
@pytest.mark.parametrize("value",_create_parameterised_data())
def test_SL_Footer_check(self,value,initialize_pages):
try:
logging.info(value)
with open('sl_footer_check_test_data.csv', 'r') as csv_file:
csv_data = csv.reader(csv_file)
for line in csv_data:
if line[0] == value:
url = line[1]
logging.info(f"URL for {value} is : {url}")
break

pytest.driver.get(pytest.config['prod_url'])
selenium_helper.wait_for_page_to_load(20,pytest.config['prod_url'])
dynamic_locator = f"(//div[starts-with(@class,'col-md-2')]//a[@title='{value}'])[1]"
logging.info(f"Dynamic Locator : {dynamic_locator}")
time.sleep(3)
WebDriverWait(pytest.driver, 20).until(EC.element_to_be_clickable((By.XPATH, dynamic_locator))).scroll_to_element()
time.sleep(2)
default_window = pytest.driver.current_window_handle
pytest.driver.find_element(By.XPATH,dynamic_locator).click()
time.sleep(5)
window_handle = list(pytest.driver.window_handles)
if len(window_handle) > 1:
pytest.driver.close()
pytest.driver.switch_to.window(window_handle[-1])

url_opened,message = self.check_redirection(value,url)
rows = [[value,url,url_opened,message]]
with open("Report.csv", 'a', newline='\n') as csvfile:
csvwriter = csv.writer(csvfile)
csvwriter.writerows(rows)
if 'Not Working' in message:
pytest.driver.get_screenshot_as_file(os.path.join(os.path.dirname(os.curdir), "report\screenshot", f"{__name__}_{value}.jpeg"))
pytest.fail()

except:
logging.info("Exception Occurred", exc_info=True)
> pytest.driver.get_screenshot_as_file(os.path.join(os.path.dirname(os.curdir), "report\screenshot", f"{__name__}_{value}.jpeg"))

test_prod\test_SL_footer_check.py:265:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:1032: in get_screenshot_as_file
png = self.get_screenshot_as_png()
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:1064: in get_screenshot_as_png
return base64.b64decode(self.get_screenshot_as_base64().encode('ascii'))
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:1074: in get_screenshot_as_base64
return self.execute(Command.SCREENSHOT)['value']
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:321: in execute
self.error_handler.check_response(response)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x000002189862D550>
response = {'status': 404, 'value': '{"value":{"error":"no such window","message":"no such window: target window already closed\\...\n\\tRtlGetAppContainerNamedObjectPath [0x77187BBE+286]\\n\\tRtlGetAppContainerNamedObjectPath [0x77187B8E+238]\\n"}}'}

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 = InvalidCookieDomainException
elif status in ErrorCode.UNABLE_TO_SET_COOKIE:
exception_class = UnableToSetCookieException
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
elif status in ErrorCode.JAVASCRIPT_ERROR:
exception_class = JavascriptException
elif status in ErrorCode.SESSION_NOT_CREATED:
exception_class = SessionNotCreatedException
elif status in ErrorCode.INVALID_ARGUMENT:
exception_class = InvalidArgumentException
elif status in ErrorCode.NO_SUCH_COOKIE:
exception_class = NoSuchCookieException
elif status in ErrorCode.UNABLE_TO_CAPTURE_SCREEN:
exception_class = ScreenshotException
elif status in ErrorCode.ELEMENT_CLICK_INTERCEPTED:
exception_class = ElementClickInterceptedException
elif status in ErrorCode.INSECURE_CERTIFICATE:
exception_class = InsecureCertificateException
elif status in ErrorCode.INVALID_COORDINATES:
exception_class = InvalidCoordinatesException
elif status in ErrorCode.INVALID_SESSION_ID:
exception_class = InvalidSessionIdException
elif status in ErrorCode.UNKNOWN_METHOD:
exception_class = UnknownMethodException
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:
alert_text = None
if 'data' in value:
alert_text = value['data'].get('text')
elif 'alert' in value:
alert_text = value['alert'].get('text')
raise exception_class(message, screen, stacktrace, alert_text)
> raise exception_class(message, screen, stacktrace)
E selenium.common.exceptions.NoSuchWindowException: Message: no such window: target window already closed
E from unknown error: web view not found
E (Session info: chrome=110.0.5481.100)

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py:242: NoSuchWindowException
-------------------------------Captured log call--------------------------------
INFO  setup:test_SL_footer_check.py:230 Corporate training INFO  setup:test_SL_footer_check.py:236 URL for Corporate training is : https://www.simplilearn.com/corporate-training INFO  setup:test_SL_footer_check.py:264 Exception Occurred Traceback (most recent call last): File "C:\test_repos\pre_sales_test_python\test_prod\test_SL_footer_check.py", line 239, in test_SL_Footer_check pytest.driver.get(pytest.config['prod_url']) File "c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 333, in get self.execute(Command.GET, {'url': url}) File "c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute self.error_handler.check_response(response) File "c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.NoSuchWindowException: Message: no such window: target window already closed from unknown error: web view not found (Session info: chrome=110.0.5481.100)
Failed test_SL_footer_check.py::TestSLFooterCheck::test_SL_Footer_check[Partners] 0.00
self = <test_SL_footer_check.TestSLFooterCheck object at 0x0000021898B9CF70>, value = 'Partners'
initialize_pages = None

@pytest.mark.test_details("SLUB-T0000","high","Sl Footer Check","Pradeep")
@pytest.mark.parametrize("value",_create_parameterised_data())
def test_SL_Footer_check(self,value,initialize_pages):
try:
logging.info(value)
with open('sl_footer_check_test_data.csv', 'r') as csv_file:
csv_data = csv.reader(csv_file)
for line in csv_data:
if line[0] == value:
url = line[1]
logging.info(f"URL for {value} is : {url}")
break

> pytest.driver.get(pytest.config['prod_url'])

test_prod\test_SL_footer_check.py:239:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.chrome.webdriver.WebDriver (session="7643857c856eba21654096eb2db552ee")>
url = 'https://www.simplilearn.com/'

def get(self, url):
"""
Loads a web page in the current browser session.
"""
> self.execute(Command.GET, {'url': url})

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:333:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.chrome.webdriver.WebDriver (session="7643857c856eba21654096eb2db552ee")>
driver_command = 'get', params = {'url': 'https://www.simplilearn.com/'}

def execute(self, driver_command, params=None):
"""
Sends a command to be executed by a command.CommandExecutor.

:Args:
- driver_command: The name of the command to execute as a string.
- params: A dictionary of named parameters to send with the command.

:Returns:
The command's JSON response loaded into a dictionary object.
"""
if self.session_id is not None:
if not params:
params = {'sessionId': self.session_id}
elif 'sessionId' not in params:
params['sessionId'] = self.session_id

params = self._wrap_value(params)
response = self.command_executor.execute(driver_command, params)
if response:
> self.error_handler.check_response(response)

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:321:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x000002189862D550>
response = {'status': 404, 'value': '{"value":{"error":"no such window","message":"no such window: target window already closed\\...\n\\tRtlGetAppContainerNamedObjectPath [0x77187BBE+286]\\n\\tRtlGetAppContainerNamedObjectPath [0x77187B8E+238]\\n"}}'}

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 = InvalidCookieDomainException
elif status in ErrorCode.UNABLE_TO_SET_COOKIE:
exception_class = UnableToSetCookieException
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
elif status in ErrorCode.JAVASCRIPT_ERROR:
exception_class = JavascriptException
elif status in ErrorCode.SESSION_NOT_CREATED:
exception_class = SessionNotCreatedException
elif status in ErrorCode.INVALID_ARGUMENT:
exception_class = InvalidArgumentException
elif status in ErrorCode.NO_SUCH_COOKIE:
exception_class = NoSuchCookieException
elif status in ErrorCode.UNABLE_TO_CAPTURE_SCREEN:
exception_class = ScreenshotException
elif status in ErrorCode.ELEMENT_CLICK_INTERCEPTED:
exception_class = ElementClickInterceptedException
elif status in ErrorCode.INSECURE_CERTIFICATE:
exception_class = InsecureCertificateException
elif status in ErrorCode.INVALID_COORDINATES:
exception_class = InvalidCoordinatesException
elif status in ErrorCode.INVALID_SESSION_ID:
exception_class = InvalidSessionIdException
elif status in ErrorCode.UNKNOWN_METHOD:
exception_class = UnknownMethodException
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:
alert_text = None
if 'data' in value:
alert_text = value['data'].get('text')
elif 'alert' in value:
alert_text = value['alert'].get('text')
raise exception_class(message, screen, stacktrace, alert_text)
> raise exception_class(message, screen, stacktrace)
E selenium.common.exceptions.NoSuchWindowException: Message: no such window: target window already closed
E from unknown error: web view not found
E (Session info: chrome=110.0.5481.100)

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py:242: NoSuchWindowException

During handling of the above exception, another exception occurred:

self = <test_SL_footer_check.TestSLFooterCheck object at 0x0000021898B9CF70>, value = 'Partners'
initialize_pages = None

@pytest.mark.test_details("SLUB-T0000","high","Sl Footer Check","Pradeep")
@pytest.mark.parametrize("value",_create_parameterised_data())
def test_SL_Footer_check(self,value,initialize_pages):
try:
logging.info(value)
with open('sl_footer_check_test_data.csv', 'r') as csv_file:
csv_data = csv.reader(csv_file)
for line in csv_data:
if line[0] == value:
url = line[1]
logging.info(f"URL for {value} is : {url}")
break

pytest.driver.get(pytest.config['prod_url'])
selenium_helper.wait_for_page_to_load(20,pytest.config['prod_url'])
dynamic_locator = f"(//div[starts-with(@class,'col-md-2')]//a[@title='{value}'])[1]"
logging.info(f"Dynamic Locator : {dynamic_locator}")
time.sleep(3)
WebDriverWait(pytest.driver, 20).until(EC.element_to_be_clickable((By.XPATH, dynamic_locator))).scroll_to_element()
time.sleep(2)
default_window = pytest.driver.current_window_handle
pytest.driver.find_element(By.XPATH,dynamic_locator).click()
time.sleep(5)
window_handle = list(pytest.driver.window_handles)
if len(window_handle) > 1:
pytest.driver.close()
pytest.driver.switch_to.window(window_handle[-1])

url_opened,message = self.check_redirection(value,url)
rows = [[value,url,url_opened,message]]
with open("Report.csv", 'a', newline='\n') as csvfile:
csvwriter = csv.writer(csvfile)
csvwriter.writerows(rows)
if 'Not Working' in message:
pytest.driver.get_screenshot_as_file(os.path.join(os.path.dirname(os.curdir), "report\screenshot", f"{__name__}_{value}.jpeg"))
pytest.fail()

except:
logging.info("Exception Occurred", exc_info=True)
> pytest.driver.get_screenshot_as_file(os.path.join(os.path.dirname(os.curdir), "report\screenshot", f"{__name__}_{value}.jpeg"))

test_prod\test_SL_footer_check.py:265:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:1032: in get_screenshot_as_file
png = self.get_screenshot_as_png()
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:1064: in get_screenshot_as_png
return base64.b64decode(self.get_screenshot_as_base64().encode('ascii'))
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:1074: in get_screenshot_as_base64
return self.execute(Command.SCREENSHOT)['value']
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:321: in execute
self.error_handler.check_response(response)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x000002189862D550>
response = {'status': 404, 'value': '{"value":{"error":"no such window","message":"no such window: target window already closed\\...\n\\tRtlGetAppContainerNamedObjectPath [0x77187BBE+286]\\n\\tRtlGetAppContainerNamedObjectPath [0x77187B8E+238]\\n"}}'}

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 = InvalidCookieDomainException
elif status in ErrorCode.UNABLE_TO_SET_COOKIE:
exception_class = UnableToSetCookieException
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
elif status in ErrorCode.JAVASCRIPT_ERROR:
exception_class = JavascriptException
elif status in ErrorCode.SESSION_NOT_CREATED:
exception_class = SessionNotCreatedException
elif status in ErrorCode.INVALID_ARGUMENT:
exception_class = InvalidArgumentException
elif status in ErrorCode.NO_SUCH_COOKIE:
exception_class = NoSuchCookieException
elif status in ErrorCode.UNABLE_TO_CAPTURE_SCREEN:
exception_class = ScreenshotException
elif status in ErrorCode.ELEMENT_CLICK_INTERCEPTED:
exception_class = ElementClickInterceptedException
elif status in ErrorCode.INSECURE_CERTIFICATE:
exception_class = InsecureCertificateException
elif status in ErrorCode.INVALID_COORDINATES:
exception_class = InvalidCoordinatesException
elif status in ErrorCode.INVALID_SESSION_ID:
exception_class = InvalidSessionIdException
elif status in ErrorCode.UNKNOWN_METHOD:
exception_class = UnknownMethodException
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:
alert_text = None
if 'data' in value:
alert_text = value['data'].get('text')
elif 'alert' in value:
alert_text = value['alert'].get('text')
raise exception_class(message, screen, stacktrace, alert_text)
> raise exception_class(message, screen, stacktrace)
E selenium.common.exceptions.NoSuchWindowException: Message: no such window: target window already closed
E from unknown error: web view not found
E (Session info: chrome=110.0.5481.100)

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py:242: NoSuchWindowException
-------------------------------Captured log call--------------------------------
INFO  setup:test_SL_footer_check.py:230 Partners INFO  setup:test_SL_footer_check.py:236 URL for Partners is : https://www.simplilearn.com/reseller-partner-program-for-training-courses INFO  setup:test_SL_footer_check.py:264 Exception Occurred Traceback (most recent call last): File "C:\test_repos\pre_sales_test_python\test_prod\test_SL_footer_check.py", line 239, in test_SL_Footer_check pytest.driver.get(pytest.config['prod_url']) File "c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 333, in get self.execute(Command.GET, {'url': url}) File "c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute self.error_handler.check_response(response) File "c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.NoSuchWindowException: Message: no such window: target window already closed from unknown error: web view not found (Session info: chrome=110.0.5481.100)
Failed test_SL_footer_check.py::TestSLFooterCheck::test_SL_Footer_check[Digital Transformation] 0.00
self = <test_SL_footer_check.TestSLFooterCheck object at 0x0000021898FDB430>, value = 'Digital Transformation'
initialize_pages = None

@pytest.mark.test_details("SLUB-T0000","high","Sl Footer Check","Pradeep")
@pytest.mark.parametrize("value",_create_parameterised_data())
def test_SL_Footer_check(self,value,initialize_pages):
try:
logging.info(value)
with open('sl_footer_check_test_data.csv', 'r') as csv_file:
csv_data = csv.reader(csv_file)
for line in csv_data:
if line[0] == value:
url = line[1]
logging.info(f"URL for {value} is : {url}")
break

> pytest.driver.get(pytest.config['prod_url'])

test_prod\test_SL_footer_check.py:239:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.chrome.webdriver.WebDriver (session="7643857c856eba21654096eb2db552ee")>
url = 'https://www.simplilearn.com/'

def get(self, url):
"""
Loads a web page in the current browser session.
"""
> self.execute(Command.GET, {'url': url})

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:333:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.chrome.webdriver.WebDriver (session="7643857c856eba21654096eb2db552ee")>
driver_command = 'get', params = {'url': 'https://www.simplilearn.com/'}

def execute(self, driver_command, params=None):
"""
Sends a command to be executed by a command.CommandExecutor.

:Args:
- driver_command: The name of the command to execute as a string.
- params: A dictionary of named parameters to send with the command.

:Returns:
The command's JSON response loaded into a dictionary object.
"""
if self.session_id is not None:
if not params:
params = {'sessionId': self.session_id}
elif 'sessionId' not in params:
params['sessionId'] = self.session_id

params = self._wrap_value(params)
response = self.command_executor.execute(driver_command, params)
if response:
> self.error_handler.check_response(response)

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:321:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x000002189862D550>
response = {'status': 404, 'value': '{"value":{"error":"no such window","message":"no such window: target window already closed\\...\n\\tRtlGetAppContainerNamedObjectPath [0x77187BBE+286]\\n\\tRtlGetAppContainerNamedObjectPath [0x77187B8E+238]\\n"}}'}

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 = InvalidCookieDomainException
elif status in ErrorCode.UNABLE_TO_SET_COOKIE:
exception_class = UnableToSetCookieException
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
elif status in ErrorCode.JAVASCRIPT_ERROR:
exception_class = JavascriptException
elif status in ErrorCode.SESSION_NOT_CREATED:
exception_class = SessionNotCreatedException
elif status in ErrorCode.INVALID_ARGUMENT:
exception_class = InvalidArgumentException
elif status in ErrorCode.NO_SUCH_COOKIE:
exception_class = NoSuchCookieException
elif status in ErrorCode.UNABLE_TO_CAPTURE_SCREEN:
exception_class = ScreenshotException
elif status in ErrorCode.ELEMENT_CLICK_INTERCEPTED:
exception_class = ElementClickInterceptedException
elif status in ErrorCode.INSECURE_CERTIFICATE:
exception_class = InsecureCertificateException
elif status in ErrorCode.INVALID_COORDINATES:
exception_class = InvalidCoordinatesException
elif status in ErrorCode.INVALID_SESSION_ID:
exception_class = InvalidSessionIdException
elif status in ErrorCode.UNKNOWN_METHOD:
exception_class = UnknownMethodException
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:
alert_text = None
if 'data' in value:
alert_text = value['data'].get('text')
elif 'alert' in value:
alert_text = value['alert'].get('text')
raise exception_class(message, screen, stacktrace, alert_text)
> raise exception_class(message, screen, stacktrace)
E selenium.common.exceptions.NoSuchWindowException: Message: no such window: target window already closed
E from unknown error: web view not found
E (Session info: chrome=110.0.5481.100)

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py:242: NoSuchWindowException

During handling of the above exception, another exception occurred:

self = <test_SL_footer_check.TestSLFooterCheck object at 0x0000021898FDB430>, value = 'Digital Transformation'
initialize_pages = None

@pytest.mark.test_details("SLUB-T0000","high","Sl Footer Check","Pradeep")
@pytest.mark.parametrize("value",_create_parameterised_data())
def test_SL_Footer_check(self,value,initialize_pages):
try:
logging.info(value)
with open('sl_footer_check_test_data.csv', 'r') as csv_file:
csv_data = csv.reader(csv_file)
for line in csv_data:
if line[0] == value:
url = line[1]
logging.info(f"URL for {value} is : {url}")
break

pytest.driver.get(pytest.config['prod_url'])
selenium_helper.wait_for_page_to_load(20,pytest.config['prod_url'])
dynamic_locator = f"(//div[starts-with(@class,'col-md-2')]//a[@title='{value}'])[1]"
logging.info(f"Dynamic Locator : {dynamic_locator}")
time.sleep(3)
WebDriverWait(pytest.driver, 20).until(EC.element_to_be_clickable((By.XPATH, dynamic_locator))).scroll_to_element()
time.sleep(2)
default_window = pytest.driver.current_window_handle
pytest.driver.find_element(By.XPATH,dynamic_locator).click()
time.sleep(5)
window_handle = list(pytest.driver.window_handles)
if len(window_handle) > 1:
pytest.driver.close()
pytest.driver.switch_to.window(window_handle[-1])

url_opened,message = self.check_redirection(value,url)
rows = [[value,url,url_opened,message]]
with open("Report.csv", 'a', newline='\n') as csvfile:
csvwriter = csv.writer(csvfile)
csvwriter.writerows(rows)
if 'Not Working' in message:
pytest.driver.get_screenshot_as_file(os.path.join(os.path.dirname(os.curdir), "report\screenshot", f"{__name__}_{value}.jpeg"))
pytest.fail()

except:
logging.info("Exception Occurred", exc_info=True)
> pytest.driver.get_screenshot_as_file(os.path.join(os.path.dirname(os.curdir), "report\screenshot", f"{__name__}_{value}.jpeg"))

test_prod\test_SL_footer_check.py:265:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:1032: in get_screenshot_as_file
png = self.get_screenshot_as_png()
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:1064: in get_screenshot_as_png
return base64.b64decode(self.get_screenshot_as_base64().encode('ascii'))
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:1074: in get_screenshot_as_base64
return self.execute(Command.SCREENSHOT)['value']
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:321: in execute
self.error_handler.check_response(response)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x000002189862D550>
response = {'status': 404, 'value': '{"value":{"error":"no such window","message":"no such window: target window already closed\\...\n\\tRtlGetAppContainerNamedObjectPath [0x77187BBE+286]\\n\\tRtlGetAppContainerNamedObjectPath [0x77187B8E+238]\\n"}}'}

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 = InvalidCookieDomainException
elif status in ErrorCode.UNABLE_TO_SET_COOKIE:
exception_class = UnableToSetCookieException
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
elif status in ErrorCode.JAVASCRIPT_ERROR:
exception_class = JavascriptException
elif status in ErrorCode.SESSION_NOT_CREATED:
exception_class = SessionNotCreatedException
elif status in ErrorCode.INVALID_ARGUMENT:
exception_class = InvalidArgumentException
elif status in ErrorCode.NO_SUCH_COOKIE:
exception_class = NoSuchCookieException
elif status in ErrorCode.UNABLE_TO_CAPTURE_SCREEN:
exception_class = ScreenshotException
elif status in ErrorCode.ELEMENT_CLICK_INTERCEPTED:
exception_class = ElementClickInterceptedException
elif status in ErrorCode.INSECURE_CERTIFICATE:
exception_class = InsecureCertificateException
elif status in ErrorCode.INVALID_COORDINATES:
exception_class = InvalidCoordinatesException
elif status in ErrorCode.INVALID_SESSION_ID:
exception_class = InvalidSessionIdException
elif status in ErrorCode.UNKNOWN_METHOD:
exception_class = UnknownMethodException
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:
alert_text = None
if 'data' in value:
alert_text = value['data'].get('text')
elif 'alert' in value:
alert_text = value['alert'].get('text')
raise exception_class(message, screen, stacktrace, alert_text)
> raise exception_class(message, screen, stacktrace)
E selenium.common.exceptions.NoSuchWindowException: Message: no such window: target window already closed
E from unknown error: web view not found
E (Session info: chrome=110.0.5481.100)

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py:242: NoSuchWindowException
-------------------------------Captured log call--------------------------------
INFO  setup:test_SL_footer_check.py:230 Digital Transformation INFO  setup:test_SL_footer_check.py:236 URL for Digital Transformation is : https://www.simplilearn.com/digital-transformation-training INFO  setup:test_SL_footer_check.py:264 Exception Occurred Traceback (most recent call last): File "C:\test_repos\pre_sales_test_python\test_prod\test_SL_footer_check.py", line 239, in test_SL_Footer_check pytest.driver.get(pytest.config['prod_url']) File "c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 333, in get self.execute(Command.GET, {'url': url}) File "c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute self.error_handler.check_response(response) File "c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.NoSuchWindowException: Message: no such window: target window already closed from unknown error: web view not found (Session info: chrome=110.0.5481.100)
Failed test_SL_footer_check.py::TestSLFooterCheck::test_SL_Footer_check[Get the Android App] 0.00
self = <test_SL_footer_check.TestSLFooterCheck object at 0x0000021898E93E50>, value = 'Get the Android App'
initialize_pages = None

@pytest.mark.test_details("SLUB-T0000","high","Sl Footer Check","Pradeep")
@pytest.mark.parametrize("value",_create_parameterised_data())
def test_SL_Footer_check(self,value,initialize_pages):
try:
logging.info(value)
with open('sl_footer_check_test_data.csv', 'r') as csv_file:
csv_data = csv.reader(csv_file)
for line in csv_data:
if line[0] == value:
url = line[1]
logging.info(f"URL for {value} is : {url}")
break

> pytest.driver.get(pytest.config['prod_url'])

test_prod\test_SL_footer_check.py:239:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.chrome.webdriver.WebDriver (session="7643857c856eba21654096eb2db552ee")>
url = 'https://www.simplilearn.com/'

def get(self, url):
"""
Loads a web page in the current browser session.
"""
> self.execute(Command.GET, {'url': url})

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:333:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.chrome.webdriver.WebDriver (session="7643857c856eba21654096eb2db552ee")>
driver_command = 'get', params = {'url': 'https://www.simplilearn.com/'}

def execute(self, driver_command, params=None):
"""
Sends a command to be executed by a command.CommandExecutor.

:Args:
- driver_command: The name of the command to execute as a string.
- params: A dictionary of named parameters to send with the command.

:Returns:
The command's JSON response loaded into a dictionary object.
"""
if self.session_id is not None:
if not params:
params = {'sessionId': self.session_id}
elif 'sessionId' not in params:
params['sessionId'] = self.session_id

params = self._wrap_value(params)
response = self.command_executor.execute(driver_command, params)
if response:
> self.error_handler.check_response(response)

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:321:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x000002189862D550>
response = {'status': 404, 'value': '{"value":{"error":"no such window","message":"no such window: target window already closed\\...\n\\tRtlGetAppContainerNamedObjectPath [0x77187BBE+286]\\n\\tRtlGetAppContainerNamedObjectPath [0x77187B8E+238]\\n"}}'}

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 = InvalidCookieDomainException
elif status in ErrorCode.UNABLE_TO_SET_COOKIE:
exception_class = UnableToSetCookieException
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
elif status in ErrorCode.JAVASCRIPT_ERROR:
exception_class = JavascriptException
elif status in ErrorCode.SESSION_NOT_CREATED:
exception_class = SessionNotCreatedException
elif status in ErrorCode.INVALID_ARGUMENT:
exception_class = InvalidArgumentException
elif status in ErrorCode.NO_SUCH_COOKIE:
exception_class = NoSuchCookieException
elif status in ErrorCode.UNABLE_TO_CAPTURE_SCREEN:
exception_class = ScreenshotException
elif status in ErrorCode.ELEMENT_CLICK_INTERCEPTED:
exception_class = ElementClickInterceptedException
elif status in ErrorCode.INSECURE_CERTIFICATE:
exception_class = InsecureCertificateException
elif status in ErrorCode.INVALID_COORDINATES:
exception_class = InvalidCoordinatesException
elif status in ErrorCode.INVALID_SESSION_ID:
exception_class = InvalidSessionIdException
elif status in ErrorCode.UNKNOWN_METHOD:
exception_class = UnknownMethodException
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:
alert_text = None
if 'data' in value:
alert_text = value['data'].get('text')
elif 'alert' in value:
alert_text = value['alert'].get('text')
raise exception_class(message, screen, stacktrace, alert_text)
> raise exception_class(message, screen, stacktrace)
E selenium.common.exceptions.NoSuchWindowException: Message: no such window: target window already closed
E from unknown error: web view not found
E (Session info: chrome=110.0.5481.100)

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py:242: NoSuchWindowException

During handling of the above exception, another exception occurred:

self = <test_SL_footer_check.TestSLFooterCheck object at 0x0000021898E93E50>, value = 'Get the Android App'
initialize_pages = None

@pytest.mark.test_details("SLUB-T0000","high","Sl Footer Check","Pradeep")
@pytest.mark.parametrize("value",_create_parameterised_data())
def test_SL_Footer_check(self,value,initialize_pages):
try:
logging.info(value)
with open('sl_footer_check_test_data.csv', 'r') as csv_file:
csv_data = csv.reader(csv_file)
for line in csv_data:
if line[0] == value:
url = line[1]
logging.info(f"URL for {value} is : {url}")
break

pytest.driver.get(pytest.config['prod_url'])
selenium_helper.wait_for_page_to_load(20,pytest.config['prod_url'])
dynamic_locator = f"(//div[starts-with(@class,'col-md-2')]//a[@title='{value}'])[1]"
logging.info(f"Dynamic Locator : {dynamic_locator}")
time.sleep(3)
WebDriverWait(pytest.driver, 20).until(EC.element_to_be_clickable((By.XPATH, dynamic_locator))).scroll_to_element()
time.sleep(2)
default_window = pytest.driver.current_window_handle
pytest.driver.find_element(By.XPATH,dynamic_locator).click()
time.sleep(5)
window_handle = list(pytest.driver.window_handles)
if len(window_handle) > 1:
pytest.driver.close()
pytest.driver.switch_to.window(window_handle[-1])

url_opened,message = self.check_redirection(value,url)
rows = [[value,url,url_opened,message]]
with open("Report.csv", 'a', newline='\n') as csvfile:
csvwriter = csv.writer(csvfile)
csvwriter.writerows(rows)
if 'Not Working' in message:
pytest.driver.get_screenshot_as_file(os.path.join(os.path.dirname(os.curdir), "report\screenshot", f"{__name__}_{value}.jpeg"))
pytest.fail()

except:
logging.info("Exception Occurred", exc_info=True)
> pytest.driver.get_screenshot_as_file(os.path.join(os.path.dirname(os.curdir), "report\screenshot", f"{__name__}_{value}.jpeg"))

test_prod\test_SL_footer_check.py:265:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:1032: in get_screenshot_as_file
png = self.get_screenshot_as_png()
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:1064: in get_screenshot_as_png
return base64.b64decode(self.get_screenshot_as_base64().encode('ascii'))
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:1074: in get_screenshot_as_base64
return self.execute(Command.SCREENSHOT)['value']
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:321: in execute
self.error_handler.check_response(response)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x000002189862D550>
response = {'status': 404, 'value': '{"value":{"error":"no such window","message":"no such window: target window already closed\\...\n\\tRtlGetAppContainerNamedObjectPath [0x77187BBE+286]\\n\\tRtlGetAppContainerNamedObjectPath [0x77187B8E+238]\\n"}}'}

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 = InvalidCookieDomainException
elif status in ErrorCode.UNABLE_TO_SET_COOKIE:
exception_class = UnableToSetCookieException
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
elif status in ErrorCode.JAVASCRIPT_ERROR:
exception_class = JavascriptException
elif status in ErrorCode.SESSION_NOT_CREATED:
exception_class = SessionNotCreatedException
elif status in ErrorCode.INVALID_ARGUMENT:
exception_class = InvalidArgumentException
elif status in ErrorCode.NO_SUCH_COOKIE:
exception_class = NoSuchCookieException
elif status in ErrorCode.UNABLE_TO_CAPTURE_SCREEN:
exception_class = ScreenshotException
elif status in ErrorCode.ELEMENT_CLICK_INTERCEPTED:
exception_class = ElementClickInterceptedException
elif status in ErrorCode.INSECURE_CERTIFICATE:
exception_class = InsecureCertificateException
elif status in ErrorCode.INVALID_COORDINATES:
exception_class = InvalidCoordinatesException
elif status in ErrorCode.INVALID_SESSION_ID:
exception_class = InvalidSessionIdException
elif status in ErrorCode.UNKNOWN_METHOD:
exception_class = UnknownMethodException
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:
alert_text = None
if 'data' in value:
alert_text = value['data'].get('text')
elif 'alert' in value:
alert_text = value['alert'].get('text')
raise exception_class(message, screen, stacktrace, alert_text)
> raise exception_class(message, screen, stacktrace)
E selenium.common.exceptions.NoSuchWindowException: Message: no such window: target window already closed
E from unknown error: web view not found
E (Session info: chrome=110.0.5481.100)

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py:242: NoSuchWindowException
-------------------------------Captured log call--------------------------------
INFO  setup:test_SL_footer_check.py:230 Get the Android App INFO  setup:test_SL_footer_check.py:236 URL for Get the Android App is : https://play.google.com/store/apps/details?id=com.mobile.simplilearn INFO  setup:test_SL_footer_check.py:264 Exception Occurred Traceback (most recent call last): File "C:\test_repos\pre_sales_test_python\test_prod\test_SL_footer_check.py", line 239, in test_SL_Footer_check pytest.driver.get(pytest.config['prod_url']) File "c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 333, in get self.execute(Command.GET, {'url': url}) File "c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute self.error_handler.check_response(response) File "c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.NoSuchWindowException: Message: no such window: target window already closed from unknown error: web view not found (Session info: chrome=110.0.5481.100)
Failed test_SL_footer_check.py::TestSLFooterCheck::test_SL_Footer_check[Get the iOS App] 0.01
self = <test_SL_footer_check.TestSLFooterCheck object at 0x0000021898F005B0>, value = 'Get the iOS App'
initialize_pages = None

@pytest.mark.test_details("SLUB-T0000","high","Sl Footer Check","Pradeep")
@pytest.mark.parametrize("value",_create_parameterised_data())
def test_SL_Footer_check(self,value,initialize_pages):
try:
logging.info(value)
with open('sl_footer_check_test_data.csv', 'r') as csv_file:
csv_data = csv.reader(csv_file)
for line in csv_data:
if line[0] == value:
url = line[1]
logging.info(f"URL for {value} is : {url}")
break

> pytest.driver.get(pytest.config['prod_url'])

test_prod\test_SL_footer_check.py:239:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.chrome.webdriver.WebDriver (session="7643857c856eba21654096eb2db552ee")>
url = 'https://www.simplilearn.com/'

def get(self, url):
"""
Loads a web page in the current browser session.
"""
> self.execute(Command.GET, {'url': url})

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:333:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.chrome.webdriver.WebDriver (session="7643857c856eba21654096eb2db552ee")>
driver_command = 'get', params = {'url': 'https://www.simplilearn.com/'}

def execute(self, driver_command, params=None):
"""
Sends a command to be executed by a command.CommandExecutor.

:Args:
- driver_command: The name of the command to execute as a string.
- params: A dictionary of named parameters to send with the command.

:Returns:
The command's JSON response loaded into a dictionary object.
"""
if self.session_id is not None:
if not params:
params = {'sessionId': self.session_id}
elif 'sessionId' not in params:
params['sessionId'] = self.session_id

params = self._wrap_value(params)
response = self.command_executor.execute(driver_command, params)
if response:
> self.error_handler.check_response(response)

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:321:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x000002189862D550>
response = {'status': 404, 'value': '{"value":{"error":"no such window","message":"no such window: target window already closed\\...\n\\tRtlGetAppContainerNamedObjectPath [0x77187BBE+286]\\n\\tRtlGetAppContainerNamedObjectPath [0x77187B8E+238]\\n"}}'}

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 = InvalidCookieDomainException
elif status in ErrorCode.UNABLE_TO_SET_COOKIE:
exception_class = UnableToSetCookieException
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
elif status in ErrorCode.JAVASCRIPT_ERROR:
exception_class = JavascriptException
elif status in ErrorCode.SESSION_NOT_CREATED:
exception_class = SessionNotCreatedException
elif status in ErrorCode.INVALID_ARGUMENT:
exception_class = InvalidArgumentException
elif status in ErrorCode.NO_SUCH_COOKIE:
exception_class = NoSuchCookieException
elif status in ErrorCode.UNABLE_TO_CAPTURE_SCREEN:
exception_class = ScreenshotException
elif status in ErrorCode.ELEMENT_CLICK_INTERCEPTED:
exception_class = ElementClickInterceptedException
elif status in ErrorCode.INSECURE_CERTIFICATE:
exception_class = InsecureCertificateException
elif status in ErrorCode.INVALID_COORDINATES:
exception_class = InvalidCoordinatesException
elif status in ErrorCode.INVALID_SESSION_ID:
exception_class = InvalidSessionIdException
elif status in ErrorCode.UNKNOWN_METHOD:
exception_class = UnknownMethodException
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:
alert_text = None
if 'data' in value:
alert_text = value['data'].get('text')
elif 'alert' in value:
alert_text = value['alert'].get('text')
raise exception_class(message, screen, stacktrace, alert_text)
> raise exception_class(message, screen, stacktrace)
E selenium.common.exceptions.NoSuchWindowException: Message: no such window: target window already closed
E from unknown error: web view not found
E (Session info: chrome=110.0.5481.100)

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py:242: NoSuchWindowException

During handling of the above exception, another exception occurred:

self = <test_SL_footer_check.TestSLFooterCheck object at 0x0000021898F005B0>, value = 'Get the iOS App'
initialize_pages = None

@pytest.mark.test_details("SLUB-T0000","high","Sl Footer Check","Pradeep")
@pytest.mark.parametrize("value",_create_parameterised_data())
def test_SL_Footer_check(self,value,initialize_pages):
try:
logging.info(value)
with open('sl_footer_check_test_data.csv', 'r') as csv_file:
csv_data = csv.reader(csv_file)
for line in csv_data:
if line[0] == value:
url = line[1]
logging.info(f"URL for {value} is : {url}")
break

pytest.driver.get(pytest.config['prod_url'])
selenium_helper.wait_for_page_to_load(20,pytest.config['prod_url'])
dynamic_locator = f"(//div[starts-with(@class,'col-md-2')]//a[@title='{value}'])[1]"
logging.info(f"Dynamic Locator : {dynamic_locator}")
time.sleep(3)
WebDriverWait(pytest.driver, 20).until(EC.element_to_be_clickable((By.XPATH, dynamic_locator))).scroll_to_element()
time.sleep(2)
default_window = pytest.driver.current_window_handle
pytest.driver.find_element(By.XPATH,dynamic_locator).click()
time.sleep(5)
window_handle = list(pytest.driver.window_handles)
if len(window_handle) > 1:
pytest.driver.close()
pytest.driver.switch_to.window(window_handle[-1])

url_opened,message = self.check_redirection(value,url)
rows = [[value,url,url_opened,message]]
with open("Report.csv", 'a', newline='\n') as csvfile:
csvwriter = csv.writer(csvfile)
csvwriter.writerows(rows)
if 'Not Working' in message:
pytest.driver.get_screenshot_as_file(os.path.join(os.path.dirname(os.curdir), "report\screenshot", f"{__name__}_{value}.jpeg"))
pytest.fail()

except:
logging.info("Exception Occurred", exc_info=True)
> pytest.driver.get_screenshot_as_file(os.path.join(os.path.dirname(os.curdir), "report\screenshot", f"{__name__}_{value}.jpeg"))

test_prod\test_SL_footer_check.py:265:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:1032: in get_screenshot_as_file
png = self.get_screenshot_as_png()
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:1064: in get_screenshot_as_png
return base64.b64decode(self.get_screenshot_as_base64().encode('ascii'))
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:1074: in get_screenshot_as_base64
return self.execute(Command.SCREENSHOT)['value']
c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py:321: in execute
self.error_handler.check_response(response)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <selenium.webdriver.remote.errorhandler.ErrorHandler object at 0x000002189862D550>
response = {'status': 404, 'value': '{"value":{"error":"no such window","message":"no such window: target window already closed\\...\n\\tRtlGetAppContainerNamedObjectPath [0x77187BBE+286]\\n\\tRtlGetAppContainerNamedObjectPath [0x77187B8E+238]\\n"}}'}

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 = InvalidCookieDomainException
elif status in ErrorCode.UNABLE_TO_SET_COOKIE:
exception_class = UnableToSetCookieException
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
elif status in ErrorCode.JAVASCRIPT_ERROR:
exception_class = JavascriptException
elif status in ErrorCode.SESSION_NOT_CREATED:
exception_class = SessionNotCreatedException
elif status in ErrorCode.INVALID_ARGUMENT:
exception_class = InvalidArgumentException
elif status in ErrorCode.NO_SUCH_COOKIE:
exception_class = NoSuchCookieException
elif status in ErrorCode.UNABLE_TO_CAPTURE_SCREEN:
exception_class = ScreenshotException
elif status in ErrorCode.ELEMENT_CLICK_INTERCEPTED:
exception_class = ElementClickInterceptedException
elif status in ErrorCode.INSECURE_CERTIFICATE:
exception_class = InsecureCertificateException
elif status in ErrorCode.INVALID_COORDINATES:
exception_class = InvalidCoordinatesException
elif status in ErrorCode.INVALID_SESSION_ID:
exception_class = InvalidSessionIdException
elif status in ErrorCode.UNKNOWN_METHOD:
exception_class = UnknownMethodException
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:
alert_text = None
if 'data' in value:
alert_text = value['data'].get('text')
elif 'alert' in value:
alert_text = value['alert'].get('text')
raise exception_class(message, screen, stacktrace, alert_text)
> raise exception_class(message, screen, stacktrace)
E selenium.common.exceptions.NoSuchWindowException: Message: no such window: target window already closed
E from unknown error: web view not found
E (Session info: chrome=110.0.5481.100)

c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py:242: NoSuchWindowException
-------------------------------Captured log call--------------------------------
INFO  setup:test_SL_footer_check.py:230 Get the iOS App INFO  setup:test_SL_footer_check.py:236 URL for Get the iOS App is : https://apps.apple.com/app/simplilearn/id963042747?ls=1 INFO  setup:test_SL_footer_check.py:264 Exception Occurred Traceback (most recent call last): File "C:\test_repos\pre_sales_test_python\test_prod\test_SL_footer_check.py", line 239, in test_SL_Footer_check pytest.driver.get(pytest.config['prod_url']) File "c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 333, in get self.execute(Command.GET, {'url': url}) File "c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute self.error_handler.check_response(response) File "c:\users\qateam\appdata\local\programs\python\python38\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.NoSuchWindowException: Message: no such window: target window already closed from unknown error: web view not found (Session info: chrome=110.0.5481.100)