czzad
czzad

Reputation: 25

Puppeteer do not click in element

So 'm trying to make the way to see my grades easier.

I'm having some issues clicking on "Boletim", it does not work.

This is the button part of the website:

  <table>
    <tbody>
       <tr>
          <td>
             <input id="btBoletim" onclick="btBoletim_click();" type="button" title="Emitir
             boletim"value="Emitir Boletim" class="form1" style="width:120px;cursor:pointer">
          </td>
       </tr>
    </tbody>
 </table>

This is the line that i was trying to use:

  await page.click('[id="btBoletim"]');

I've already tried some other codes but they didn't worked too.

I think that is because the button open a new window and I'm starting with this

Upvotes: 1

Views: 175

Answers (4)

i-Guru
i-Guru

Reputation: 184

I think your elements are not ready when you are calling that script Insert bellow codes

await page.waitForNavigation(); 

or

await page.waitFor(100000) 

to get load all of your elements

Thanks

Upvotes: 1

czzad
czzad

Reputation: 25

already made it work, just needed some time before clicking

Upvotes: 0

Nanoo
Nanoo

Reputation: 903

Use JQuery, if you're trying to simulate a click:

$("#btBoletim").click()

JQuery 3.2.1 Library: https://code.jquery.com/jquery-3.2.1.min.js

Upvotes: 0

EugenSunic
EugenSunic

Reputation: 13703

Remove the brackets and the id key

 await page.click('#btBoletim');

Upvotes: 0

Related Questions