此章为核心模块,内含对浏览器的各种操作!!!
目录结构如下:
class WebDriver(object):
将命令通过WebDriver wire protocol协议发送到服务器
session_id:
由此webdriver启动和控制浏览器的会话id
capabilities:
远端服务器以字典形式返回有效功能,并非所有服务器实现都将支持每种WebDriver功能。 因此,在描述用户请求会话支持的功能时,客户端和服务器应使用具有以下属性的JSON对象。 如果会话不能支持所需功能中要求的功能,则不会引发任何错误; 返回一个只读功能对象,该对象指示会话实际支持的功能。
command_executor:
执行命令,引用的是:remote_connection.RemoteConnection类
error_handler:
用于处理错误。引用的是:errorhandler.ErrorHandler类
def __init__(self, command_executor='http://127.0.0.1:4444/wd/hub',desired_capabilities=None, browser_profile=None,proxy=None,keep_alive=False, file_detector=None, options=None):
初始化一个新的驱动程序,他将使用WebDriver wire protocol协议发送命令
command_executor:
代表远端服务器地址url的字符串或自定义,remote_connection.RemoteConnection对象默认:http://127.0.0.1:4444/wd/hub
desired_capabilities:
必填参数,启动浏览器会话时要求的功能字典
browser_profile:
可选项,selenium.webdriver.firefox.firefox_profile.FirefoxProfile对象,仅在请求Firefox时使用
if browser_profile is not None:
warnings.warn("Please use FirefoxOptions to set browser profile",DeprecationWarning, stacklevel=2)
proxy:
可选项,selenium.webdriver.common.proxy.Proxy对象,如果可能,将使用给定的代理设置启动浏览器会话
if proxy is not None:
warnings.warn("Please use FirefoxOptions to set proxy",DeprecationWarning, stacklevel=2)
keep_alive:
默认为False,是否将r