This commit is contained in:
g1879 2020-11-19 23:55:50 +08:00
parent 79b61704c7
commit b087d103aa
2 changed files with 194 additions and 74 deletions

View File

@ -1202,7 +1202,7 @@ Returns: None
### ele() ### ele()
Return the eligible elements on the page, the first one is returned by default. Return the eligible elements on the page, the first one is returned by default.
If the query parameter is a string, the options of'@attribute name:','tag:','text:','css:', and'xpath:' are available. When there is no control mode, the text mode is used to search by default. If the query parameter is a string, the options of '@attribute name:', 'tag:', 'text:', 'css:', 'xpath:', '.', '#' are available. When there is no control mode, the text mode is used to search by default.
If it is loc, query directly according to the content. If it is loc, query directly according to the content.
Parameter Description: Parameter Description:
@ -1221,10 +1221,14 @@ Example:
- Find with query string: - Find with query string:
Attributes, tag name and attributes, text, xpath, css selector. Attributes, tag name and attributes, text, xpath, css selector, id, class.
Among them, @ means attribute, = means exact match,: means fuzzy match, the string is searched by default when there is no control string. @ Means attribute,. Means class, # means id, = means exact match,: means fuzzy match, the string is searched by default when there is no control string.
- page.ele('.ele_class') - returns the first element whose name is equal to ele_name
- page.ele('.:ele_class') - returns the element with ele_class in the first class
- page.ele('#ele_id') - Return the first element with id ele_id
- page.ele('#:ele_id') - Returns the element with ele_id in the first id
- page.ele('@class:ele_class') - returns the element with ele_class in the first class - page.ele('@class:ele_class') - returns the element with ele_class in the first class
- page.ele('@name=ele_name') - returns the first element whose name is equal to ele_name - page.ele('@name=ele_name') - returns the first element whose name is equal to ele_name
- page.ele('@placeholder') - returns the first element with placeholder attribute - page.ele('@placeholder') - returns the first element with placeholder attribute
@ -1797,7 +1801,7 @@ Returns: str
### ele() ### ele()
Returns the sub- elements, attributes or node texts of the current element that meet the conditions. Returns the sub- elements, attributes or node texts of the current element that meet the conditions.
If the query parameter is a string, the options of'@attribute name:','tag:','text:','css:', and'xpath:' are available. When there is no control mode, the text mode is used to search by default. If the query parameter is a string, the options of '@attribute name:', 'tag:', 'text:', 'css:', 'xpath:', '.', '#' are available. When there is no control mode, the text mode is used to search by default.
If it is loc, query directly according to the content. If it is loc, query directly according to the content.
Parameter Description: Parameter Description:
@ -1814,23 +1818,43 @@ Example:
- Find with query string: - Find with query string:
Attributes, tag name and attributes, text, xpath, css selector. Attributes, tag name and attributes, text, xpath, css selector, id, class.
Among them, @ means attribute, = means exact match,: means fuzzy match, the string is searched by default when there is no control string. @ Means attribute,. Means class, # means id, = means exact match,: means fuzzy match, the string is searched by default when there is no control string.
- ele.ele('@class:ele_class') - returns the first class element that contains ele_class - ele.ele('.ele_class')-returns the first child element whose class is ele_class
- ele.ele('@name=ele_name') - returns the first element whose name is equal to ele_name
- ele.ele('@placeholder') - returns the first element with placeholder attribute - ele.ele('.:ele_class')-returns the child elements of the first class that contain ele_class
- ele.ele('tag:p') - returns the first p element
- ele.ele('tag:div@class:ele_class') - Returns the div element with ele_class in the first class - ele.ele('#ele_id')-returns the first child element with id ele_id
- ele.ele('tag:div@class=ele_class') - returns the first div element whose class is equal to ele_class
- ele.ele('tag:div@text():some_text') - returns the first div element whose text contains some_text - ele.ele('#:ele_id')-Returns the child element with ele_id in the first id
- ele.ele('tag:div@text()=some_text') - Returns the first div element whose text is equal to some_text
- ele.ele('text:some_text') - returns the first element whose text contains some_text - ele.ele('@class:ele_class')-returns the first class that contains e le_class
- ele.ele('some_text') - returns the first text element containing some_text (equivalent to the previous line)
- ele.ele('text=some_text') - returns the first element whose text is equal to some_text - ele.ele('@name=ele_name')-returns the first child element whose name is equal to ele_name
- ele.ele('xpath://div[@class="ele_class"]') - Return the first element that matches xpath
- ele.ele('css:div.ele_class') - returns the first element that matches the css selector - ele.ele('@placeholder')-returns the first child element with placeholder attribute
- ele.ele('tag:p')-returns the first p child element
- ele.ele('tag:div@class:ele_class')-returns the first div sub-element that contains ele_class
- ele.ele('tag:div@class=ele_class')-returns the first div child element whose class is equal to ele_class
- ele.ele('tag:div@text():some_text')-returns the first div child element whose text contains some_text
- ele.ele('tag:div@text()=some_text')-returns the first div child element whose text is equal to some_tex t
- ele.ele('text:some_text')-returns the first child element whose text contains some_text
- ele.ele('some_text')-returns the first text element with some_text (equivalent to the previous line)
- ele.ele('text=some_text')-returns the first child element whose text is equal to some_text
- ele.ele('xpath://div[@class="ele_class"]')-Return the first child element that matches xpath
- ele.ele('css:div.ele_class')-returns the first child element that matches the css selector
Returns: [DriverElement, str] Returns: [DriverElement, str]
@ -2185,7 +2209,7 @@ Returns: str
### ele() ### ele()
Get elements based on query parameters. Get elements based on query parameters.
If the query parameter is a string, you can choose the methods of'@attribute name:','tag:','text:','css:', and'xpath:'. When there is no control mode, the text mode is used to search by default. If the query parameter is a string, you can choose the methods of '@attribute name:', 'tag:', 'text:', 'css:', 'xpath:', '.', '#'. When there is no control mode, the text mode is used to search by default.
If it is loc, query directly according to the content. If it is loc, query directly according to the content.
Parameter Description: Parameter Description:
@ -2203,23 +2227,43 @@ Example:
- Find with query string: - Find with query string:
Attributes, tag name and attributes, text, xpath, css selector. Attributes, tag name and attributes, text, xpath, css selector, id, class.
Among them, @ means attribute, = means exact match,: means fuzzy match, the string is searched by default when there is no control string. @ Means attribute,. Means class, # means id, = means exact match,: means fuzzy match, the string is searched by default when there is no control string.
- ele.ele('@class:ele_class') - return the first class element containing ele_class - ele.ele('.ele_class')-returns the first child element whose class is ele_class
- ele.ele('@name=ele_name') - returns the first element whose name is equal to ele_name
- ele.ele('@placeholder') - returns the first element with placeholder attribute - ele.ele('.:ele_class')-returns the child elements of the first class that contain ele_class
- ele.ele('tag:p') - return the first p element
- ele.ele('tag:div@class:ele_class') - Returns the div element with ele_class in the first class - ele.ele('#ele_id')-returns the first child element with id ele_id
- ele.ele('tag:div@class=ele_class') - returns the first div element whose class is equal to ele_class
- ele.ele('tag:div@text():some_text') - returns the first div element whose text contains some_text - ele.ele('#:ele_id')-Returns the child element with ele_id in the first id
- ele.ele('tag:div@text()=some_text') - Returns the first div element whose text is equal to some_text
- ele.ele('text:some_text') - returns the first element whose text contains some_text - ele.ele('@class:ele_class')-returns the first class that contains e le_class
- ele.ele('some_text') - returns the first element whose text contains some_text (equivalent to the previous line)
- ele.ele('text=some_text') - returns the first element whose text is equal to some_text - ele.ele('@name=ele_name')-returns the first child element whose name is equal to ele_name
- ele.ele('xpath://div[@class="ele_class"]') - Return the first element that matches xpath
- ele.ele('css:div.ele_class') - returns the first element that matches the css selector - ele.ele('@placeholder')-returns the first child element with placeholder attribute
- ele.ele('tag:p')-returns the first p child element
- ele.ele('tag:div@class:ele_class')-returns the first div sub-element that contains ele_class
- ele.ele('tag:div@class=ele_class')-returns the first div child element whose class is equal to ele_class
- ele.ele('tag:div@text():some_text')-returns the first div child element whose text contains some_text
- ele.ele('tag:div@text()=some_text')-returns the first div child element whose text is equal to some_tex t
- ele.ele('text:some_text')-returns the first child element whose text contains some_text
- ele.ele('some_text')-returns the first text element with some_text (equivalent to the previous line)
- ele.ele('text=some_text')-returns the first child element whose text is equal to some_text
- ele.ele('xpath://div[@class="ele_class"]')-Return the first child element that matches xpath
- ele.ele('css:div.ele_class')-returns the first child element that matches the css selector
Returns: [SessionElement, str] Returns: [SessionElement, str]
@ -2251,6 +2295,30 @@ Parameter Description:
### paths
Return paths setting information.
Returns: dict
### chrome_options
Return to chrome setting information.
Returns: dict
### session_options
Return session setting information.
Returns: dict
### get_value() ### get_value()
Get the configured value. Get the configured value.
@ -2480,6 +2548,14 @@ Return: DriverOptions - return self
Chrome's configuration is too difficult to remember, so the commonly used configuration is written as a simple method, and the call will modify the relevant content of the ini file. Chrome's configuration is too difficult to remember, so the commonly used configuration is written as a simple method, and the call will modify the relevant content of the ini file.
### show_settings()
Print all configuration information in the ini file.
Returns: None
### set_paths() ### set_paths()
Convenient way to set the path, save the incoming path to the default ini file, and check whether the chrome and chromedriver versions match. Convenient way to set the path, save the incoming path to the default ini file, and check whether the chrome and chromedriver versions match.

