<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>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                [TOC] ## 4.11 警告框處理 在 WebDriver 中處理 JavaScript 生成的 alert、confirm 和 prompt 十分簡單,具體做法是,首先使用 switch_to.alert()方法定位,然后使用 text、accept、dismiss、send_keys 等進行操作。 * text:返回 alert、confirm、prompt 中的文字信息。 * accept():接受現有警告框。 * dismiss():解散現有警告框。 * send_keys():在警告框中輸入文本(如果可以輸入的話)。 可以使用 switch_to.alert()方法為百度搜索設置彈窗,如圖 4-5 所示。 ![](https://img.kancloud.cn/68/fa/68fa8041cef23841a0e3eea378695be2_1071x721.png) :-: 圖 4-5 為百度搜索設置彈窗 ``` from selenium import webdriver from time import sleep driver = webdriver.Chrome() driver.get("https://www.baidu.com") # 打開搜索設置 link = driver.find_element_by_id("s-usersetting-top").click() driver.find_element_by_link_text("搜索設置").click() sleep(2) #保存設置 driver.find_element_by_link_text("保存設置").click() # 獲取警告框 alert = driver.switch_to.alert # 獲取警告框提示信息 alert_text = alert.text print(alert_text) # 接收警告框 alert.accept() driver.quit() ``` 這里以百度搜索設置為例,打開百度搜索設置,設置完成后單擊“保存設置”按鈕,彈出保存確認警告框。通過 switch_to.alert 方法獲取當前頁面上的警告框,text 用于獲取警告框提示信息,accept()用于接受警告框。
                  <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>

                              哎呀哎呀视频在线观看