【发布时间】:2018-09-24 07:42:43
【问题描述】:
我正在终端中使用 python 运行 selenium 测试。当我运行测试时,Firefox 窗口在终端后面打开。如何让它在前台打开 Firefox 窗口?
我试过了:
# Store the current window handle
currentWindowHandle = webDriver.current_window_handle
# Run your javascript alert code
webDriver.execute_script("alert('Test')")
webDriver.switch_to.alert.accept()
# Switch back to to the window using the handle saved earlier
webDriver.switch_to.window(currentWindowHandle)
还有:
webDriver.maximize_window()
这两个解决方案是由this previous stackoverflow question 提出的。但它们不适用于 osx。
【问题讨论】:
标签: python-3.x macos selenium