Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

123
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!