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

124
Visualizações
Watir Click JS Button

I can't seem to get past a button in a landing page. Here is the JS element with parent nodes:

<div class="modal-body-content callfor-popup">
  <h3>Welcome | Bienvenue</h3>

  <p class="body_M_normal" aria-level="4" role="heading">Please select a language | Veuillez sélectionner une langue</p>

  <div class="small_btn lcbo_cookie">
    <a class="body_M_normal" href="https://www.lcbo.com/en/stores/store/redirect/___store/en/___from_store/en/uenc/aHR0cHM6Ly93d3cubGNiby5jb20vZW4v/">English</a>
  </div>

  <div class="small_btn lcbo_cookie">
    <a class="body_M_normal" href="https://www.lcbo.com/en/stores/store/redirect/___store/fr/___from_store/en/uenc/aHR0cHM6Ly93d3cubGNiby5jb20vZnIv/">Français</a>
  </div>

  <hr>

  <p class="caption_xxs_noletterspace">
    You must be 19 years of age to purchase alcohol. Please note that we only deliver in Ontario / Vous devez avoir au moins 19 ans pour acheter de l'alcool. Veuillez noter que nous ne livrons pas à l'extérieur de l’Ontario.
  </p>
</div>

This is what I am currently trying:

    puts '1' if a.element(visible_text: 'English').exist?
    puts '2' if a.link(visible_text: 'English').exist?
    puts '3' if a.button(text: 'English').exist?
    puts '4' if a.link(visible_text: 'English').exist?
    puts '5' if a.element(visible_text: 'English').exist?

    a.button(text: 'English').click
    a.element(visible_text: 'English').click
    a.link(visible_text: 'English').click
    
    puts "clicks finished"

1, 2, 4 and 5 show up, indicating Watir knows they are there and exist. I can't seem to click that element though. It's not a formal HTML button, so that's why I'm trying several elements.

Is there a better way of dealing with such JS elements? I'm not sure how to focus on the English option.

about 4 years ago · Juan Pablo Isaza
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