• <small id='7r0zA'></small><noframes id='7r0zA'>

    • <bdo id='7r0zA'></bdo><ul id='7r0zA'></ul>
    <tfoot id='7r0zA'></tfoot>
    <i id='7r0zA'><tr id='7r0zA'><dt id='7r0zA'><q id='7r0zA'><span id='7r0zA'><b id='7r0zA'><form id='7r0zA'><ins id='7r0zA'></ins><ul id='7r0zA'></ul><sub id='7r0zA'></sub></form><legend id='7r0zA'></legend><bdo id='7r0zA'><pre id='7r0zA'><center id='7r0zA'></center></pre></bdo></b><th id='7r0zA'></th></span></q></dt></tr></i><div id='7r0zA'><tfoot id='7r0zA'></tfoot><dl id='7r0zA'><fieldset id='7r0zA'></fieldset></dl></div>

      1. <legend id='7r0zA'><style id='7r0zA'><dir id='7r0zA'><q id='7r0zA'></q></dir></style></legend>

        如何在 python 2.7 的自动登录脚本中使用浏览器保存的凭据?

        How do you use credentials saved by the browser in auto login script in python 2.7?(如何在 python 2.7 的自动登录脚本中使用浏览器保存的凭据?)

        1. <small id='hpPir'></small><noframes id='hpPir'>

          <i id='hpPir'><tr id='hpPir'><dt id='hpPir'><q id='hpPir'><span id='hpPir'><b id='hpPir'><form id='hpPir'><ins id='hpPir'></ins><ul id='hpPir'></ul><sub id='hpPir'></sub></form><legend id='hpPir'></legend><bdo id='hpPir'><pre id='hpPir'><center id='hpPir'></center></pre></bdo></b><th id='hpPir'></th></span></q></dt></tr></i><div id='hpPir'><tfoot id='hpPir'></tfoot><dl id='hpPir'><fieldset id='hpPir'></fieldset></dl></div>
            <tbody id='hpPir'></tbody>
        2. <legend id='hpPir'><style id='hpPir'><dir id='hpPir'><q id='hpPir'></q></dir></style></legend>

              <bdo id='hpPir'></bdo><ul id='hpPir'></ul>

                1. <tfoot id='hpPir'></tfoot>

                  本文介绍了如何在 python 2.7 的自动登录脚本中使用浏览器保存的凭据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  当我手动打开浏览器(firefox 和 chrome)并继续访问我之前通过浏览器保存登录凭据的网站时,用户名和密码字段会自动填充.但是,当我使用 python selenium webdriver 打开浏览器到特定页面时,不会填充这些字段.

                  When I manually open a browser, both firefox and chrome, and proceed to a website where I previously saved my login credentials via the browser, the username and password fields automatically populate as they should. However, when I use the python selenium webdriver to open the browser to a specific page, the fields do not populate.

                  我的脚本的重点是打开网页并使用 element.submit() 登录,因为应该已经填充了登录凭据.但不是.我怎样才能让它们在田野中填充?

                  The point of my script is to open the webpage and use element.submit() to login since the login credentials should already be populated., but the are NOT. How can i get them to populate in the fields?

                  例如:

                  driver = webdriver.Chrome()    
                  driver.get("https://facebook.com")    
                  element = driver.find_element_by_id("u_0_v")    
                  element.submit()
                  

                  推荐答案

                  这是因为 selenium 不使用您的默认浏览器实例,它会打开一个具有临时(空)配置文件的不同实例.

                  This is because selenium doesn't use your default browser instance, it opens a different instance with a temporary (empty) profile.

                  如果您希望它加载默认配置文件,您需要指示它这样做.

                  If you would like it to load a default profile you need to instruct it to do so.

                  这是一个 chrome 示例:

                  Here's a chrome example:

                  from selenium import webdriver
                  from selenium.webdriver.chrome.options import Options
                  
                  options = webdriver.ChromeOptions() 
                  options.add_argument("user-data-dir=C:\Path") #Path to your chrome profile
                  w = webdriver.Chrome(executable_path="C:\Users\chromedriver.exe", chrome_options=options)
                  

                  这是一个火狐的例子:

                  from selenium import webdriver
                  from selenium.webdriver.firefox.webdriver import FirefoxProfile
                  
                  profile = FirefoxProfile("C:\Path\to\profile")
                  driver = webdriver.Firefox(profile)
                  

                  我们开始吧,只需在(非官方)文档中找到此链接.Firefox 配置文件 和 Chrome驱动程序信息就在它的下方.

                  Here we go, just dug up a link to this in the (unofficial) documentation. Firefox Profile and the Chrome driver info is right underneath it.

                  这篇关于如何在 python 2.7 的自动登录脚本中使用浏览器保存的凭据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  env: python: No such file or directory(env: python: 没有这样的文件或目录)
                  How to evaluate environment variables into a string in Python?(如何在 Python 中将环境变量评估为字符串?)
                  Python - temporarily modify the current process#39;s environment(Python - 临时修改当前进程的环境)
                  Change current process environment#39;s LD_LIBRARY_PATH(更改当前进程环境的 LD_LIBRARY_PATH)
                  Reading and writing environment variables in Python?(在 Python 中读写环境变量?)
                  When to use sys.path.append and when modifying %PYTHONPATH% is enough(何时使用 sys.path.append 以及何时修改 %PYTHONPATH% 就足够了)

                  • <legend id='xOjes'><style id='xOjes'><dir id='xOjes'><q id='xOjes'></q></dir></style></legend>
                        <tbody id='xOjes'></tbody>

                    1. <small id='xOjes'></small><noframes id='xOjes'>

                      • <bdo id='xOjes'></bdo><ul id='xOjes'></ul>

                      • <tfoot id='xOjes'></tfoot>
                        • <i id='xOjes'><tr id='xOjes'><dt id='xOjes'><q id='xOjes'><span id='xOjes'><b id='xOjes'><form id='xOjes'><ins id='xOjes'></ins><ul id='xOjes'></ul><sub id='xOjes'></sub></form><legend id='xOjes'></legend><bdo id='xOjes'><pre id='xOjes'><center id='xOjes'></center></pre></bdo></b><th id='xOjes'></th></span></q></dt></tr></i><div id='xOjes'><tfoot id='xOjes'></tfoot><dl id='xOjes'><fieldset id='xOjes'></fieldset></dl></div>