Files
zhaopin/scripts/test-greet-hr1.js
T

38 lines
2.0 KiB
JavaScript

// 手动测试 hr1 打招呼是否恢复(职位切换后验证)
const pw = require('playwright-core');
(async () => {
const b = await pw.chromium.connectOverCDP('http://127.0.0.1:9223');
const p = b.contexts()[0]?.pages().find(x => /rd\d?\.zhaopin\.com/.test(x.url()));
const cards = await p.$$('.recommend-item');
console.log('卡片数:', cards.length);
for (let i = 0; i < Math.min(cards.length, 4); i++) {
const content = await cards[i].$('.resume-item__content').catch(() => null);
if (!content) continue;
await content.click();
await new Promise(r => setTimeout(r, 3500));
const btn = p.locator('.new-shortcut-resume__modal button.km-button--primary.km-button--filled').first();
const t1 = ((await btn.innerText({ timeout: 4000 }).catch(() => '')) || '').trim();
console.log(`卡片${i} 按钮文案:`, JSON.stringify(t1));
if (t1 === '打招呼') {
await btn.click({ timeout: 5000 }).catch(e => console.log('点击失败:', String(e).slice(0, 60)));
let final = '';
for (let k = 0; k < 16; k++) {
await new Promise(r => setTimeout(r, 500));
final = ((await btn.innerText({ timeout: 2000 }).catch(() => '')) || '').trim();
if (final === '继续沟通') break;
}
console.log(final === '继续沟通' ? '✅ 打招呼成功!职位已生效' : '❌ 点击后按钮仍为: ' + (final || '(空)'));
await p.evaluate(() => document.querySelector('.new-shortcut-resume__close')?.click()).catch(() => { });
process.exit(0);
} else if (t1 === '继续沟通') {
console.log('该候选人已打过招呼,试下一个');
} else {
console.log('❌ 无打招呼按钮(职位仍未生效)');
process.exit(0);
}
await p.evaluate(() => document.querySelector('.new-shortcut-resume__close')?.click()).catch(() => { });
await new Promise(r => setTimeout(r, 800));
}
process.exit(0);
})().catch(e => { console.log('ERR:', String(e).slice(0, 100)); process.exit(1); });