I am attempting to recreate the functionality found at:
The page I am working on has a target="_blank"
attribute, is it possible to remove this attribute?
This currently causes the test to fail.
The purpose of the code example provided is not entirely clear. Must the URL be that of the page containing the download link?
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);
})