Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Review `Handle Alert when popup window closes` test

未关闭
#1,818 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
28/100
Issue 类型
缺陷
描述清晰度
需要澄清
活跃度
停滞
技术栈
python
领域
testing-qa

调研方向

从“Handle Alert when popup window closes”验收测试开始,并比较关联的 GitHub Actions 运行中的通过日志和失败日志。然后检查 src/SeleniumLibrary/keywords/alert.py 中的 alert 处理路径,尤其是 _handle_alert 和 _wait_alert;完成的标准是测试结果一致且可理解,并且不再出现报告中的窗口或 alert 失败。

由索引模型根据 Issue 内容生成。

描述

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.

主要语言
Python
星标
1.5k
派生
787
PR 合并指标
30 天内没有已合并 PR

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

robotframework/SeleniumLibrary 的其他 Issue

查看 robotframework/SeleniumLibrary 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。