<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] 前言? ? 不是所有的彈出框都叫alert,在使用alert方法前,先要識別出到底是不是alert。先認清楚alert長什么樣子,下次碰到了,就可以用對應方法解決。 alert\\confirm\\prompt彈出框操作主要方法有: * text:獲取文本值 * accept() :點擊"確認" * dismiss() :點擊"取消"或者叉掉對話框 * send_keys() :輸入文本值 --僅限于prompt,在alert和confirm上沒有輸入框 <br /> 一、認識alert\\confirm\\prompt 1. 如下圖,從上到下依次為alert\confirm\prompt,先認清楚長什么樣子,以后遇到了就知道如何操作了。 ?![](http://images2015.cnblogs.com/blog/1070438/201704/1070438-20170429134522865-675937848.png) 2. html源碼如下: ``` <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Alert</title> </head> <body> <input id="alert" value="alert" type="button" onclick="alert('您關注了yoyoketang嗎?');"/> <input id="confirm" value="confirm" type="button" onclick="alert('確定關注微信公眾號:yoyoketang?');"/> <input id="prompt" value="prompt" type="button" onclick = "var name = prompt('請輸入微信公眾號:','yoyoketang'); document.write(name) "/> </body> </html> ``` <br /> 二、alert操作 1. 先用switch\_to\_alert()方法切換到alert彈出框上 2. 可以用text方法獲取彈出的文本 信息 3. accept()點擊確認按鈕 4. dismiss()相當于點取消按鈕或點右上角x,取消彈出框(url的路徑,直接復制瀏覽器打開的路徑) ``` # coding:utf-8 from selenium import webdriver import time url = "G:/py/selenium/test/alert.html" driver = webdriver.Chrome() driver.get(url) time.sleep(4) driver.find_element_by_id("alert").click() time.sleep(3) t = driver.switch_to_alert() # 打印警告框文本內容 print(t.text) # 點擊警告框確認按鈕 t.accept() # t.dismiss()相當于點"x"按鈕,取消 ``` <br /> 三、confirm操作 1. 先用switch\_to\_alert()方法切換到alert彈出框上 2. 可以用text方法獲取彈出的文本 信息 3. accept()點擊確認按鈕 4. dismiss()相當于點取消按鈕或點右上角x,取消彈出框(url的路徑,直接復制瀏覽器打開的路徑) ``` # coding:utf-8 from selenium import webdriver import time url = "G:/py/selenium/test/alert.html" driver = webdriver.Chrome() driver.get(url) time.sleep(4) driver.find_element_by_id("confirm").click() time.sleep(3) t = driver.switch_to_alert() # 打印警告框文本內容 print(t.text) # 點擊警告框確認按鈕 t.accept() # t.dismiss()相當于點"x"按鈕,取消 ``` <br /> 四、prompt操作 1. 先用switch\_to\_alert()方法切換到alert彈出框上 2. 可以用text方法獲取彈出的文本 信息 3. accept()點擊確認按鈕 4. dismiss()相當于點取消按鈕或點右上角x,取消彈出框 5. send_keys()這里多個輸入框,可以用send_keys()方法輸入文本內容 (url的路徑,直接復制瀏覽器打開的路徑) ``` # coding:utf-8 from selenium import webdriver import time url = "G:/py/selenium/test/alert.html" driver = webdriver.Chrome() driver.get(url) time.sleep(4) driver.find_element_by_id("prompt").click() time.sleep(3) t = driver.switch_to_alert() # 打印警告框文本內容 print(t.text) t.send_keys("hello selenuim3") ```
                  <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>

                              哎呀哎呀视频在线观看