跳至主要內容

方法

以下方法會新增至全域 WebdriverIO browser 物件。

儲存方法

提示

只有當您想要比較螢幕,而只想擁有元素/螢幕截圖時,才使用儲存方法。

saveElement

儲存元素的影像。

用法

await browser.saveElement(
// element
await $('#element-selector'),
// tag
'your-reference',
// saveElementOptions
{
// ...
}
);

支援

  • 桌面瀏覽器
  • 行動瀏覽器
  • 行動混合應用程式
  • 行動原生應用程式

參數

  • element:
    • 強制:
    • 類型:WebdriverIO 元素
  • tag:
    • 強制:
    • 類型:字串
  • saveElementOptions:
    • 強制:
    • 類型:選項物件,請參閱儲存選項

輸出:

請參閱測試輸出頁面。

saveScreen

儲存視窗的影像。

用法

await browser.saveScreen(
// tag
'your-reference',
// saveScreenOptions
{
// ...
}
);

支援

  • 桌面瀏覽器
  • 行動瀏覽器
  • 行動混合應用程式
  • 行動原生應用程式

參數

  • tag:
    • 強制:
    • 類型:字串
  • saveScreenOptions:
    • 強制:
    • 類型:選項物件,請參閱儲存選項

輸出:

請參閱測試輸出頁面。

saveFullPageScreen

用法

儲存完整螢幕的影像。

await browser.saveFullPageScreen(
// tag
'your-reference',
// saveFullPageScreenOptions
{
// ...
}
);

支援

  • 桌面瀏覽器
  • 行動瀏覽器

參數

  • tag:
    • 強制:
    • 類型:字串
  • saveFullPageScreenOptions:
    • 強制:
    • 類型:選項物件,請參閱儲存選項

輸出:

請參閱測試輸出頁面。

saveTabbablePage

儲存完整螢幕的影像,並包含可 Tab 切換的線條和點。

用法

await browser.saveTabbablePage(
// tag
'your-reference',
// saveTabbableOptions
{
// ...
}
);

支援

  • 桌面瀏覽器

參數

  • tag:
    • 強制:
    • 類型:字串
  • saveTabbableOptions:
    • 強制:
    • 類型:選項物件,請參閱儲存選項

輸出:

請參閱測試輸出頁面。

檢查方法

提示

當第一次使用 check 方法時,您會在記錄中看到以下警告。這表示如果您想要建立基準,則不需要結合 savecheck 方法。

#####################################################################################
Baseline image not found, save the actual image manually to the baseline.
The image can be found here:
/Users/wswebcreation/project/.tmp/actual/desktop_chrome/examplePage-chrome-latest-1366x768.png
If you want the module to auto save a non existing image to the baseline you
can provide 'autoSaveBaseline: true' to the options.
#####################################################################################

checkElement

將元素的影像與基準影像進行比較。

用法

await browser.checkElement(
// element
'#element-selector',
// tag
'your-reference',
// checkElementOptions
{
// ...
}
);

支援

  • 桌面瀏覽器
  • 行動瀏覽器
  • 行動混合應用程式
  • 行動原生應用程式

參數

  • element:
    • 強制:
    • 類型:WebdriverIO 元素
  • tag:
    • 強制:
    • 類型:字串
  • checkElementOptions:

輸出:

請參閱測試輸出頁面。

checkScreen

將視窗的影像與基準影像進行比較。

用法

await browser.checkScreen(
// tag
'your-reference',
// checkScreenOptions
{
// ...
}
);

支援

  • 桌面瀏覽器
  • 行動瀏覽器
  • 行動混合應用程式
  • 行動原生應用程式

參數

  • tag:
    • 強制:
    • 類型:字串
  • checkScreenOptions:

輸出:

請參閱測試輸出頁面。

checkFullPageScreen

將完整螢幕的影像與基準影像進行比較。

用法

await browser.checkFullPageScreen(
// tag
'your-reference',
// checkFullPageOptions
{
// ...
}
);

支援

  • 桌面瀏覽器
  • 行動瀏覽器

參數

  • tag:
    • 強制:
    • 類型:字串
  • checkFullPageOptions:

輸出:

請參閱測試輸出頁面。

checkTabbablePage

將包含可 Tab 切換的線條和點的完整螢幕影像與基準影像進行比較。

用法

await browser.checkTabbablePage(
// tag
'your-reference',
// checkTabbableOptions
{
// ...
}
);

支援

  • 桌面瀏覽器

參數

  • tag:
    • 強制:
    • 類型:字串
  • checkTabbableOptions:

輸出:

請參閱測試輸出頁面。

歡迎!我能如何協助您?

WebdriverIO AI Copilot