我正在使用 Selenium-python 脚本进行 Web 测试自动化。每当我使用 selenium 内置命令时,我都会在运行时收到属性错误。
例如:selenium.WindowFocus("preview_email") 抛出“AttributeError: class selenium has no attribute 'WindowFocus'”
我是测试自动化的新手。帮我解决这个问题。
我正在使用 Selenium-python 脚本进行 Web 测试自动化。每当我使用 selenium 内置命令时,我都会在运行时收到属性错误。
例如:selenium.WindowFocus("preview_email") 抛出“AttributeError: class selenium has no attribute 'WindowFocus'”
我是测试自动化的新手。帮我解决这个问题。
您正在寻找的命令是selenium.window_focus()
I have never used the Python client personally, but a quick glance at the selenium.py file reveals that there is a window_focus command which gives the currently "selected" window focus ("selected" in Selenium terms is the window that Selenium is currently executing commands against and not necessarially the window that has user focus).
Executing the select_window command with a window ID will set tell Selenium which window you want to execute commands against.
I have had some trouble w/ popups in general and the way the Selenium IDE and RC clients attempt to locate new windows and/or there parents. Good luck.
我认为您想强制网络驱动程序转到另一个名为“preview_email”的窗口。
为此,您需要使用selenium.switch_to_window("preview_email")
; 因为selenium.window_focus()
只是将焦点放在当前选定的窗口上并且不接受任何参数。此外,您在 JAVA 模式下使用它(我的意思是selenium.windowFocus()
)。