如何在 Firefox 中使用 Selenium 和 Python 禁用自动完成功能? [英] How to disable autocomplete in Firefox using Selenium with Python?

查看:34
本文介绍了如何在 Firefox 中使用 Selenium 和 Python 禁用自动完成功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Selenium 构建自动化测试任务.当我将第一个字段放在表单上时,其余部分会根据之前的尝试自动完成.我可以清除字段来处理这个问题,但如果我完全禁用自动完成功能会更容易.
有没有办法在 Python Selenium 中做到这一点?

I am building an automated test task with Selenium. When I put the first field on a form, the rest of it is autocompleted based on previous attempts. I can clear the fields to handle this, but it would be easier if I could disable autocomplete at all.
Is there a way to do this in Python Selenium?

我正在创建一个配置文件:

I am creating a profile with:

profile = webdriver.FirefoxProfile()
profile.accept_untrusted_certs = True
profile.set_preference("security.enable_java", True)
profile.set_preference("plugin.state.java", 2) 
driver = webdriver.Firefox(firefox_profile=profile)

推荐答案

您需要设置browser.formfill.enable Firefox 配置文件首选项 false 要求 Firefox 不记住并自动填充表单输入值:

You need to set browser.formfill.enable firefox profile preference to false to ask Firefox not to remember and autofill form input values:

profile.set_preference("browser.formfill.enable", "false")

这篇关于如何在 Firefox 中使用 Selenium 和 Python 禁用自动完成功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