Search code examples
testingautomationautomated-testse2e-testingtestcafe

Is the mix of TestCafe Studio codeless tests and implementing a Page Model mutually exclusive if the intent is to maintain codeless tests?


It is a TestCafe Best Practice to "use the Page Model in your tests". The TestCafe Page Model article instructs the user to use the Page Model pattern to create tests by writing the tests using JavaScript in .js files.

Meanwhile, TestCafe Studio supports the creation of *.testcafe codeless tests.

The use of JavaScript in the Page Model seems to imply that attempting to implement a Page Model while using "codeless" tests with the intent of maintaining them as codeless won't work out very well. That is to say, if the recorder is used to create codeless tests that are intended to immediately be converted to JavaScript, which is then sliced and diced to rearrange it to implement a Page Model, then that's a different story. I assume Studio generates JavaScript 'under the covers' for codeless tests, but if the intent is to maintain the tests as codeless, then essentially, this JavaScript should be considered uneditable.

Is the mix of TestCafe Studio codeless tests and implementing a Page Model mutually exclusive if the intent is to maintain codeless tests?


Solution

  • TestCafe Studio can be used to record tests both in coded (.js/.ts) and codeless (.testcafe) formats. However, PageModel, as a separate file, is supported only for coded tests. For codeless tests, you can use Define Element Selector steps to store selectors separately from test actions within one test. Copy/paste actions are available for all test steps and can be used in this case to share stored selectors between different test files. Also you can convert your codeless files to organize your tests using the PageModel approach.