Switch Window sporadically fails with TypeError
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 35/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- python
- 领域
- testing-qa
调研方向
从 src/SeleniumLibrary/locators/windowmanager.py 中解包 execute_script("return [ window.id, window.name ];") 结果的那一行开始。使用延迟打开的新标签页重现 Switch Window 场景,并检查现有的异常处理和 timeout 流程。完成标准是解决间歇性 TypeError,同时不破坏窗口切换或请求的 timeout 行为。
由索引模型根据 Issue 内容生成。
描述
Observed with
Python 3.13.0
SeleniumLibrary 6.7.1
Scenario
I have the following scenario in a test which fails sporadically:
- Link in an (internal) application is clicked which opens a different URL in a new tab
Switch Windowis called with the expected URL as locator and10 sas a timeout
Expected behaviour
The new window is switched to. If the window is not immediately available/ready when this keyword is started, it should wait until the window can be switched to, within the given timeout limits.
Error
This works just fine most of the time, but occasionally I get the following error:
TypeError: cannot unpack non-iterable NoneType object
This error shows up pretty much instantly (within a few hundred ms), so the timeout is not taken into account.
However, in the associated screenshots, the expected page is always shown.
Analysis
I looked into the library's code and added some extra logging, which showed the error was coming from this line:
https://github.com/robotframework/SeleniumLibrary/blob/ce9d0ec510bd99c5a1b1cd114f767c7feeae1208/src/SeleniumLibrary/locators/windowmanager.py#L199
The call to self.driver.execute_script("return [ window.id, window.name ];") returns None, thus the assignment to the two variables fails with the above error.
Adding a 1 s sleep right before the call to execute_script makes the error no longer occur (even with many iterations of the test), so it does seem to be somehow timing related.
I guess there's a short timeframe where the window is there but not fully ready and this makes the function call fail? But I wasn't able to understand the exact nature of this presumed 'not ready' state so far.
Proposed solution
The TypeError could be added to the already present except, which successfully avoided failures due to this in my scenario.
Adding this would be trivial, but I'm not sure about the implications:
- does anything depend on the current behaviour that raises an error in this case (seems not, but I'm not super familiar with the library's codebase)?
- would it be appropriate to suppress this error in the library, given it is not fully understood what exactly the nature of the actual, underlying error is?
Do you have any guidance how to proceed here?
- 主要语言
- Python
- 星标
- 1.5k
- 派生
- 787
- PR 合并指标
- 30 天内没有已合并 PR
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
robotframework/SeleniumLibrary 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 67/100
robotframework/SeleniumLibrary#1941 · 3 条评论 ·
-
难度 1/5 1 小时以内 新手友好度 65/100
robotframework/SeleniumLibrary#1833 ·
-
难度 2/5 1-3 小时 新手友好度 68/100
robotframework/SeleniumLibrary#1436 · 5 条评论 ·
-
难度 3/5 1-2 天 新手友好度 58/100
robotframework/SeleniumLibrary#1993 ·
-
难度 4/5 3-5 天 新手友好度 35/100
robotframework/SeleniumLibrary#1992 · 4 条评论 ·
查看 robotframework/SeleniumLibrary 的全部 Issue
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 86/100
zostera/django-bootstrap4#894 ·
-
难度 2/5 1-3 小时 新手友好度 78/100
use-agent-os/agent-os#3276 ·
-
难度 2/5 1-3 小时 新手友好度 88/100
zephyrproject-rtos/zephyr#119726 ·
-
area/auth bug comp/agent P3 platform/discord type/security
难度 2/5 1-3 小时 新手友好度 88/100
NousResearch/hermes-agent#117848 ·
-
难度 2/5 1-3 小时 新手友好度 82/100
zilliztech/memsearch#759 ·