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

                [TOC] ## **Selenium是一款基于Web頁面的UI自動化測試框架** 1、支持多瀏覽器操作:Chrome、IE、Firefox、Safaria等 2、支持夸平臺,Windows、Linux、Mac等 3、支持多語言,Python、Java、Ruby、C#等 ## **1、Selenium webdriver 原理:** Webdriver是按照Client/Server模式設計的 Client:編程語言客戶端 Server:瀏覽器驅動程序。用來接收客戶端的請求并驅動瀏覽器執行操作然后返回結果 Selenium代碼與瀏覽器驅動程序之間是通過http協議進行數據交互的。這種方式,不在乎客戶端是什么樣的形式,只要數據的格式和協議是服務端能夠解析的就可以了。 ![](https://img.kancloud.cn/47/b7/47b7e5319695a0dfa13647b4c355d1d2_899x298.png) 通信步驟為: 1、webdriver啟動瀏覽器驅動程序,并設置偵聽端口號 2、webdriver客戶端與瀏覽器服務端建立連接 3、連接成功后,所有的操作(比如:查找元素、點擊等)都是客戶端通過 commandExecuter發送http請求到服務端;服務端根據收到的請求做相應的操作并返回 <br> <br> 以上簡單的介紹,那么下面我們一起來搭建環境,記得當初我自己自學selenium的時候,說來也是奇葩烏龍事件很多 一個selenium環境搭建了3天,還吧電腦搞得系統重裝,哈哈哈哈哈,正題進入 :-: 1:python3的環境要下載好,python3大家去自行下載(版本:3.6-3.8即可) :-: 2:chrome瀏覽器 :-: 3:selenium :-: 4: ChromeDriver版本 **注意: ChromeDriver的版本和chrome的版本要對應,如下是對應表,必須對應,以免后期出現環境問題(本人已mac為準)** **[第一步]():** chrome老版本下載地址:https://www.slimjet.com/chrome/google-chrome-old-version.php <br> **[第二步:]()** chromedriver:地址如下 鏡像1:[http://npm.taobao.org/mirrors/chromedriver/](http://npm.taobao.org/mirrors/chromedriver/) 鏡像2:[http://chromedriver.storage.googleapis.com/index.html](http://chromedriver.storage.googleapis.com/index.html) ![](../images/screenshot_1596336077237.png) chrome和chromedriver的版本按照搭建所用的系統以及系統(64位)(32位)下載即可 <br> **[第三步:]()** 下載------>:selenium 使用windows的伙伴如果python3的環境已經下載好了,那么可以使用pip來下載 ``` pip install selenium # 默認下載最高版本 pip install selenium==2.4.1 # 指定版本 ``` 下載后驗證是否下載成功打開cmd,輸入python回車 ~~~bash from selenium import webdriver ~~~ 沒有報錯就成功了 **有的時候pip下載selenium特別慢怎么辦或者安裝總是提示連接超時失敗。可以通過國內源進行安裝,別急讓子彈飛一會兒,解決方法:給它加加速** 阿里云?[https://mirrors.aliyun.com/pypi/simple/](http://mirrors.aliyun.com/pypi/simple/) 中國科技大學?[https://pypi.mirrors.ustc.edu.cn/simple/](https://pypi.mirrors.ustc.edu.cn/simple/%20) 豆瓣(douban)?[http://pypi.douban.com/simple/](http://pypi.douban.com/simple/) 清華大學?[https://pypi.tuna.tsinghua.edu.cn/simple/](https://pypi.tuna.tsinghua.edu.cn/simple/) 中國科學技術大學?[http://pypi.mirrors.ustc.edu.cn/simple/](http://pypi.mirrors.ustc.edu.cn/simple/) ``` pip install -i https://mirrors.aliyun.com/pypi/simple/ selenium ``` <br> <br> 現在我們selenium已經下載好了,導入也成功說明沒問題,那么我們將chrome瀏覽器下載好后安裝,然后在吧ChromeDriver解壓:放入**python的bin目錄即可** 現在在進入cmd,輸入如下,如果沒有問題瀏覽器被正常打開說明我們環境以及成功了,就剩下寫代碼 ~~~bash Python 3.7.0 (default, Aug 22 2018, 15:22:33) Type 'copyright', 'credits' or 'license' for more information IPython 6.5.0 -- An enhanced Interactive Python. Type '?' for help. from selenium import webdriver browser = webdriver.Chrome() ~~~
                  <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>

                              哎呀哎呀视频在线观看