<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                [TOC] ## 4.12 下拉框處理 下拉框是 Web 頁面常見功能之一,WebDriver 提供了 Select 類來處理下拉框。 select在HTML中表示元素名,可創建單選或多選菜單。 ``` <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> <select name="cc"> <option value="boke">請關注cc博客</option> <option value="study">今天學習了么?</option> <option value="daily">今天看云寫筆記了么?</option> <option value="like">點贊了么?</option> <option value="attention">關注了么?</option> </select> </body> </html> ``` <br /> ### **select操作方法** selenium中想要操作下拉框需要導入新的模塊?fromselenium.webdriver.support.selectimportSelect? ### **Select有以下操作方法:** | 方法 | 說明 | | --- | --- | | select_by_index() | 通過索引定位 | | select_by_value() | 通過value值定位 | | select_by_visible_text() | 通過文本值定位 | | deselect_all() | 取消所有選項 | | deselect_by_index() | 取消對應index選項 | | deselect_by_value() | 取消對應value選項 | | deselect_by_visible_text() | 取消對應文本選項 | | first_selected_option() | 返回第一個選項 | | all_selected_options() | 返回所有的選項 | | options() | 返回所以的選擇項 | | all_selected_options() | 返回所以已選中的選擇項 | | first_selected_option() | 返回選中的第一個選擇項 | <br /> 1、想要操作select,首先定位到select上,然后進行實例化 2、通過Select進行通過下標,value,text進行定位下拉框 3、加入判斷預期值是否切換到下拉框中 ``` from selenium import webdriver from time import sleep from selenium.webdriver.support.select import Select from selenium.webdriver.support.wait import WebDriverWait from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.common.by import By driver = webdriver.Chrome() driver.get("G:\我的堅果云\python_project\py3_selenium3_practice\static\select.html") # 通過顯示等待的方法判斷元素是否出現 WebDriverWait(driver, 10).until(EC.visibility_of_element_located((By.NAME, "cc"))) select = driver.find_element_by_name("cc") # 根據下標進行選擇,從0開始 Select(select).select_by_index(1) sleep(2) # 根據value的值選擇 Select(select).select_by_value('daily') sleep(2) # 根據text選擇 Select(select).select_by_visible_text("關注了么?") sleep(2) # 判斷選擇是否預期 WebDriverWait(driver, 20).until(EC.element_located_to_be_selected(By.XPATH, '//*[contains(text(),"關注了")]')) ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看