0


selenium python 入门教程

  1. Getting Started — Selenium Python Bindings 2 documentation

2.1. Simple Usage

If you have installed Selenium Python bindings, you can start using it from Python like this.

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By

driver = webdriver.Firefox()
driver.get("http://www.python.org")
assert "Python" in driver.title
elem = driver.find_element(By.NAME, "q")
elem.clear()
elem.send_keys("pycon")
elem.send_keys(Keys.RETURN)
assert "No results found." not in driver.page_source
driver.close()

The above script can be saved into a file (eg:- python_org_search.py), then it can be run like this:

python python_org_search.py

The python which you are running should have the selenium module installed.


本文转载自: https://blog.csdn.net/u010087338/article/details/126293158
版权归原作者 子燕若水 所有, 如有侵权,请联系我们删除。

“selenium python 入门教程”的评论:

还没有评论