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

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

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

        • <bdo id='RrfYk'></bdo><ul id='RrfYk'></ul>
      2. &quot;find_element_by_name(&#39;name&#39;)&q

        What is the difference between quot;find_element_by_name(#39;name#39;)quot; and quot;find_element(By.NAME, #39;name#39;)quot;?(quot;find_element_by_name(#39;name#39;)quot;和QOOT;FIND_ELEMENT(BY NAME,#39;NAME#39;)QUOT;之间有什么区别

          • <bdo id='22heD'></bdo><ul id='22heD'></ul>
              1. <legend id='22heD'><style id='22heD'><dir id='22heD'><q id='22heD'></q></dir></style></legend>
                  <tbody id='22heD'></tbody>

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

                <tfoot id='22heD'></tfoot>
                • <small id='22heD'></small><noframes id='22heD'>

                  本文介绍了&quot;find_element_by_name(&#39;name&#39;)&quot;和&QOOT;FIND_ELEMENT(BY NAME,&#39;NAME&#39;)&QUOT;之间有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  示例:

                  # method 1
                  from selenium import webdriver
                  
                  PATH = '...'
                  driver = webdriver.Chrome(PATH)
                  driver.get('https://google.com')
                  driver.find_element_by_name('q').send_keys('test')
                  
                  # method 2
                  from selenium import webdriver
                  from selenium.webdriver.common.by import By
                  
                  PATH = 'c:\Program Files (x86)\chromedriver.exe'
                  driver = webdriver.Chrome(PATH)
                  driver.get('https://google.com')
                  driver.find_element(By.NAME, 'q').send_keys('test')
                  

                  基本上,我想知道:

                  1-两者之间有什么不同?如果有,是什么?

                  2-一般来说,这两者有什么区别吗?

                  find_element_by_class_name(el): find_element(By.CLASS_NAME, el); 
                  
                  find_element_by_name(el): find_element(By.NAME, el)
                  

                  3-执行第一个方法时为什么显示DeprecationWarning

                  推荐答案

                  正如@guihva也提到的,这两行没有区别:

                  driver.find_element_by_name('q')
                  

                  driver.find_element(By.NAME, 'q')
                  

                  如同当前版本的selenium4Python客户端find_element_by_name(name)在幕后仍然调用:

                  self.find_element(by=By.NAME, value=name)
                  

                  但与DeprecationWarning一起。

                  find_element_by_name()当前实现如下:

                  def find_element_by_name(self, name) -> WebElement:
                      """
                      Finds an element by name.
                  
                      :Args:
                       - name: The name of the element to find.
                  
                      :Returns:
                       - WebElement - the element if it was found
                  
                      :Raises:
                       - NoSuchElementException - if the element wasn't found
                  
                      :Usage:
                          ::
                  
                              element = driver.find_element_by_name('foo')
                      """
                      warnings.warn(
                          "find_element_by_* commands are deprecated. Please use find_element() instead",
                          DeprecationWarning,
                          stacklevel=2,
                      )
                      return self.find_element(by=By.NAME, value=name)
                  

                  为什么要进行此更改

                  As@AutomatedTestermentions:

                  决定简化跨语言的API,这就做到了这一点。

                  这篇关于&quot;find_element_by_name(&#39;name&#39;)&quot;和&QOOT;FIND_ELEMENT(BY NAME,&#39;NAME&#39;)&QUOT;之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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()?)

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

                      <tbody id='Lb5xX'></tbody>

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

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