Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

205
Views
Is it possible for testcafe to read a variable from another file?

I want to create some automation so the user would have to place a file with some details like their address and then my automation script would pick it up.

I'm comfortable with using the const command in TestCafe to pick up local variables but is there a way if i put a file in like lets say address.txt for it to pick up line1 line2 line3, etc?

So i see the code like this:

const line1;
const line2;
const line3;

and in Address.txt we'd have

$line1 = '1 hello world way'
$line2 = 'line 2'
$line3= 'line 3'

What am i missing to plug it all together? Thanks,

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

You can use the native facilities of NodeJS. Please refer to the example from our documentation for more details.

about 4 years ago · Juan Pablo Isaza Report

0

This would be better if done through json. Here is a high level approach you could take:

  1. Keep an excel file to get data from users (say, address).
  2. Use xlsx-to-json to convert excel data to json.
  3. Refer this json in your script: const dataFile = require('./data.json');
  4. Parse json and do whatever is needed.
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!