• <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 的自动登录脚本中使用浏览器保存的凭据?

        时间:2023-07-04

        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 的自动登录脚本中使用浏览器保存的凭据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:Python 中 Selenium Webdriver 测试失败时的自动截图 下一篇:使用 Selenium Webdriver 下载时命名文件

                  相关文章

                2. <legend id='xOjes'><style id='xOjes'><dir id='xOjes'><q id='xOjes'></q></dir></style></legend>
                  1. <small id='xOjes'></small><noframes id='xOjes'>

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

                  2. <tfoot id='xOjes'></tfoot>
                  3. <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>