Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Review Handle Alert when popup window closes test #1818

Open
emanlove opened this issue Apr 27, 2023 · 0 comments
Open

Review Handle Alert when popup window closes test #1818

emanlove opened this issue Apr 27, 2023 · 0 comments

Comments

@emanlove
Copy link
Member

emanlove commented Apr 27, 2023

In running the acceptance test for a recent pull request we received varying results on the Handle Alert when popup window closes test case.

When it fails the following trace loglevel is shown

<html>
<body>
<!--StartFragment-->

10:22:53.373 | INFO | HANDLE::<class 'datetime.timedelta'>::0:00:10 |  
-- | -- | -- | --


<!--EndFragment-->
</body>
</html>10:22:53.373	INFO	HANDLE::<class 'datetime.timedelta'>::0:00:10	
10:22:53.373	DEBUG	GET http://localhost:46269/session/59f81e650237aeb4b439252651ba8358/alert/text {}	
10:22:53.379	DEBUG	http://localhost:46269/ "GET /session/59f81e650237aeb4b439252651ba8358/alert/text HTTP/1.1" 404 747	
10:22:53.380	DEBUG	Remote response: status=404 | data={"value":{"error":"no such alert","message":"no such alert\n  (Session info: headless chrome=112.0.5615.165)","stacktrace":"#0 0x55f5ce88dfe3 \u003Cunknown>\n#1 0x55f5ce5ccbc1 \u003Cunknown>\n#2 0x55f5ce5c0b41 \u003Cunknown>\n#3 0x55f5ce5e4279 \u003Cunknown>\n#4 0x55f5ce62a91b \u003Cunknown>\n#5 0x55f5ce5e40ee \u003Cunknown>\n#6 0x55f5ce62a693 \u003Cunknown>\n#7 0x55f5ce5fd03a \u003Cunknown>\n#8 0x55f5ce5fe17e \u003Cunknown>\n#9 0x55f5ce84fdbd \u003Cunknown>\n#10 0x55f5ce853c6c \u003Cunknown>\n#11 0x55f5ce85d4b0 \u003Cunknown>\n#12 0x55f5ce854d63 \u003Cunknown>\n#13 0x55f5ce827c35 \u003Cunknown>\n#14 0x55f5ce878138 \u003Cunknown>\n#15 0x55f5ce8782c7 \u003Cunknown>\n#16 0x55f5ce886093 \u003Cunknown>\n#17 0x7fec88957b43 \u003Cunknown>\n"}} | headers=HTTPHeaderDict({'Content-Length': '747', 'Content-Type': 'application/json; charset=utf-8', 'cache-control': 'no-cache'})	
10:22:53.380	DEBUG	Finished Request	
10:22:53.881	DEBUG	GET http://localhost:46269/session/59f81e650237aeb4b439252651ba8358/alert/text {}	
10:22:53.893	DEBUG	http://localhost:46269/ "GET /session/59f81e650237aeb4b439252651ba8358/alert/text HTTP/1.1" 200 14	
10:22:53.894	DEBUG	Remote response: status=200 | data={"value":null} | headers=HTTPHeaderDict({'Content-Length': '14', 'Content-Type': 'application/json; charset=utf-8', 'cache-control': 'no-cache'})	
10:22:53.895	DEBUG	Finished Request	
10:22:53.895	DEBUG	GET http://localhost:46269/session/59f81e650237aeb4b439252651ba8358/alert/text {}	
10:22:53.897	DEBUG	http://localhost:46269/ "GET /session/59f81e650237aeb4b439252651ba8358/alert/text HTTP/1.1" 404 784	
10:22:53.898	DEBUG	Remote response: status=404 | data={"value":{"error":"no such window","message":"no such window: target window already closed\nfrom unknown error: web view not found\n  (Session info: headless chrome=112.0.5615.165)","stacktrace":"#0 0x55f5ce88dfe3 \u003Cunknown>\n#1 0x55f5ce5ccd36 \u003Cunknown>\n#2 0x55f5ce5a7b2c \u003Cunknown>\n#3 0x55f5ce62f83f \u003Cunknown>\n#4 0x55f5ce5e3ed1 \u003Cunknown>\n#5 0x55f5ce62a693 \u003Cunknown>\n#6 0x55f5ce5fd03a \u003Cunknown>\n#7 0x55f5ce5fe17e \u003Cunknown>\n#8 0x55f5ce84fdbd \u003Cunknown>\n#9 0x55f5ce853c6c \u003Cunknown>\n#10 0x55f5ce85d4b0 \u003Cunknown>\n#11 0x55f5ce854d63 \u003Cunknown>\n#12 0x55f5ce827c35 \u003Cunknown>\n#13 0x55f5ce878138 \u003Cunknown>\n#14 0x55f5ce8782c7 \u003Cunknown>\n#15 0x55f5ce886093 \u003Cunknown>\n#16 0x7fec88957b43 \u003Cunknown>\n"}} | headers=HTTPHeaderDict({'Content-Length': '784', 'Content-Type': 'application/json; charset=utf-8', 'cache-control': 'no-cache'})	
10:22:53.898	DEBUG	Finished Request	
10:22:53.898	FAIL	NoSuchWindowException: Message: no such window: target window already closed
from unknown error: web view not found
  (Session info: headless chrome=112.0.5615.165)
