【发布时间】:2019-07-10 09:57:13
【问题描述】:
我正在尝试复制这个:
https://devexpress.github.io/testcafe/documentation/test-api/intercepting-http-requests/
我的目标页面有target="_blank" 有没有办法改变属性删除这个target?
所以测试失败了。
示例中的代码的作用不是很清楚。 URL 必须是下载链接所在的页面吗?
import { ClientFunction, t, Selector, RequestLogger } from 'testcafe'
import * as fs from 'fs';
import * as path from 'path';
...
const forInvoice = new ForInvoice()
const client = 'STRV s.r.o.'
const url = urlFor('?/timers/unbilledOverview')
const logger = RequestLogger({ url, method: 'post' }, {
logResponseHeaders: true,
logResponseBody: true
});
fixture.only `For Invoicing`
.requestHooks(logger);
test('Verify download of .xls and .pdf', async t => {
await t.useRole(ADMIN_INVOICE)
await forInvoice.navigateToForInvoicing()
await forInvoice.filterClient(client)
await t
.click(Selector('a').filter('.sc-mini-icon-file.excel-file'))
.expect(logger.contains(r => r.response.statusCode === 200)).ok();
const filePath = path.join(__dirname, 'STRV-s-r-o-Attachment');
console.log(filePath);
console.log(logger.requests[0].response.headers);
fs.writeFileSync(filePath, logger.requests[0].response.body);
})
【问题讨论】:
-
能否请您提供错误的文本?
标签: typescript automated-tests e2e-testing web-testing testcafe