亚洲好骚综合-亚洲黄色录像-亚洲黄色网址-亚洲黄色网址大全-99久久99久久-99久久99久久精品国产

您的位置:軟件測試 > 開源軟件測試 > 開源功能測試工具 > Selenium
Python selenium chrome環境配置
作者:網絡轉載 發布時間:[ 2015/10/30 16:22:31 ] 推薦標簽:功能測試工具

  一、參考文章:
  1. 記錄一下python easy_install和pip安裝地址和方法
  http://heipark.iteye.com/blog/1916758
  2. selenium + python自動化測試環境搭建
  http://www.cnblogs.com/fnng/archive/2013/05/29/3106515.html
  3. Python-selenium-Firefox-chrome-IE問題解決方法
  http://blog.csdn.net/lcm_up/article/details/38302143
  4. ChromeDriver - WebDriver for Chrome Getting started
  https://sites.google.com/a/chromium.org/chromedriver/getting-started
  二、Windows PowerShell
  1. 【win】鍵
  2. 鍵入:Windows PowerShell + 【Enter】鍵
  三、Python setuptools 18.4 安裝:
  1. download:https://pypi.python.org/pypi/setuptools
  2. 跳到ez_setup.py所在的目錄
  3. python .ez_setup.py
  四、Python pip 7.1.2 安裝:
  1. download:https://pypi.python.org/pypi/pip#downloads
  2. 跳到解壓出來的目錄下的setup.py所在的目錄
  3. python setup.py install
  五、Python selenium 2.48.0 安裝:
  1. download:https://pypi.python.org/pypi/selenium
  2. 跳到解壓出來的目錄下的setup.py所在的目錄
  3. python setup.py install
  六、chrome driver
  1. download:http://chromedriver.storage.googleapis.com/index.html?path=2.20/
  2. 解壓拷貝文件到:D:python2_7chromedriver_win32chromedriver.exe
  3. 創建一個chrome瀏覽器實例:
  driver = webdriver.Chrome('D:python2_7chromedriver_win32chromedriver') ##可以替換為IE(), FireFox()
  七、Test Demo(請確保能訪問Google):
#!/usr/bin/python
# -*- coding: utf-8 -*-
import os
from selenium import webdriver
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.support.ui import WebDriverWait # available since 2.4.0
import time
# Create a new instance of the browser driver
driver = webdriver.Chrome('D:python2_7chromedriver_win32chromedriver')  ##可以替換為IE(), FireFox()
# go to the google home page
driver.get("http://www.google.com")
# find the element that's name attribute is q (the google search box)
inputElement = driver.find_element_by_name("q")
# type in the search
inputElement.send_keys("Cheese!")
# submit the form. (although google automatically searches now without submitting)
inputElement.submit()
# the page is ajaxy so the title is originally this:
print driver.title
try:
# we have to wait for the page to refresh, the last thing that seems to be updated is the title
WebDriverWait(driver, 10).until(lambda driver : driver.title.lower().startswith("cheese!"))
# You should see "cheese! - Google Search"
print driver.title
finally:
#driver.quit()      # 當前使用 driver.quit()會導致如下錯誤
#   Traceback (most recent call last):
#   File "E:/python/Spider/Spider.py", line 39, in <module>
#       driver.quit()
#   File "D:python2_7installlibsite-packagesselenium-2.48.0-py2.7.eggseleniumwebdriverchromewebdriver.py", line 88, in quit
#       self.service.stop()
#   File "D:python2_7installlibsite-packagesselenium-2.48.0-py2.7.eggseleniumwebdriverchromeservice.py", line 111, in stop
#       url_request.urlopen("http://127.0.0.1:%d/shutdown" % self.port)
#   File "D:python2_7installliburllib2.py", line 126, in urlopen
#       return _opener.open(url, data, timeout)
#   File "D:python2_7installliburllib2.py", line 397, in open
#       response = meth(req, response)
#   File "D:python2_7installliburllib2.py", line 510, in http_response
#       'http', request, response, code, msg, hdrs)
#   File "D:python2_7installliburllib2.py", line 435, in error
#       return self._call_chain(*args)
#   File "D:python2_7installliburllib2.py", line 369, in _call_chain
#       result = func(*args)
#   File "D:python2_7installliburllib2.py", line 518, in http_error_default
#       raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
#   urllib2.HTTPError: HTTP Error 404: Not Found
driver.close()

軟件測試工具 | 聯系我們 | 投訴建議 | 誠聘英才 | 申請使用列表 | 網站地圖
滬ICP備07036474 2003-2017 版權所有 上海澤眾軟件科技有限公司 Shanghai ZeZhong Software Co.,Ltd
主站蜘蛛池模板: 狠狠插网站 | 成人影院在线观看免费 | 欧美天堂在线观看 | 久久精品网 | 色播视频在线观看 | 激情五月婷婷综合网 | 中文三 级 黄 色 片 | 国产精品手机在线 | 男人的午夜影院 | 久久99精品久久久久久欧洲站 | 成人禁在线观看 | 一级一级 a爱片免费视频 | 特级深夜a级毛片免费观看 特级中国aaa毛片 | 亚洲欧洲中文 | 国产免费色视频 | 日韩美女一级毛片 | 久久厕所精品国产精品亚洲 | 99精品热女视频专线 | 天天做天天摸 | 日日狠日 | 最近免费2019中文字幕大全 | 日本人真淫视频一区二区三区 | 成人欧美在线 | 国产一区二区三区视频在线观看 | 欧美怡红院免费的视频 | 国产大片黄在线观看 | 宅男午夜影院 | 狠狠操免费视频 | 日韩一区二区三区在线 | 午夜剧场直接免费观看 | 亚洲国产成人影院播放 | 欧美一页 | 亚洲人成网站在线播放观看 | 在线色网 | 国产又黄又爽又猛的免费视频播放 | 91久久精品国产一区二区 | 日韩伦理片在线播放 | 国内精品卡一卡二卡三 | 午夜视频在线看 | 最刺激黄a大片免费观看下截 | 一级一片免费播放 |