在Selenium(WebDriver)中,根据操作系统,Firefox驱动程序使用“本机事件”进行用户交互模拟(键盘,鼠标等).它还可以使用“合成事件”,通过Javascript模拟用户交互.
如何禁用本机事件,并启用合成事件? (在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.
...
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。