Merge pull request #310 from zfangqijun/chore-export-actions
chore(page-controller): export actions as internal methods
This commit is contained in:
@@ -424,3 +424,5 @@ export class PageController extends EventTarget {
|
|||||||
this.mask = null
|
this.mask = null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export * from './actions'
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the HTMLElement by index from a selectorMap.
|
* Get the HTMLElement by index from a selectorMap.
|
||||||
|
* @private Internal method, subject to change at any time.
|
||||||
*/
|
*/
|
||||||
export function getElementByIndex(
|
export function getElementByIndex(
|
||||||
selectorMap: Map<number, InteractiveElementDomNode>,
|
selectorMap: Map<number, InteractiveElementDomNode>,
|
||||||
@@ -54,6 +55,7 @@ function blurLastClickedElement() {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Simulate a click on the element
|
* Simulate a click on the element
|
||||||
|
* @private Internal method, subject to change at any time.
|
||||||
*/
|
*/
|
||||||
export async function clickElement(element: HTMLElement) {
|
export async function clickElement(element: HTMLElement) {
|
||||||
blurLastClickedElement()
|
blurLastClickedElement()
|
||||||
@@ -89,6 +91,9 @@ export async function clickElement(element: HTMLElement) {
|
|||||||
await waitFor(0.2) // Wait to ensure click event processing completes
|
await waitFor(0.2) // Wait to ensure click event processing completes
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private Internal method, subject to change at any time.
|
||||||
|
*/
|
||||||
export async function inputTextElement(element: HTMLElement, text: string) {
|
export async function inputTextElement(element: HTMLElement, text: string) {
|
||||||
const isContentEditable = element.isContentEditable
|
const isContentEditable = element.isContentEditable
|
||||||
if (!isInputElement(element) && !isTextAreaElement(element) && !isContentEditable) {
|
if (!isInputElement(element) && !isTextAreaElement(element) && !isContentEditable) {
|
||||||
@@ -196,6 +201,7 @@ export async function inputTextElement(element: HTMLElement, text: string) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @todo browser-use version is very complex and supports menu tags, need to follow up
|
* @todo browser-use version is very complex and supports menu tags, need to follow up
|
||||||
|
* @private Internal method, subject to change at any time.
|
||||||
*/
|
*/
|
||||||
export async function selectOptionElement(selectElement: HTMLSelectElement, optionText: string) {
|
export async function selectOptionElement(selectElement: HTMLSelectElement, optionText: string) {
|
||||||
if (!isSelectElement(selectElement)) {
|
if (!isSelectElement(selectElement)) {
|
||||||
@@ -219,6 +225,9 @@ interface ScrollableElement extends Element {
|
|||||||
scrollIntoViewIfNeeded?: (centerIfNeeded?: boolean) => void
|
scrollIntoViewIfNeeded?: (centerIfNeeded?: boolean) => void
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private Internal method, subject to change at any time.
|
||||||
|
*/
|
||||||
export async function scrollIntoViewIfNeeded(element: Element) {
|
export async function scrollIntoViewIfNeeded(element: Element) {
|
||||||
const el = element as ScrollableElement
|
const el = element as ScrollableElement
|
||||||
if (typeof el.scrollIntoViewIfNeeded === 'function') {
|
if (typeof el.scrollIntoViewIfNeeded === 'function') {
|
||||||
@@ -231,6 +240,9 @@ export async function scrollIntoViewIfNeeded(element: Element) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private Internal method, subject to change at any time.
|
||||||
|
*/
|
||||||
export async function scrollVertically(
|
export async function scrollVertically(
|
||||||
down: boolean,
|
down: boolean,
|
||||||
scroll_amount: number,
|
scroll_amount: number,
|
||||||
@@ -359,6 +371,9 @@ export async function scrollVertically(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private Internal method, subject to change at any time.
|
||||||
|
*/
|
||||||
export async function scrollHorizontally(
|
export async function scrollHorizontally(
|
||||||
right: boolean,
|
right: boolean,
|
||||||
scroll_amount: number,
|
scroll_amount: number,
|
||||||
|
|||||||
Reference in New Issue
Block a user