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

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

        自动单击网页中的按钮

        时间:2023-07-04
        • <small id='Nn87W'></small><noframes id='Nn87W'>

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

                  <tbody id='Nn87W'></tbody>
                • <bdo id='Nn87W'></bdo><ul id='Nn87W'></ul>
                  本文介绍了自动单击网页中的按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我需要自动点击网页中的任何添加"按钮,如下地址:

                  "https://groceries.asda.com/search/yoghurt"p>

                  但是,页面中的添加"按钮都没有名称或 ID.所以我不能使用 Selenium 包中的 driver.find_element_by_id() 命令.

                  谁能帮帮我?

                  解决方案

                  要单击特定产品的任何特定 Add 按钮,您可以编写如下方法:

                  def click_me(string):driver.find_element_by_xpath("//h3/a[@class='co-product__anchor' and contains(@title, '%s')]//following::button[1]" % (string)).click()

                  现在您可以点击任何一个 Add 按钮来传递它们的标题,如下所示:

                  click_me("Munch") # Munch Bunch Double Up Strawberry &香草酸奶# 或者click_me("ASDA") # ASDA 希腊式脱脂酸奶# 或者click_me("Petits") # Petits Filous Apricot, Strawberry &覆盆子酸奶

                  I need to auto click on any of the "Add" buttons in a web page like as the following address:

                  "https://groceries.asda.com/search/yoghurt"

                  But, none of the "Add" buttons in the page has name or id. So I can not use driver.find_element_by_id() command from Selenium package.

                  Can any one help me?

                  解决方案

                  To click on any particular Add button for a particular product you can write a method as follows:

                  def click_me(string):
                      driver.find_element_by_xpath("//h3/a[@class='co-product__anchor' and contains(@title, '%s')]//following::button[1]" % (string)).click()
                  

                  Now you can click on any of the Add button passing their title as follows:

                  click_me("Munch") # Munch Bunch Double Up Strawberry & Vanilla Yogurts
                  # or
                  click_me("ASDA") # ASDA Greek Style Fat Free Yogurt
                  # or
                  click_me("Petits") # Petits Filous Apricot, Strawberry & Raspberry Yogurt
                  

                  这篇关于自动单击网页中的按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:TypeError:“WebElement"对象不可下标 下一篇:Python 中 Selenium Webdriver 测试失败时的自动截图

                  相关文章

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

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

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

                      <tfoot id='htFM1'></tfoot>