Skip to content

Latest commit

 

History

History

check-if-opened-with-testcafe

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Check Whether Web Page Is Opened With TestCafe

Test Code: index.js Tested Page: index.html

When TestCafe runs, it exposes multiple variables with internal TestCafe data to the global object. Your application can check if these variables are present to determine whether it is opened with TestCafe.

This example demonstrates how to let your application know whether it is opened with TestCafe.

The test page includes a <div> with a <span>. When the page is opened, a script determines whether the page was opened with TestCafe. The <span> element then displays yes or no.

During the test, the t.expect.eql method checks the <div> text.

TestCafe Functions and Methods Used in This Example

  1. Test Structure:
  2. Assertion and Evaluation: