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

249
Views
How to load values from a local csv and pass them in a webform using Playwright

So I am trying to automate the process of filling out a webform on https://www.business.att.com/disconnects/.

I am using the Playwright test tool to automate this process using JavaScript

I have the steps outlined in Playwright:

const { test, expect } = require('@playwright/test');

test('filling out ATT disconnect webform', async ({ page }) => {

  await page.goto('https://www.business.att.com/disconnects/');

  await page.click('select[name="region"]');
  await page.selectOption('select[name="region"]', "ES");

  await page.selectOption('select[name="service"]', 'ZH:E2');

  await page.click('text=Desired Disconnect Date');
   // This RequestedDisconnectDate is one of the values I want to pull from a local csv. I have it hard coded for now

  await page.fill('input[name="RequestedDisconnectDate"]', '01/12/2022');
  await page.click('a:has-text("12")');



  // For "Disconnect Reason", ALWAYS select = "Other"
  await page.click('select[name="ReasonForDisconnect"]');
  await page.selectOption('select[name="ReasonForDisconnect"]', '31');


  // For "Reason Other", ALWAYS fill = "Other"
  await page.click('input[name="ReasonForDisconnectOther"]');
  await page.fill('input[name="ReasonForDisconnectOther"]', 'Other');

  // ... 

  await page.click('input[alt="Submit"]');

});

Some of the values I am trying to pass in are constant but others are variable. For example, the RequestedDisconnectDate is stored in a csv. Those values I want to pull from a csv I have saved on my computer locally. But I am not sure how to go about that process. I have been looking at js library solutions and npm packages like csv-parser, and jquery. But I am not sure how to work it out.

If someone could give me an idea on how to approach this that would be much appreciated. thanks

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

0

I dont know much about csv files. I had something similar with .json files, at the time, I imported the json file as followed:

import * as whatever from 'path;

const firstVariable = whatever.myvariables[1] // depends on the file structure.

and then I would access the elements as an array. so you have to figure out if you can do the same with csv or just use json file instead which as I understood have a very similar structure to csv file.

another option would be using .env variable. It's not meant to be used for things like that but that would definitly work. In the .env file:

VARIABLE=variable content

in the test:

page.fill('selector', process.evn.VARIABLE);

Make sure to use env-cmd when executing the test files, so the env variable would be available: env-cmd npm run test

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!