0

I'm trying to click on the element using xpath on puppeteer. It actually didn't throw any errors, its just that the puppeteer won't click on the element. I don't know if there's something wrong with my code.I'll be showing the element that I'm trying to click on and the 2 solutions that I made. any help will be appreciated thanks.

this is the element that I'm trying to click on.

<div class="formSelectCombo-item" value="1470000113" title="Purchase Request" style="height: 15.2px; width: 100px;">Purchase Request</div>

first solution

await page.waitFor(2000); 
const prcf = await page.$x("//div[@class='formSelectCombo-item']
[@value='1470000113'][title='Purchase Request']");

 await page.waitForSelector[prcf];
 await prcf[0].click();

second solution

await page.waitFor(2000);
    const [prcf] = await page.$x("//div[@class='formSelectCombo-item'][@value='1470000113'][title='Purchase Request']");

    if (prcf)
    {
      await prcf.click();
    }
skyboyer
  • 22,209
  • 7
  • 57
  • 64

1 Answers1

0

Could you try :

const [button] = await page.$x("//div[@class='formSelectCombo-item'][@title='Purchase Request']");
await button.click();
E.Wiest
  • 5,425
  • 2
  • 7
  • 12