您的位置:軟件測(cè)試 > 開(kāi)源軟件測(cè)試 > 開(kāi)源功能測(cè)試工具 > Selenium
Selenium+Python多瀏覽器測(cè)試
作者:網(wǎng)絡(luò)轉(zhuǎn)載 發(fā)布時(shí)間:[ 2015/5/11 10:44:30 ] 推薦標(biāo)簽:功能測(cè)試

  多瀏覽器代碼優(yōu)化
  除了 Firefox、chrome、IE 以外,可看到 opera 、Safari 等也可支持,這邊不一一介紹了,如果想要了解,可google。
  可寫(xiě)一個(gè) .py 來(lái)啟動(dòng)瀏覽器,測(cè)試代碼僅需 import 即可。
1 # !/usr/bin/env python
2 # -*- coding:utf-8 -*-
3
4 from os import environ
5 from selenium import webdriver
6
7 ff = webdriver.Firefox()                    # Firefox
8 ff.maximize_window()                        # full-window
9
10 chromedriver = "C:UserssisiAppDataLocalGoogleChromeApplicationchromedriver.exe"
11 environ["webdriver.chrome.driver"] = chromedriver
12 chrome = webdriver.Chrome(chromedriver)     # Chrome
13 chrome.maximize_window()                    # full-window
14
15 iedriver = "C:Program FilesInternet ExplorerIEDriverServer.exe"
16 environ["webdriver.ie.driver"] = iedriver
17 ie = webdriver.Ie(iedriver)                 # IE
18 ie.maximize_window()                        # full-window
19
20
21 ''' Your testing code should be here '''
22
23 TEST_URL = "http://www.baidu.com"
24
25 ff.get(TEST_URL)
26 chrome.get(TEST_URL)
27 ie.get(TEST_URL)

上一頁(yè)12下一頁(yè)
軟件測(cè)試工具 | 聯(lián)系我們 | 投訴建議 | 誠(chéng)聘英才 | 申請(qǐng)使用列表 | 網(wǎng)站地圖
滬ICP備07036474 2003-2017 版權(quán)所有 上海澤眾軟件科技有限公司 Shanghai ZeZhong Software Co.,Ltd