跳至內容
Astera Technology

必要依據,不應只靠滑鼠懸停開啟

同一原文,焦點、觸控及指標都要核。

下載完整個案資料及參考答案 ↓

訂判斷及所需輸入

R1 必須可讀 E1。錯介面只在懸停顯示,焦點到紀錄仍藏。更正加 Show evidence,Enter 或觸控都開同一原文;字留在藏着的 DOM,未完成閱讀。

已填本地測試工作表
情況輸入 JSON
原例測試{"method":"keyboard"}
下載可編輯 CSV ↓

跑所附比較

瀏覽器實際懸停、Enter 及觸控後核顯示狀態;顯示不會授予受限資料權限,也不標個案已完成。

錯誤及所需輸出
路徑輸出 JSON
錯誤路徑{"visible":false,"text":"Evidence E1"}
所需路徑{"visible":true,"text":"Evidence E1"}
下載可編輯 CSV ↓
Node24.14.1 程序;須 Playwright1.63 Chromium
import assert from 'node:assert/strict';
import {createRequire} from 'node:module';
const htmlEscape=s=>String(s).replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;').replace(/"/g,'&quot;');
async function withPage(action,options={}){
  const require=createRequire(import.meta.url);const {chromium}=require('playwright');
  const browser=await chromium.launch({headless:true});
  try{const context=await browser.newContext(options);const page=await context.newPage();
    const requests=[];await page.route('**/*',route=>{requests.push(route.request().url());return route.abort();});
    return await action(page,context,requests);
  }finally{await browser.close();}
}

const run=async function run(i,corrected=true){
    if(!['keyboard','touch','pointer'].includes(i.method))return {held:true};
    return withPage(async page=>{await page.setContent('<style>#tip{display:none}.record:hover #tip{display:block}</style><div class="record" tabindex="0" id="record">Record R1'+(corrected?'<button id="show">Show evidence</button>':'')+'<span id="tip">Evidence E1</span></div>');
      if(corrected)await page.evaluate(()=>document.querySelector('#show').addEventListener('click',()=>document.querySelector('#tip').style.display='block'));
      if(i.method==='pointer')await page.hover('#record');else if(corrected&&i.method==='touch')await page.tap('#show');else if(corrected){await page.focus('#show');await page.press('#show','Enter');}else await page.focus('#record');
      return page.evaluate(()=>({visible:getComputedStyle(document.querySelector('#tip')).display!=='none',text:document.querySelector('#tip').textContent}));
    },{hasTouch:i.method==='touch'});
  };
const cases=[{"input":{"method":"keyboard"},"corrected":false,"expected":{"visible":false,"text":"Evidence E1"}},{"input":{"method":"keyboard"},"corrected":true,"expected":{"visible":true,"text":"Evidence E1"}},{"input":{"method":"touch"},"corrected":true,"expected":{"visible":true,"text":"Evidence E1"}},{"input":{"method":"pointer"},"corrected":true,"expected":{"visible":true,"text":"Evidence E1"}}];
for(const test of cases){const actual=await run(test.input,test.corrected);assert.deepEqual(actual,test.expected);console.log(actual);}
下載可執行例子 ↓

按邊界依據作判斷

更正觸控及指標邊界都顯 E1,原文身分不改。

  1. 核必須可讀依據
  2. 各按所需方法開
  3. 核真正顯示狀態

權限規則與開啟機制分開核。

可編輯邊界輸入及結果
條件輸入 JSON預期輸出 JSON
觸控開啟依據{"method":"touch"}{"visible":true,"text":"Evidence E1"}
指標開啟依據{"method":"pointer"}{"visible":true,"text":"Evidence E1"}
下載可編輯 CSV ↓

原例鍵盤動作須開到甚麼?

查看參考答案

同一 E1,而且真正看得到,不是只有隱藏文字節點。

相關資源