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

      <small id='Qq71P'></small><noframes id='Qq71P'>

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

      无法使用无头铬在网页上定位元素

      Unable to locate elements on webpage with headless chrome(无法使用无头铬在网页上定位元素)
          <tbody id='Ujxaz'></tbody>
        • <i id='Ujxaz'><tr id='Ujxaz'><dt id='Ujxaz'><q id='Ujxaz'><span id='Ujxaz'><b id='Ujxaz'><form id='Ujxaz'><ins id='Ujxaz'></ins><ul id='Ujxaz'></ul><sub id='Ujxaz'></sub></form><legend id='Ujxaz'></legend><bdo id='Ujxaz'><pre id='Ujxaz'><center id='Ujxaz'></center></pre></bdo></b><th id='Ujxaz'></th></span></q></dt></tr></i><div id='Ujxaz'><tfoot id='Ujxaz'></tfoot><dl id='Ujxaz'><fieldset id='Ujxaz'></fieldset></dl></div>

              <legend id='Ujxaz'><style id='Ujxaz'><dir id='Ujxaz'><q id='Ujxaz'></q></dir></style></legend>
              • <bdo id='Ujxaz'></bdo><ul id='Ujxaz'></ul>
              • <tfoot id='Ujxaz'></tfoot>

                <small id='Ujxaz'></small><noframes id='Ujxaz'>

                本文介绍了无法使用无头铬在网页上定位元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我有一个访问打印机的脚本,当Chrome正常运行时,我的代码工作得很好,但当它无头运行时,Selenium似乎找不到网页上的元素。

                相关代码如下:

                初始化方法:

                def __init__(self, ip_address):
                    """ Initialize a new Printer_Webpage object."""
                    self.ip_address = ip_address
                    chrome_options = Options()
                    chrome_options.add_argument("--headless")
                    chrome_options.add_argument("--disable-gpu")
                    chrome_options.add_argument("--window-size=1920x1080")
                    self.browser = webdriver.Chrome(chrome_options=chrome_options)
                    # Ignore lack of cert for each printer web page.
                    # Otherwise, can't open page.
                    self.browser.accept_untrusted_certs = True
                

                登录方式:

                def login(self):
                    """Navigates through the login page for the printer."""
                    # Open login page
                    self.browser.get(f'https://{self.ip_address}/wcd/top.xml')
                    # STEPS TO LOGIN:
                    # 1) Select 'Administrator' radio button and click.
                    self.browser.find_element_by_id('Admin').click()
                    # 2) Select Login button and click.
                    self.browser.find_element_by_xpath("//input[@type='submit' 
                                                        and @value='Login']").click()
                    # 3) Select admin (user mode)
                    self.browser.find_element_by_id('R_ADM2').click()
                    # 4) Select password field and input PASSWORD, then submit.
                    password_field = self.browser.find_element_by_id('Admin_Pass')
                    password_field.send_keys(PASSWORD)
                    password_field.send_keys(Keys.RETURN)
                

                完整错误消息:

                selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"id","selector":"Admin"}
                

                以下是其他一些可能有用的信息:

                (Session info: headless chrome=62.0.3202.94)
                
                (Driver info: chromedriver=2.33.506120 (e3e53437346286c0bc2d2dc9aa4915ba81d9023f),platform=Windows NT 10.0.14393 x86_64)
                

                推荐答案

                如果是SSL证书的问题,您可以使用命令行标志在没有证书的情况下启动Chrome(假设您是这样启动的)。我相信开关是--allow-running-insecure-content,我从这个列表中找到了here。

                这篇关于无法使用无头铬在网页上定位元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                相关文档推荐

                GUI Freezes while downloading PyQt5 and Pytube(GUI在下载PyQt5和Pytube时冻结)
                How to solve memory issues while multiprocessing using Pool.map()?(如何解决使用Pool.map()进行多处理时的内存问题?)
                Python - How to use FastAPI and uvicorn.run without blocking the thread?(Python-如何使用FastAPI和uvicorn.run而不阻塞线程?)
                How to increment a shared counter from multiple processes?(如何从多个进程递增共享计数器?)
                Using pika, how to connect to rabbitmq running in docker, started with docker-compose with external network?(使用pika,如何连接运行在docker中的rabbitmq,从docker开始-与外部网络连接?)
                How to use .rolling() on each row of a Pandas dataframe?(如何对 pandas 数据帧的每一行使用.roll()?)

                    <tbody id='ZWT2N'></tbody>
                • <small id='ZWT2N'></small><noframes id='ZWT2N'>

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

                        <tfoot id='ZWT2N'></tfoot>
                        <legend id='ZWT2N'><style id='ZWT2N'><dir id='ZWT2N'><q id='ZWT2N'></q></dir></style></legend>

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