mirror of
https://gitee.com/g1879/DrissionPage.git
synced 2024-12-04 13:07:45 +08:00
to_iframe()改名为to_frame()
This commit is contained in:
parent
9ef2285712
commit
2882f17745
@ -5,15 +5,15 @@
|
||||
@File : driver_page.py
|
||||
"""
|
||||
from glob import glob
|
||||
from pathlib import Path
|
||||
from typing import Union, List, Any, Tuple
|
||||
from urllib.parse import quote
|
||||
|
||||
from pathlib import Path
|
||||
from selenium.common.exceptions import NoAlertPresentException
|
||||
from selenium.webdriver.chrome.webdriver import WebDriver
|
||||
from selenium.webdriver.remote.webelement import WebElement
|
||||
from selenium.webdriver.support.wait import WebDriverWait
|
||||
from time import time, sleep
|
||||
from typing import Union, List, Any, Tuple
|
||||
from urllib.parse import quote
|
||||
|
||||
from .common import str_to_loc, get_available_file_name, translate_loc, format_html
|
||||
from .driver_element import DriverElement, execute_driver_find
|
||||
@ -421,18 +421,18 @@ class DriverPage(object):
|
||||
tab = self.driver.window_handles[tab] if isinstance(tab, int) else tab
|
||||
self.driver.switch_to.window(tab)
|
||||
|
||||
def to_iframe(self, loc_or_ele: Union[int, str, tuple, WebElement, DriverElement] = 'main') -> None:
|
||||
"""跳转到iframe \n
|
||||
可接收iframe序号(0开始)、id或name、查询字符串、loc元组、WebElement对象、DriverElement对象, \n
|
||||
传入'main'跳到最高层,传入'parent'跳到上一层 \n
|
||||
示例: \n
|
||||
to_iframe('tag:iframe') - 通过传入iframe的查询字符串定位 \n
|
||||
to_iframe('iframe_id') - 通过iframe的id属性定位 \n
|
||||
to_iframe('iframe_name') - 通过iframe的name属性定位 \n
|
||||
to_iframe(iframe_element) - 通过传入元素对象定位 \n
|
||||
to_iframe(0) - 通过iframe的序号定位 \n
|
||||
to_iframe('main') - 跳到最高层 \n
|
||||
to_iframe('parent') - 跳到上一层 \n
|
||||
def to_frame(self, loc_or_ele: Union[int, str, tuple, WebElement, DriverElement] = 'main') -> None:
|
||||
"""跳转到frame \n
|
||||
可接收frame序号(0开始)、id或name、查询字符串、loc元组、WebElement对象、DriverElement对象, \n
|
||||
传入'main'跳到最高层,传入'parent'跳到上一层 \n
|
||||
示例: \n
|
||||
to_frame('tag:iframe') - 通过传入frame的查询字符串定位 \n
|
||||
to_frame('iframe_id') - 通过frame的id属性定位 \n
|
||||
to_frame('iframe_name') - 通过frame的name属性定位 \n
|
||||
to_frame(iframe_element) - 通过传入元素对象定位 \n
|
||||
to_frame(0) - 通过frame的序号定位 \n
|
||||
to_frame('main') - 跳到最高层 \n
|
||||
to_frame('parent') - 跳到上一层 \n
|
||||
:param loc_or_ele: iframe的定位信息
|
||||
:return: None
|
||||
"""
|
||||
|
32
README.en.md
32
README.en.md
@ -564,11 +564,12 @@ When calling a method that only belongs to d mode, it will automatically switch
|
||||
|
||||
```python
|
||||
page.set_cookies() # set cookies
|
||||
page.get_cookies() # Get cookies, which can be returned by list or dict
|
||||
page.get_cookies() # Get cookies, which can be returned by list or dict
|
||||
page.change_mode() # Switch mode, it will automatically copy cookies
|
||||
page.cookies_to_session() # Copy cookies from WebDriver object to Session object
|
||||
page.cookies_to_driver() # Copy cookies from Session object to WebDriver object
|
||||
page.get(url, retry, interval, **kwargs) # Use get to access the web page, you can specify the number of retries and the interval
|
||||
page.get(url, retry, interval,
|
||||
**kwargs) # Use get to access the web page, you can specify the number of retries and the interval
|
||||
page.ele(loc_or_ele, timeout) # Get the first element, node or attribute that meets the conditions
|
||||
page.eles(loc_or_ele, timeout) # Get all eligible elements, nodes or attributes
|
||||
page.download(url, save_path, rename, file_exists, **kwargs) # download file
|
||||
@ -576,7 +577,8 @@ page.close_driver() # Close the WebDriver object
|
||||
page.close_session() # Close the Session object
|
||||
|
||||
# s mode unique:
|
||||
page.post(url, data, retry, interval, **kwargs) # To access the webpage in post mode, you can specify the number of retries and the interval
|
||||
page.post(url, data, retry, interval,
|
||||
**kwargs) # To access the webpage in post mode, you can specify the number of retries and the interval
|
||||
|
||||
# d mode unique:
|
||||
page.wait_ele(loc_or_ele, mode, timeout) # Wait for the element to be deleted, displayed, and hidden from the dom
|
||||
@ -585,10 +587,11 @@ page.create_tab(url) # Create and locate a tab page, which is at the end
|
||||
page.to_tab(num_or_handle) # Jump to tab page
|
||||
page.close_current_tab() # Close the current tab page
|
||||
page.close_other_tabs(num_or_handles) # Close other tabs
|
||||
page.to_iframe(iframe) # cut into iframe
|
||||
page.to_frame(iframe) # cut into iframe
|
||||
page.screenshot(path) # Page screenshot
|
||||
page.scrool_to_see(element) # Scroll until an element is visible
|
||||
page.scroll_to(mode, pixel) # Scroll the page as indicated by the parameter, and the scroll direction is optional:'top','bottom','rightmost','leftmost','up','down','left', ' right'
|
||||
page.scroll_to(mode,
|
||||
pixel) # Scroll the page as indicated by the parameter, and the scroll direction is optional:'top','bottom','rightmost','leftmost','up','down','left', ' right'
|
||||
page.refresh() # refresh the current page
|
||||
page.back() # Browser back
|
||||
page.et_window_size(x, y) # Set the browser window size, maximize by default
|
||||
@ -1725,9 +1728,7 @@ Parameter Description:
|
||||
|
||||
Returns: None
|
||||
|
||||
|
||||
|
||||
### to_iframe()
|
||||
### to_frame()
|
||||
|
||||
Jump to iframe, jump to the highest level by default, compatible with selenium native parameters.
|
||||
|
||||
@ -1736,13 +1737,14 @@ Parameter Description:
|
||||
- loc_or_ele:[int, str, tuple, WebElement, DriverElement] - Find the condition of iframe element, can receive iframe serial number (starting at 0), id or name, query string, loc parameter, WebElement object, DriverElement object, and pass in ' main' jump to the highest level, and pass in'parent' to jump to the upper level
|
||||
|
||||
Example:
|
||||
- to_iframe('tag:iframe')- locate by the query string passed in iframe
|
||||
- to_iframe('iframe_id')- Positioning by the id attribute of the iframe
|
||||
- to_iframe('iframe_name')- locate by the name attribute of iframe
|
||||
- to_iframe(iframe_element)- locate by passing in the element object
|
||||
- to_iframe(0)- locate by the serial number of the iframe
|
||||
- to_iframe('main')- jump to the top level
|
||||
- to_iframe('parent')- jump to the previous level
|
||||
|
||||
- to_frame('tag:iframe')- locate by the query string passed in iframe
|
||||
- to_frame('iframe_id')- Positioning by the id attribute of the iframe
|
||||
- to_frame('iframe_name')- locate by the name attribute of iframe
|
||||
- to_frame(iframe_element)- locate by passing in the element object
|
||||
- to_frame(0)- locate by the serial number of the iframe
|
||||
- to_frame('main')- jump to the top level
|
||||
- to_frame('parent')- jump to the previous level
|
||||
|
||||
Returns: None
|
||||
|
||||
|
@ -551,10 +551,11 @@ page.create_tab(url) # 新建并定位到一个标签页,该标签页在最后
|
||||
page.to_tab(num_or_handle) # 跳转到标签页
|
||||
page.close_current_tab() # 关闭当前标签页
|
||||
page.close_other_tabs(num_or_handles) # 关闭其它标签页
|
||||
page.to_iframe(iframe) # 切入 iframe
|
||||
page.to_frame(iframe) # 切入 iframe
|
||||
page.screenshot(path) # 页面截图
|
||||
page.scroll_to_see(element) # 滚动直到某元素可见
|
||||
page.scroll_to(mode, pixel) # 按参数指示方式滚动页面,可选滚动方向:'top', 'bottom', 'rightmost', 'leftmost', 'up', 'down', 'left', 'right'
|
||||
page.scroll_to(mode,
|
||||
pixel) # 按参数指示方式滚动页面,可选滚动方向:'top', 'bottom', 'rightmost', 'leftmost', 'up', 'down', 'left', 'right'
|
||||
page.refresh() # 刷新当前页面
|
||||
page.back() # 浏览器后退
|
||||
page.et_window_size(x, y) # 设置浏览器窗口大小,默认最大化
|
||||
|
Loading…
Reference in New Issue
Block a user