View File

@ -1198,7 +1198,7 @@ MixPage 封装了页面操作的常用功能,可在 driver 和 session 模式
### ele() ### ele()
返回页面中符合条件的元素,默认返回第一个。 返回页面中符合条件的元素,默认返回第一个。
​如查询参数是字符串,可选'@属性名:'、'tag:'、'text:'、'css:'、'xpath:'方式。无控制方式时默认用 text 方式查找。 ​如查询参数是字符串,可选 '@属性名:'、'tag:'、'text:'、'css:'、'xpath:'、'.'、'#' 方式。无控制方式时默认用 text 方式查找。
如是loc直接按照内容查询。 如是loc直接按照内容查询。
参数说明: 参数说明:
@ -1217,10 +1217,14 @@ MixPage 封装了页面操作的常用功能,可在 driver 和 session 模式
- 用查询字符串查找: - 用查询字符串查找:
属性、tag name和属性、文本、xpath、css selector。 属性、tag name 和属性、文本、xpath、css selector、id、class
其中,@表示属性=表示精确匹配,:表示模糊匹配,无控制字符串时默认搜索该字符串。 @ 表示属性,. 表示 class# 表示 id= 表示精确匹配,: 表示模糊匹配,无控制字符串时默认搜索该字符串。
- page.ele('.ele_class') - 返回第一个 class 为 ele_class 的元素
- page.ele('.:ele_class') - 返回第一个 class 中含有 ele_class 的元素
- page.ele('#ele_id') - 返回第一个 id 为 ele_id 的元素
- page.ele('#:ele_id') - 返回第一个 id 中含有 ele_id 的元素
- page.ele('@class:ele_class') - 返回第一个 class 含有 ele_class 的元素 - page.ele('@class:ele_class') - 返回第一个 class 含有 ele_class 的元素
- page.ele('@name=ele_name') - 返回第一个 name 等于 ele_name 的元素 - page.ele('@name=ele_name') - 返回第一个 name 等于 ele_name 的元素
- page.ele('@placeholder') - 返回第一个带 placeholder 属性的元素 - page.ele('@placeholder') - 返回第一个带 placeholder 属性的元素
@ -1793,7 +1797,7 @@ driver 模式的元素对象,包装了一个 WebElement 对象,并封装了
### ele() ### ele()
返回当前元素下级符合条件的子元素、属性或节点文本。 返回当前元素下级符合条件的子元素、属性或节点文本。
如查询参数是字符串,可选'@属性名:'、'tag:'、'text:'、'css:'、'xpath:'方式。无控制方式时默认用text方式查找。 如查询参数是字符串,可选 '@属性名:'、'tag:'、'text:'、'css:'、'xpath:'、'.'、'#' 方式。无控制方式时默认用 text 方式查找。
如是loc直接按照内容查询。 如是loc直接按照内容查询。
参数说明: 参数说明:
@ -1810,23 +1814,27 @@ driver 模式的元素对象,包装了一个 WebElement 对象,并封装了
- 用查询字符串查找: - 用查询字符串查找:
属性、tag name和属性、文本、xpath、css selector。 属性、tag name和属性、文本、xpath、css selector、id、class
其中,@表示属性=表示精确匹配,:表示模糊匹配,无控制字符串时默认搜索该字符串。 @ 表示属性,. 表示 class# 表示 id= 表示精确匹配,: 表示模糊匹配,无控制字符串时默认搜索该字符串。
- ele.ele('@class:ele_class') - 返回第一个 class 含有e le_class 的元素 - ele.ele('.ele_class') - 返回第一个 class 为 ele_class 的子元素
- ele.ele('@name=ele_name') - 返回第一个 name 等于 ele_name 的元素 - ele.ele('.:ele_class') - 返回第一个 class 中含有 ele_class 的子元素
- ele.ele('@placeholder') - 返回第一个带 placeholder 属性的元素 - ele.ele('#ele_id') - 返回第一个 id 为 ele_id 的子元素
- ele.ele('tag:p') - 返回第一个 p 元素 - ele.ele('#:ele_id') - 返回第一个 id 中含有 ele_id 的子元素
- ele.ele('tag:div@class:ele_class') - 返回第一个 class 含有 ele_class 的 div 元素 - ele.ele('@class:ele_class') - 返回第一个 class 含有e le_class 的子元素
- ele.ele('tag:div@class=ele_class') - 返回第一个 class 等于 ele_class 的 div 元素 - ele.ele('@name=ele_name') - 返回第一个 name 等于 ele_name 的子元素
- ele.ele('tag:div@text():some_text') - 返回第一个文本含有 some_text 的 div 元素 - ele.ele('@placeholder') - 返回第一个带 placeholder 属性的子元素
- ele.ele('tag:div@text()=some_text') - 返回第一个文本等于 some_tex t的 div 元素 - ele.ele('tag:p') - 返回第一个 p 子元素
- ele.ele('text:some_text') - 返回第一个文本含有 some_text 的元素 - ele.ele('tag:div@class:ele_class') - 返回第一个 class 含有 ele_class 的 div 子元素
- ele.ele('some_text') - 返回第一个文本含有 some_text 的元素(等价于上一行) - ele.ele('tag:div@class=ele_class') - 返回第一个 class 等于 ele_class 的 div 子元素
- ele.ele('text=some_text') - 返回第一个文本等于 some_text 的元素 - ele.ele('tag:div@text():some_text') - 返回第一个文本含有 some_text 的 div 子元素
- ele.ele('xpath://div[@class="ele_class"]') - 返回第一个符合 xpath 的元素 - ele.ele('tag:div@text()=some_text') - 返回第一个文本等于 some_tex t的 div 子元素
- ele.ele('css:div.ele_class') - 返回第一个符合 css selector 的元素 - ele.ele('text:some_text') - 返回第一个文本含有 some_text 的子元素
- ele.ele('some_text') - 返回第一个文本含有 some_text 的子元素(等价于上一行)
- ele.ele('text=some_text') - 返回第一个文本等于 some_text 的子元素
- ele.ele('xpath://div[@class="ele_class"]') - 返回第一个符合 xpath 的子元素
- ele.ele('css:div.ele_class') - 返回第一个符合 css selector 的子元素
返回: [DriverElement, str] 返回: [DriverElement, str]
@ -2181,7 +2189,7 @@ session 模式的元素对象包装了一个Element对象并封装了常
### ele() ### ele()
根据查询参数获取元素。 根据查询参数获取元素。
如查询参数是字符串,可选'@属性名:'、'tag:'、'text:'、'css:'、'xpath:'方式。无控制方式时默认用text方式查找。 如查询参数是字符串,可选 '@属性名:'、'tag:'、'text:'、'css:'、'xpath:'、'.'、'#' 方式。无控制方式时默认用 text 方式查找。
如是loc直接按照内容查询。 如是loc直接按照内容查询。
参数说明: 参数说明:
@ -2199,23 +2207,27 @@ session 模式的元素对象包装了一个Element对象并封装了常
- 用查询字符串查找: - 用查询字符串查找:
属性、tag name和属性、文本、xpath、css selector。 属性、tag name和属性、文本、xpath、css selector、id、class
其中,@表示属性=表示精确匹配,:表示模糊匹配,无控制字符串时默认搜索该字符串。 @ 表示属性,. 表示 class# 表示 id= 表示精确匹配,: 表示模糊匹配,无控制字符串时默认搜索该字符串。
- ele.ele('@class:ele_class') - 返回第一个 class 含有 ele_class 的元素 - ele.ele('.ele_class') - 返回第一个 class 为 ele_class 的子元素
- ele.ele('@name=ele_name') - 返回第一个 name 等于 ele_name 的元素 - ele.ele('.:ele_class') - 返回第一个 class 中含有 ele_class 的子元素
- ele.ele('@placeholder') - 返回第一个带 placeholder 属性的元素 - ele.ele('#ele_id') - 返回第一个 id 为 ele_id 的子元素
- ele.ele('tag:p') - 返回第一个 p 元素 - ele.ele('#:ele_id') - 返回第一个 id 中含有 ele_id 的子元素
- ele.ele('tag:div@class:ele_class') - 返回第一个 class 含有 ele_class 的div元素 - ele.ele('@class:ele_class') - 返回第一个 class 含有e le_class 的子元素
- ele.ele('tag:div@class=ele_class') - 返回第一个 class 等于 ele_class 的div元素 - ele.ele('@name=ele_name') - 返回第一个 name 等于 ele_name 的子元素
- ele.ele('tag:div@text():some_text') - 返回第一个文本含有 some_text 的div元素 - ele.ele('@placeholder') - 返回第一个带 placeholder 属性的子元素
- ele.ele('tag:div@text()=some_text') - 返回第一个文本等于 some_text 的div元素 - ele.ele('tag:p') - 返回第一个 p 子元素
- ele.ele('text:some_text') - 返回第一个文本含有 some_text 的元素 - ele.ele('tag:div@class:ele_class') - 返回第一个 class 含有 ele_class 的 div 子元素
- ele.ele('some_text') - 返回第一个文本含有 some_text 的元素(等价于上一行) - ele.ele('tag:div@class=ele_class') - 返回第一个 class 等于 ele_class 的 div 子元素
- ele.ele('text=some_text') - 返回第一个文本等于 some_text 的元素 - ele.ele('tag:div@text():some_text') - 返回第一个文本含有 some_text 的 div 子元素
- ele.ele('xpath://div[@class="ele_class"]') - 返回第一个符合 xpath 的元素 - ele.ele('tag:div@text()=some_text') - 返回第一个文本等于 some_tex t的 div 子元素
- ele.ele('css:div.ele_class') - 返回第一个符合 css selector 的元素 - ele.ele('text:some_text') - 返回第一个文本含有 some_text 的子元素
- ele.ele('some_text') - 返回第一个文本含有 some_text 的子元素(等价于上一行)
- ele.ele('text=some_text') - 返回第一个文本等于 some_text 的子元素
- ele.ele('xpath://div[@class="ele_class"]') - 返回第一个符合 xpath 的子元素
- ele.ele('css:div.ele_class') - 返回第一个符合 css selector 的子元素
返回: [SessionElement, str] 返回: [SessionElement, str]
@ -2247,6 +2259,30 @@ session 模式的元素对象包装了一个Element对象并封装了常
### paths
返回 paths 设置信息。
返回: dict
### chrome_options
返回 chrome 设置信息。
返回: dict
### session_options
返回 session 设置信息。
返回: dict
### get_value() ### get_value()
获取配置的值。 获取配置的值。
@ -2476,6 +2512,14 @@ on_off: bool - 打开或关闭
chrome 的配置太难记,所以把常用的配置写成简单的方法,调用会修改 ini 文件相关内容。 chrome 的配置太难记,所以把常用的配置写成简单的方法,调用会修改 ini 文件相关内容。
### show_settings()
打印 ini 文件中所有配置信息。
返回: None
### set_paths() ### set_paths()
便捷的设置路径方法,把传入的路径保存到默认 ini 文件,并检查 chrome 和 chromedriver 版本是否匹配。 便捷的设置路径方法,把传入的路径保存到默认 ini 文件,并检查 chrome 和 chromedriver 版本是否匹配。