selenium源码通读·12 |webdriver/remote分析

时间:2023-01-31 12:10:17

(·12 |webdriver/remote分析)

1 源码路径

selenium/webdriver/remote

selenium源码通读·12 |webdriver/remote分析

2 功能说明

方法 描述 说明
command.py Defines constants for the standard WebDriver commands 定义标准WebDriver命令的常量
errorhandler.py Error codes defined in the WebDriver wire protocol WebDriver wire协议中定义的错误代码
file_detector.py Used for identifying whether a sequence of chars represents the path to a file 用于标识字符序列是否表示文件的路径
getAttribute.js / 获取属性
isDisplayed.js / 判断元素是否显示
mobile.py / 定义移动端的功能
remote_connection.py A connection with the Remote WebDriver server 与远程WebDriver服务器的连接
switch_to.py / 切换能力
utils.py / 辅助能力
webdriver.py The WebDriver implementation 定义webdriver核心API
WebElement.py Represents a DOM element 定义对webdriver element操作的能力

3 部分功能详解

3.1 command.py

  • 定义标准WebDriver命令的常量;

  • 如下: selenium源码通读·12 |webdriver/remote分析

  • 比如我们常用的(部分):

常量
CLOSE close
QUIT quit
GET get
REFRESH refresh
GET_COOKIE getCookie
FIND_ELEMENT findElement
FIND_ELEMENTS findElements
GET_TITLE getTitle
SCREENSHOT screenshot
SET_TIMEOUTS setTimeouts
MAXIMIZE_WINDOW windowMaximize
MINIMIZE_WINDOW minimizeWindow
  • Alerts相关常量 selenium源码通读·12 |webdriver/remote分析

  • Advanced user interactions常量 selenium源码通读·12 |webdriver/remote分析

  • Screen Orientation常量 selenium源码通读·12 |webdriver/remote分析

  • Touch Actions常量 selenium源码通读·12 |webdriver/remote分析

  • HTML 5常量 selenium源码通读·12 |webdriver/remote分析selenium源码通读·12 |webdriver/remote分析

  • Mobile常量 selenium源码通读·12 |webdriver/remote分析

3.2 errorhandler.py

  • WebDriver wire协议中定义的错误代码
  • 如下: selenium源码通读·12 |webdriver/remote分析
  • 代码说明:
代码 标识 说明
0 SUCCESS 成功
7 NO_SUCH_ELEMENT no such element
8 NO_SUCH_FRAME no such frame
9 UNKNOWN_COMMAND unknown command
10 STALE_ELEMENT_REFERENCE stale element reference
11 ELEMENT_NOT_VISIBLE element not visible
12 INVALID_ELEMENT_STATE invalid element state
13 UNKNOWN_ERROR unknown error
15 ELEMENT_IS_NOT_SELECTABLE element not selectable
17 JAVASCRIPT_ERROR javascript error
19 XPATH_LOOKUP_ERROR invalid selector
21 TIMEOUT timeout
23 NO_SUCH_WINDOW no such window
24 INVALID_COOKIE_DOMAIN invalid cookie domain
25 UNABLE_TO_SET_COOKIE unable to set cookie
26 UNEXPECTED_ALERT_OPEN unexpected alert open
27 NO_ALERT_OPEN no such alert
28 SCRIPT_TIMEOUT script timeout
29 INVALID_ELEMENT_COORDINATES invalid element coordinates
30 IME_NOT_AVAILABLE ime not available
31 IME_ENGINE_ACTIVATION_FAILED ime engine activation failed
32 INVALID_SELECTOR invalid selector
33 SESSION_NOT_CREATED session not created
34 MOVE_TARGET_OUT_OF_BOUNDS move target out of bounds
51 INVALID_XPATH_SELECTOR invalid selector
52 INVALID_XPATH_SELECTOR_RETURN_TYPER invalid selector
60 ELEMENT_NOT_INTERACTABLE element not interactable
/ INSECURE_CERTIFICATE insecure certificate
61 INVALID_ARGUMENT invalid argument
/ INVALID_COORDINATES invalid coordinates
/ INVALID_SESSION_ID invalid session id
62 NO_SUCH_COOKIE no such cookie
63 UNABLE_TO_CAPTURE_SCREEN unable to capture screen
64 ELEMENT_CLICK_INTERCEPTED element click intercepted
/ UNKNOWN_METHOD unknown method exception
405 METHOD_NOT_ALLOWED unsupported operation