.. _api: WebDriver API ================ .. note:: 这不是官方文档,官方的API文档在 `这里 `_. 这一章涵盖了所有的Selenium WebDriver接口 推荐的引入风格 ------------------ 这一章里面API的定义已经展示了类的绝对位置,不过推荐使用下面引入风格 :: from selenium import webdriver 然后你就可以这样使用这个类: :: webdriver.Firefox webdriver.FirefoxProfile webdriver.Chrome webdriver.ChromeOptions webdriver.Ie webdriver.Opera webdriver.Phantomjs webdriver.Remote webdriver.DesiredCapabilities webdriver.ActionChains webdriver.TouchActions webdriver.Proxy 特殊的键盘类(``Keys``)可以这样引入: :: from selenium.webdriver.common.keys import Keys 引入 ``exception`` 类(把 `TheNameOfTheExceptionClass` 替换为你真正需要的类名) :: from selenium.common.exceptions import [TheNameOfTheExceptionClass] API的常规使用 ------------------- 一些属性(或者方法)是可以调用的,另外一些不可以调用,可以调用的属性是以圆括号结尾的。 下面是属性的一个例子 - current_url 当前载入页面的URL. 用法:: driver.current_url 下面是方法的一个例子 - close() 关闭当前窗口. 使用:: driver.close()