feat(gemini-ops): 新增页面刷新功能,调整点击操作抖动参数
This commit is contained in:
@@ -649,6 +649,28 @@ export function createOps(page) {
|
|||||||
|
|
||||||
// ─── 高层组合操作 ───
|
// ─── 高层组合操作 ───
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 刷新当前页面
|
||||||
|
*
|
||||||
|
* 适用于页面卡住、状态异常等场景。
|
||||||
|
* 刷新后会等待页面重新加载完成(waitUntil: networkidle2)。
|
||||||
|
*
|
||||||
|
* @param {object} [options]
|
||||||
|
* @param {number} [options.timeout=30000] - 等待页面加载的超时时间(ms)
|
||||||
|
* @returns {Promise<{ok: boolean, elapsed?: number, error?: string, detail?: string}>}
|
||||||
|
*/
|
||||||
|
async reloadPage({ timeout = 30_000 } = {}) {
|
||||||
|
try {
|
||||||
|
const start = Date.now();
|
||||||
|
await page.reload({ waitUntil: 'networkidle2', timeout });
|
||||||
|
const elapsed = Date.now() - start;
|
||||||
|
console.log(`[ops] 页面刷新完成 (${elapsed}ms)`);
|
||||||
|
return { ok: true, elapsed };
|
||||||
|
} catch (e) {
|
||||||
|
return { ok: false, error: 'reload_failed', detail: e.message };
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 上传图片到 Gemini 输入框
|
* 上传图片到 Gemini 输入框
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ export function createOperator(page) {
|
|||||||
* @returns {Promise<{ok: boolean, selector?: string, x?: number, y?: number, error?: string}>}
|
* @returns {Promise<{ok: boolean, selector?: string, x?: number, y?: number, error?: string}>}
|
||||||
*/
|
*/
|
||||||
async click(selectors, opts = {}) {
|
async click(selectors, opts = {}) {
|
||||||
const { jitter = 3, delayBeforeClick = 50, clickDuration = 80 } = opts;
|
const { jitter = 10, delayBeforeClick = 50, clickDuration = 80 } = opts;
|
||||||
|
|
||||||
const sels = Array.isArray(selectors) ? selectors : [selectors];
|
const sels = Array.isArray(selectors) ? selectors : [selectors];
|
||||||
const loc = await locate(sels);
|
const loc = await locate(sels);
|
||||||
|
|||||||
Reference in New Issue
Block a user