感谢Debanjan(并为以后的回复表示歉意-刚回到办公室)。我能够通过使用解决此问题
While True:
try:
[navigate to the new frame, wait for a specific element to show up]
break
except (NoSuchWindowException, NoSuchElementException):
pass
我没有意识到,当我单击打开表单时,另一个窗口在后台非常短暂地打开,然后关闭。这将window_handles增加到2,因此执行与等待2个窗口句柄有关的任何操作仍然会引发错误。