在 Selenium (WebDriver) 中,根据操作系统,Firefox 驱动程序使用“本地事件”来模拟用户交互(键盘、鼠标等)。它还可以使用“综合事件”,即通过 Javascript 模拟的用户交互。
如何禁用 native 事件并启用合成事件? (在 Python 中)
最佳答案
在 Firefox 配置文件中,您可以像这样设置首选项或属性(两者具有相同的效果):
profile.native_events_enabled = False
或者...
profile.set_preference('webdriver_enable_native_events', False)
例子:
from selenium import webdriver
profile = webdriver.FirefoxProfile()
profile.native_events_enabled = False
driver = webdriver.Firefox(profile)
# synthesized events are now enabled for this
# driver instance... native events are disabled.
...
关于python - Selenium WebDriver - 禁用 native 事件(启用综合事件),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19471102/