Click on modal with the Puppeteer Node Javascript library

Asked

Viewed 288 times

-1

Hello, I would like help to be able to select an item within a mondal, using the TAB key inside a FOR then a ENTER can solve , the problem and when the customer has another contract, even selected by the table id or field.

await page.waitForSelector('#ctl00_cph_FIJanela1_FIJanelaPanel1_grvHomo');
await page.click('#ctl00_cph_FIJanela1_FIJanelaPanel1_grvHomo');



await page.waitForSelector('#ctl00_cph_FIJanela1_FIJanelaPanel1_grvHomo > tbody > tr.normal > td:nth-child(1)');
await page.click('#ctl00_cph_FIJanela1_FIJanelaPanel1_grvHomo > tbody > tr.normal > td:nth-child(1)');
  • 3
  • Its description is not clear. Unfortunately we do not know what is "contract" in your case, we do not know how the screen, nor the structure of HTML, Moreover we have no way to test your problem to propose a solution. What you can do is create a page with a small example that reproduces your problem so that we can check and assist you, otherwise I fear it is impossible to answer your question

1 answer

0

It is difficult to decipher what you want with the question, but I will try to give a simple help that may help since you are starting.

There is an extension of Chrome that gives you the value of the css selector, this in a faster way, the copy-css-selector it will add the Css Path field to your Devtools.

Knowing exactly which selector, you can do the tests in Devtools, for example, you can test whether the click will work or whether you can set some value,

If on the console you put:

document.querySelector("input[name='q']").value = "teste";

the stackoverflow search bar will have the "test" text, to play it on Puppeteer you put it like this:

await page.evaluate(() => {
      document.querySelector("input[name='q']").value = "teste";
}).catch(error => { console.log(error) });

Watch out for websites that have Frames, because it is not possible to access them this way with Puppeteer.

If you want to specify your question better, it will be easier to help you, good luck!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.