Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

165
Visualizações
.click() method not recognised

Right now i'm playing around with creating yet another version of a bot for one of my favorit browser games Big Barn World. I try to use .click() on an Element to water a crop which just won't work. I tried adding an EventListener to the node i'm using .click() on. That works fine but the Website itself does not react to that. In previous versions i used http requests or mouse automation, both being slow and inconsistent. I'm looking for a different approach to "click" the buttons on the Webpage. I would already be happy if you could tell me what might be stopping .click() from working so i can do further research. I'm using C#/JS with EO.WebBrowser.

This is the JS code i'm running.

document.getElementById('s_0_0').click();

I tried this in chrome dev console and clicked the button manually. If i click manually everything works fine. As said the EventListener recognises my .click()-call but the website itself just won't do anything. Dev Console Returns "undefined".

The Element i'm trying to click.

<div class="sector s_0_0" id="s_0_0" style="background-image: url(&quot;https://static.airg.ca/games/bbw/fieldplot/200/200/png&quot;); width: 20%; padding-bottom: 20%;">
    <div class="overlay itemImage " style="background-image: url(https://static.airg.ca/games/bbw/WheatSeeds_seeded/200/200/png)"></div>           
    <div class="overlay status water" style="background-image: url(&quot;https://static.airg.ca/bbw5/img/status_water.png&quot;);"></div>
</div>

EDIT: from what i've read the problem might be the click() method being isTrusted = false;

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You seem to be mixing two different issues. The first is about the method being recognized.

When you have a browser console interaction like

> document.getElementById('...').click()
< undefined

the click method was recognized, it just produced no return value. You can check the behavior of calling something unrecognized

> (0).click();
x Uncaught TypeError: 0.click is not a function at <anonymous>:1:5

Now the second issue, is about the method doing nothing. Event handling in web pages can be done in many different ways. What does click() do? Perhaps it sends a mouseclick event, but the app in question might be listening for a mousedown event (triggered as soon as the button is pressed, without waiting for its release). You can search your browser's Developer Tools documentation to know how to check event listeners for an element and figure out the appropriate one you should be triggering. Simulating something like a mousedown event is a lot more complex than just calling click() but it's doable. You can check the MDN documentation for MouseEvent and search for the example of how to create a synthetic click mouse event.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda