Simulate Click with webview in a href

2
<li class="paginate_button page-item next" id="tb_next"
  <a href="#" aria-controls="tb" data-dt-idx="5" tabindex="0" class="page-link">Seguinte</a>
</li>

Hello friends, I have a page that has this html code and I need to simulate a click on this href, the simulation I can already get via webview (javafx)

webEngine.executeScript(
  "document.getElementById(\"botão\").click();"
);

But as you can see, there is only ID in the parent element and I am not able to access the href child element.

I've tried this, but it's not working:

webEngine.executeScript(
  "document.getElementById(\"tb_next\").firstChild.click();"
);

Someone could help me please, thank you in advance for any help.

    
asked by anonymous 26.11.2018 / 14:02

2 answers

0

Use document.querySelector where you can more easily select <a> within <li> in question:

document.querySelector("#tb_next a").click();

Example:

document.querySelector("#tb_next a").click();
<li class="paginate_button page-item next" id="tb_next">
   <a href="javascript: alert('ok')" aria-controls="tb" data-dt-idx="5" tabindex="0" class="page-link">Seguinte</a>
</li>
    
26.11.2018 / 14:12
-1

I do using querySelectorAll

the selection ex would be something like

webEngine.executeScript(
  "document.querySelectorAll(\"#tb_next > .page-link\").click();"
);

it would execute the click on all .page-link that have inside a #tb_next

    
26.11.2018 / 14:13