Selenium2Library源码解读(1)- 概述

概述

官方文档这样描述Selenium2Library:

Selenium2Library is a web testing library for Robot Framework.

It uses the Selenium 2 (WebDriver) libraries internally to control a web browser.
See http://seleniumhq.org/docs/03_webdriver.html for more information on Selenium 2
and WebDriver.

Selenium2Library runs tests in a real browser instance. It should work in
most modern browsers and can be used with both Python and Jython interpreters.

个人翻译如下:

Selenium2Library是用于RobotFramework框架的测试库。

它应用Selenium 2 (WebDriver)库来控制浏览器,可访问http://seleniumhq.org/docs/03_webdriver.html">http://seleniumhq.org/docs/03_webdriver.html来获取更多有关Selenium2和WebDriver的信息。

Selenium2Library在实际浏览器实例上运行测试,它能够支持多数现代浏览器,并可以使用Python和Jython解释器。

源码

源码所在路径为:

"\Python27\Lib\site-packages\robotframework_selenium2library-1.7.1-py2.7.egg\Selenium2Library"

个人安装版本为1.7.1,见下图:

RobotFramework能够识别的关键字所在包为"keywords",查看包的定义,其实际是从keywords包内的11个模块中导入关键字,后续也主要从这11个模块着手,来进行解读。keywords包的定义:

from _logging import _LoggingKeywords
from _runonfailure import _RunOnFailureKeywords
from _browsermanagement import _BrowserManagementKeywords
from _element import _ElementKeywords
from _tableelement import _TableElementKeywords
from _formelement import _FormElementKeywords
from _selectelement import _SelectElementKeywords
from _javascript import _JavaScriptKeywords
from _cookie import _CookieKeywords
from _screenshot import _ScreenshotKeywords
from _waiting import _WaitingKeywords

__all__ = [
    "_LoggingKeywords",
    "_RunOnFailureKeywords",
    "_BrowserManagementKeywords",
    "_ElementKeywords",
    "_TableElementKeywords",
    "_FormElementKeywords",
    "_SelectElementKeywords",
    "_JavaScriptKeywords",
    "_CookieKeywords",
    "_ScreenshotKeywords",
    "_WaitingKeywords"
]

 

Selenium2Library基于Selenium2 (WebDriver)技术,并应用于RbotFramework框架。接下来的内容就是个人结合平时工作经验,在阅读Selenium2Library源代码过程中的一些记录和思考。从今天起,争取每周都有进展。

 

你可能感兴趣的:(Selenium2Library源码解读(1)- 概述)