Stacktrace:
#0 0x55f5ce88dfe3 <unknown>
#1 0x55f5ce5ccd36 <unknown>
#2 0x55f5ce5a7b2c <unknown>
#3 0x55f5ce62f83f <unknown>
#4 0x55f5ce5e3ed1 <unknown>
#5 0x55f5ce62a693 <unknown>
#6 0x55f5ce5fd03a <unknown>
#7 0x55f5ce5fe17e <unknown>
#8 0x55f5ce84fdbd <unknown>
#9 0x55f5ce853c6c <unknown>
#10 0x55f5ce85d4b0 <unknown>
#11 0x55f5ce854d63 <unknown>
#12 0x55f5ce827c35 <unknown>
#13 0x55f5ce878138 <unknown>
#14 0x55f5ce8782c7 <unknown>
#15 0x55f5ce886093 <unknown>
#16 0x7fec88957b43 <unknown>
10:22:53.899	DEBUG	Traceback (most recent call last):
  File "/home/runner/work/SeleniumLibrary/SeleniumLibrary/src/SeleniumLibrary/__init__.py", line 513, in run_keyword
    return DynamicCore.run_keyword(self, name, args, kwargs)
  File "/opt/hostedtoolcache/PyPy/3.7.13/x64/site-packages/robotlibcore.py", line 122, in run_keyword
    return self.keywords[name](*args, **(kwargs or {}))
  File "/home/runner/work/SeleniumLibrary/SeleniumLibrary/src/SeleniumLibrary/keywords/alert.py", line 131, in handle_alert
    return self._handle_alert(alert, action)
  File "/home/runner/work/SeleniumLibrary/SeleniumLibrary/src/SeleniumLibrary/keywords/alert.py", line 135, in _handle_alert
    text = " ".join(alert.text.splitlines())
  File "/opt/hostedtoolcache/PyPy/3.7.13/x64/site-packages/selenium/webdriver/common/alert.py", line 59, in text
    return self.driver.execute(Command.W3C_GET_ALERT_TEXT)["value"]
  File "/home/runner/work/SeleniumLibrary/SeleniumLibrary/src/SeleniumLibrary/keywords/browsermanagement.py", line 773, in execute
    result = self._base_execute(driver_command, params)
  File "/opt/hostedtoolcache/PyPy/3.7.13/x64/site-packages/selenium/webdriver/remote/webdriver.py", line 440, in execute
    self.error_handler.check_response(response)
  File "/opt/hostedtoolcache/PyPy/3.7.13/x64/site-packages/selenium/webdriver/remote/errorhandler.py", line 245, 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: headless chrome=112.0.5615.165)
Stacktrace:
#0 0x55f5ce88dfe3 <unknown>
#1 0x55f5ce5ccd36 <unknown>
#2 0x55f5ce5a7b2c <unknown>
#3 0x55f5ce62f83f <unknown>
#4 0x55f5ce5e3ed1 <unknown>
#5 0x55f5ce62a693 <unknown>
#6 0x55f5ce5fd03a <unknown>
#7 0x55f5ce5fe17e <unknown>
#8 0x55f5ce84fdbd <unknown>
#9 0x55f5ce853c6c <unknown>
#10 0x55f5ce85d4b0 <unknown>
#11 0x55f5ce854d63 <unknown>
#12 0x55f5ce827c35 <unknown>
#13 0x55f5ce878138 <unknown>
#14 0x55f5ce8782c7 <unknown>
#15 0x55f5ce886093 <unknown>
#16 0x7fec88957b43 <unknown>

Where as when it pass we got the following

<html>
<body>
<!--StartFragment-->

Documentation: | Handles the current alert and returns its message.
-- | --
20230427 10:22:12.459 / 20230427 10:22:12.985 / 00:00:00.526

<!--EndFragment-->
</body>
</html>Documentation:	
Handles the current alert and returns its message.

