Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

255
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda