02、selenium與pycharm簡介與安裝
阿新 • • 發佈:2020-09-17
一、selenium特點
1 開源,免費,簡單(API簡單)、靈活(開發語言驅動)
2 多瀏覽器支援:FireFox、Chrome、IE、Opera(核心)
3 多平臺支援:linux 、windows、MAC
4 多語言支援:java、python、php、C#、JavaScript
5 支援分散式測試用例執行
二、selenium版本
1 http://www.seleniumhq.org/
2 1.0:IDE(錄製)、Grid(分散式)、RC(程式碼控制瀏覽器)
3 2.0:Selenium2.0 = Selenium1.0 + WebDriver(主要)
4 3.0:Selenium3.0 = Selenium2.0改進 – RC
5 備註:2.0火狐不需要驅動,3.0需要驅動且支援safari
三、Selenium安裝
1 ①.python安裝https://www.python.org/downloads/
2 ②.selenium安裝pip install -U selenium
3 ③.升級pippython -m pip install --upgrade pip
4 ④.安裝瀏覽器驅動
5 A.谷歌瀏覽器版本和驅動對應參考表:https://chromedriver.storage.googleapis.com/2.30/notes.txt
6 B.谷歌瀏覽器驅動下載的對應地址:http://chromedriver.storage.googleapis.com/index.html
7 C.火狐驅動下載https://github.com/mozilla/geckodriver/releases
8 D.IE驅動下載https://www.selenium.dev/downloads/選The Internet Explorer Driver Server
9 E.Safari驅動mac中已存在,下載外掛配置即可https://www.selenium.dev/downloads/
10 ⑤.配置瀏覽器驅動chromedriver.exe驅動放到C:\python27目錄下
11 ⑥.驗證驅動配置成功
12 from selenium import webdriver
13 import time
14 driver=webdriver.Chrome() #.Firefox()
15 driver.get("https://www.baidu.com")
16 time.sleep(5)
17 driver.quit()
18 ⑦.如果selenium調不出,則需要配置編輯器
19 File-Settings-Project-Interpreter右側加號
四、pycharm安裝
1 ①.pycharm:https://www.jetbrains.com/pycharm/download/#section=windows
2 ②.基礎設定
3 A.主題設定http://www.themesmap.com/
4 點選 file-settings-edito-color scheme-選擇已經匯入的主題Ladies.jar,重啟pycharm,ok
5 B.字型設定
6 編輯器內字型file-ettings-editor-font內選擇。
7 軟體字型在 file-settings-appearance裡修改
8 C.更改背景色
9 File-Settings-Editor-General-Text-Default text
五、pycharm基礎操作
1 alt + 1 隱藏或者顯示左側專案工程
2 ctrl / 選中後註釋和取消註釋
3 tab 預設4個空格
4 shift tab 回退程式碼的原來位置
5 ctrl + d 複製選中區域
6 ctrl + y 刪除選中區域
7 Ctrl + 滑鼠 函式介紹
8 ctrl+shift+F10 執行程式/或者滑鼠右鍵
9 選中函式alt+回車 反匯入包
10 #coding=utf-8或#-*- coding=utf-8 -*- 宣告編輯器允許輸入中文