In our insurance domain, the below scenario we want to achieve using testcafe:-
1st file:- Login into the application 2nd file:- create a claim, store the claim number into the global variable 3rd file:- use that globally declared claim number in all the Testscripts.
we are using the Page object model to achieve our scenario.
Please let us know how can we achieve this in testcafe. As we suspect, the web element value that we get in 2nd file gets vanished as soon as the test case gets executed. so how can we pass that web element value in our 3rd file? If possible, please let us know the steps in detail.
we have tried the below keywords to define our selector but it didn't work.
global
globalthis
We want to pass the data(fetched web element value) from one testscript to another testscript. Our question is whether it's possible or not
//page.js
import { Selector, t } from 'testcafe'; class PageModel { constructor() { global.ClaimNumber = Selector('#Txt_claimnumber'); //selector for Claim Number
this.DateOfEvent = Selector('#dateofevent'); //selector for Date of Event
this.DateOfClaim = Selector('#dateofclaim') //selector for Date of Claim
this.TimeOfEvent = Selector('#timeofevent') //selector for Time of Event
this.TimeOfClaim = Selector('#timeofclaim') //selector for Time of Claim
this.ClaimStatus = Selector('#claimstatus') //selector for Claim Status
this.Save = Selector('#Save'); //selector for Save Button
}};
export default new PageModel();
//test.js
import { Selector } from 'testcafe';
import PageModel from './page';
fixture
Getting Started.page
https://devexpress.github.io/testcafe/example;var claimid;//claimid will be generate after saving a claim
test('My first test', async t => { await t .typeText(this.DateOfEvent, '20/09/2022')
.typeText(this.DateOfClaim, '20/09/2022')
.typeText(this.TimeOfEvent, '12:00')
.typeText(this.TimeOfClaim, '12:00')
.typeText(this.ClaimStatus, 'xyz')
.click(this.Save)
claimid=global.ClaimNumber.value
//After saving the claim we want to fetch claimid and want to use that claim id in another testscript
});
//test1.js
import { Selector } from 'testcafe';
import PageModel from './page';
import Test from './test'
fixtureGetting Started
.pagehttps://devexpress.github.io/testcafe/example;
test('My first test', async t => {
var claimid1='23445'; await t.expect(claimid1).eql('claimid');
//want to verify claimid getting from test.js is equal to claimid from test1.js or not
//this is just an example but our requirement is to use claimid (getting from test.js) for different different operation into test1.js testscript.
});
Could you please tell us how to achieve this scenario.