有誰知道如何在python中安裝硒?Python + Selenium Webdriver
是的,我用窗戶。我的Python 2.7
所以我嘗試使用此鏈接:https://pypi.python.org/pypi/selenium
但問題是:在我運行「PIP安裝-U命令硒」?後
有誰知道如何在python中安裝硒?Python + Selenium Webdriver
是的,我用窗戶。我的Python 2.7
所以我嘗試使用此鏈接:https://pypi.python.org/pypi/selenium
但問題是:在我運行「PIP安裝-U命令硒」?後
pip install -U selenium
java -jar selenium-server-standalone-2.31.0.jar
簡單的例子:
from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.keys import Keys
import time
browser = webdriver.Firefox() # Get local session of firefox
browser.get("http://www.yahoo.com") # Load page
assert "Yahoo!" in browser.title
elem = browser.find_element_by_name("p") # Find the query box
elem.send_keys("seleniumhq" + Keys.RETURN)
time.sleep(0.2) # Let the page load, will be added to the API
try:
browser.find_element_by_xpath("//a[contains(@href,'http://seleniumhq.org')]")
except NoSuchElementException:
assert 0, "can't find seleniumhq"
browser.close()
您也可以手動下載Selenium(https://pypi.python.org/pypi/selenium),然後在您的項目中添加selenium文件夾('selenium-2.31.0/py/selenium /')。這種方式更容易分發,並且不會依賴於先在其他人的機器上使用'pip':) – 2013-03-06 17:03:11
直到那時我只安裝了python(http://www.python.org/download/) SO :Windows – RFtests 2013-03-06 17:07:03
只是將該文件夾複製到c:\ python27 \ Lib文件 – 2013-03-06 16:58:59
是的,有人知道。你有更具體的問題嗎?什麼OS?什麼版本的Python?哪個Selenium Webdriver?你遇到什麼錯誤? – 2013-03-06 16:59:00
你試過了嗎? – Arran 2013-03-06 17:21:15