dimanche 9 février 2020

Inserting data into table cells with testcafe

I have a table with 3 rows and 4 columns like below. Columnone|columntwo|columnthreee|columnfour| checkbox|textbox|textbox|textbox| checkbox|textbox|textbox|textbox| checkbox|textbox|textbox|textbox|

I need to enter values like below into the table using testcafe: Columnone|columntwo|columnthreee|columnfour| checkbox|columntwo0|columnthreee0|columnfour0| checkbox|columntwo1|columnthreee1|columnfour1| checkbox|columntwo2|columnthreee2|columnfour2|

I tried the below code and tdText is of type function and not from client:

test("My test second", async t => {
  const table = Selector(".table");
  const rowCount = await table.find("tbody > tr").count;

  for (let i = 0; i < rowCount; i++) {
    const tdText =  table
      .find("tbody > tr")
      .nth(i)
      .find("td");
    for (let j = 1; j < tdText.length; j++) {
      const tdReferrer =  table
        .find("tbody > tr")
        .nth(i)
        .find("td")
        .nth(j);
      //console.log(typeof tdReferrer);
      //type text into each cell of a table
    }
  }
});

So tried below and tdText is of type function:

test("My test second", async t => {
  const table = Selector(".table");
  const rowCount = await table.find("tbody > tr").count;
  //dataInsert(table,rowCount);

  for (let i = 0; i < rowCount; i++) {
    const tdText = ClientFunction(() =>
      table
        .find("tbody > tr")
        .nth(i)
        .find("td")
    );
    for (let j = 1; j < tdText.length; j++) {
      const tdReferrer = table
        .find("tbody > tr")
        .nth(i)
        .find("td")
        .nth(j);
      //console.log(typeof tdReferrer);
      //type text into each cell of a table
    }
  }
});

So please help to find a solution. Also in clientfunction its not possible to call t.typetext as its supported with only Selectors

Aucun commentaire:

Enregistrer un commentaire