0

有谁知道如何在 python 中安装 selenium?

是的,我使用窗户。我的蟒蛇是2.7

所以我尝试使用这个链接:https ://pypi.python.org/pypi/selenium

但问题是:我在哪里运行“pip install -U command selenium”?

4

1 回答 1

3
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()
于 2013-03-06T16:59:43.767 回答