Start / End / Elapsed:	20230427 10:22:12.459 / 20230427 10:22:12.985 / 00:00:00.526
10:22:12.460	INFO	HANDLE::<class 'datetime.timedelta'>::0:00:10	
10:22:12.460	DEBUG	GET http://localhost:46113/session/6bb6f29b435dcee71c2cb55ece3f2689/alert/text {}	
10:22:12.475	DEBUG	http://localhost:46113/ "GET /session/6bb6f29b435dcee71c2cb55ece3f2689/alert/text HTTP/1.1" 404 747	
10:22:12.476	DEBUG	Remote response: status=404 | data={"value":{"error":"no such alert","message":"no such alert\n  (Session info: headless chrome=112.0.5615.165)","stacktrace":"#0 0x556abadcdfe3 \u003Cunknown>\n#1 0x556abab0cbc1 \u003Cunknown>\n#2 0x556abab00b41 \u003Cunknown>\n#3 0x556abab24279 \u003Cunknown>\n#4 0x556abab6a91b \u003Cunknown>\n#5 0x556abab240ee \u003Cunknown>\n#6 0x556abab6a693 \u003Cunknown>\n#7 0x556abab3d03a \u003Cunknown>\n#8 0x556abab3e17e \u003Cunknown>\n#9 0x556abad8fdbd \u003Cunknown>\n#10 0x556abad93c6c \u003Cunknown>\n#11 0x556abad9d4b0 \u003Cunknown>\n#12 0x556abad94d63 \u003Cunknown>\n#13 0x556abad67c35 \u003Cunknown>\n#14 0x556abadb8138 \u003Cunknown>\n#15 0x556abadb82c7 \u003Cunknown>\n#16 0x556abadc6093 \u003Cunknown>\n#17 0x7f82165beb43 \u003Cunknown>\n"}} | headers=HTTPHeaderDict({'Content-Length': '747', 'Content-Type': 'application/json; charset=utf-8', 'cache-control': 'no-cache'})	
10:22:12.476	DEBUG	Finished Request	
10:22:12.977	DEBUG	GET http://localhost:46113/session/6bb6f29b435dcee71c2cb55ece3f2689/alert/text {}	
10:22:12.981	DEBUG	http://localhost:46113/ "GET /session/6bb6f29b435dcee71c2cb55ece3f2689/alert/text HTTP/1.1" 404 784	
10:22:12.982	DEBUG	Remote response: status=404 | data={"value":{"error":"no such window","message":"no such window: target window already closed\nfrom unknown error: web view not found\n  (Session info: headless chrome=112.0.5615.165)","stacktrace":"#0 0x556abadcdfe3 \u003Cunknown>\n#1 0x556abab0cd36 \u003Cunknown>\n#2 0x556abaae7b2c \u003Cunknown>\n#3 0x556abab6f83f \u003Cunknown>\n#4 0x556abab23ed1 \u003Cunknown>\n#5 0x556abab6a693 \u003Cunknown>\n#6 0x556abab3d03a \u003Cunknown>\n#7 0x556abab3e17e \u003Cunknown>\n#8 0x556abad8fdbd \u003Cunknown>\n#9 0x556abad93c6c \u003Cunknown>\n#10 0x556abad9d4b0 \u003Cunknown>\n#11 0x556abad94d63 \u003Cunknown>\n#12 0x556abad67c35 \u003Cunknown>\n#13 0x556abadb8138 \u003Cunknown>\n#14 0x556abadb82c7 \u003Cunknown>\n#15 0x556abadc6093 \u003Cunknown>\n#16 0x7f82165beb43 \u003Cunknown>\n"}} | headers=HTTPHeaderDict({'Content-Length': '784', 'Content-Type': 'application/json; charset=utf-8', 'cache-control': 'no-cache'})	
10:22:12.982	DEBUG	Finished Request	
10:22:12.983	FAIL	An exception occurred waiting for alert: Message: no such window: target window already closed
from unknown error: web view not found
  (Session info: headless chrome=112.0.5615.165)
Stacktrace:
#0 0x556abadcdfe3 <unknown>
#1 0x556abab0cd36 <unknown>
#2 0x556abaae7b2c <unknown>
#3 0x556abab6f83f <unknown>
#4 0x556abab23ed1 <unknown>
#5 0x556abab6a693 <unknown>
#6 0x556abab3d03a <unknown>
#7 0x556abab3e17e <unknown>
#8 0x556abad8fdbd <unknown>
#9 0x556abad93c6c <unknown>
#10 0x556abad9d4b0 <unknown>
#11 0x556abad94d63 <unknown>
#12 0x556abad67c35 <unknown>
#13 0x556abadb8138 <unknown>
#14 0x556abadb82c7 <unknown>
#15 0x556abadc6093 <unknown>
#16 0x7f82165beb43 <unknown>
10:22:12.985	DEBUG	Traceback (most recent call last):
  File "/home/runner/work/SeleniumLibrary/SeleniumLibrary/src/SeleniumLibrary/keywords/alert.py", line 148, in _wait_alert
    return wait.until(EC.alert_is_present())
  File "/opt/hostedtoolcache/PyPy/3.7.13/x64/site-packages/selenium/webdriver/support/wait.py", line 86, in until
    value = method(self._driver)
  File "/opt/hostedtoolcache/PyPy/3.7.13/x64/site-packages/selenium/webdriver/support/expected_conditions.py", line 439, in _predicate
    return driver.switch_to.alert
  File "/opt/hostedtoolcache/PyPy/3.7.13/x64/site-packages/selenium/webdriver/remote/switch_to.py", line 55, in alert
    _ = alert.text
  File "/opt/hostedtoolcache/PyPy/3.7.13/x64/site-packages/selenium/webdriver/common/alert.py", line 59, in text
    return self.driver.execute(Command.W3C_GET_ALERT_TEXT)["value"]
  File "/home/runner/work/SeleniumLibrary/SeleniumLibrary/src/SeleniumLibrary/keywords/browsermanagement.py", line 773, in execute
    result = self._base_execute(driver_command, params)
  File "/opt/hostedtoolcache/PyPy/3.7.13/x64/site-packages/selenium/webdriver/remote/webdriver.py", line 440, in execute
    self.error_handler.check_response(response)
  File "/opt/hostedtoolcache/PyPy/3.7.13/x64/site-packages/selenium/webdriver/remote/errorhandler.py", line 245, 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: headless chrome=112.0.5615.165)
Stacktrace:
#0 0x556abadcdfe3 <unknown>
#1 0x556abab0cd36 <unknown>
#2 0x556abaae7b2c <unknown>
#3 0x556abab6f83f <unknown>
#4 0x556abab23ed1 <unknown>
#5 0x556abab6a693 <unknown>
#6 0x556abab3d03a <unknown>
#7 0x556abab3e17e <unknown>
#8 0x556abad8fdbd <unknown>
#9 0x556abad93c6c <unknown>
#10 0x556abad9d4b0 <unknown>
#11 0x556abad94d63 <unknown>
#12 0x556abad67c35 <unknown>
#13 0x556abadb8138 <unknown>
#14 0x556abadb82c7 <unknown>
#15 0x556abadc6093 <unknown>
#16 0x7f82165beb43 <unknown>


During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/runner/work/SeleniumLibrary/SeleniumLibrary/src/SeleniumLibrary/__init__.py", line 513, in run_keyword
    return DynamicCore.run_keyword(self, name, args, kwargs)
  File "/opt/hostedtoolcache/PyPy/3.7.13/x64/site-packages/robotlibcore.py", line 122, in run_keyword
    return self.keywords[name](*args, **(kwargs or {}))
  File "/home/runner/work/SeleniumLibrary/SeleniumLibrary/src/SeleniumLibrary/keywords/alert.py", line 130, in handle_alert
    alert = self._wait_alert(timeout)
  File "/home/runner/work/SeleniumLibrary/SeleniumLibrary/src/SeleniumLibrary/keywords/alert.py", line 152, in _wait_alert
    raise AssertionError(f"An exception occurred waiting for alert: {err}")
AssertionError: An exception occurred waiting for alert: Message: no such window: target window already closed
from unknown error: web view not found
  (Session info: headless chrome=112.0.5615.165)
Stacktrace:
#0 0x556abadcdfe3 <unknown>
#1 0x556abab0cd36 <unknown>
#2 0x556abaae7b2c <unknown>
#3 0x556abab6f83f <unknown>
#4 0x556abab23ed1 <unknown>
#5 0x556abab6a693 <unknown>
#6 0x556abab3d03a <unknown>
#7 0x556abab3e17e <unknown>
#8 0x556abad8fdbd <unknown>
#9 0x556abad93c6c <unknown>
#10 0x556abad9d4b0 <unknown>
#11 0x556abad94d63 <unknown>
#12 0x556abad67c35 <unknown>
#13 0x556abadb8138 <unknown>
#14 0x556abadb82c7 <unknown>
#15 0x556abadc6093 <unknown>
#16 0x7f82165beb43 <unknown>

Noting a couple of differences. First when it fails there seems to be a 200 response from the alert/text webdriver command. And then when it passes we see that the NoSuchWindow exception is thrown. This may be narrowed down to adding that exception to the handle alert code.

This is placeholder to look at strange results we are seeing with the acceptance tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant