NoSuchElementError with Selenium using RubyMine after trying all element attributes

52 Views Asked by At

I am tying to write some tests for this website: https://roomy-fire-houseboat.glitch.me/ but unable to find any elements. I can launch the website then add 5 seconds of sleep.

Here is the error in RubyMine:

Selenium::WebDriver::Error::NoSuchElementError: no such element: Unable to locate element: {"method":"css selector","selector":"#number"}
  (Session info: chrome=123.0.6312.59); For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#no-such-element-exception
        GetHandleVerifier [0x00534CE3+225091]
       (No symbol) [0x00464E31]
    (No symbol) [0x00309A7A]
    (No symbol) [0x0034175B]
    (No symbol) [0x0034188B]
    (No symbol) [0x00377882]
    (No symbol) [0x0035F5A4]
    (No symbol) [0x00375CB0]
    (No symbol) [0x0035F2F6]
    (No symbol) [0x003379B9]
    (No symbol) [0x0033879D]
    sqlite3_dbdata_init [0x009A9A83+4064547]
    sqlite3_dbdata_init [0x009B108A+4094762]
    sqlite3_dbdata_init [0x009AB988+4072488]
    sqlite3_dbdata_init [0x006AC9E9+930953]
     (No symbol) [0x00470804]
    (No symbol) [0x0046AD28]
    (No symbol) [0x0046AE51]
    (No symbol) [0x0045CAC0]
    BaseThreadInitThunk [0x76EB7BA9+25]
 RtlInitializeExceptionChain [0x779EBDAB+107]
        RtlClearBits [0x779EBD2F+191]
C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/selenium-webdriver-4.10.0/lib/selenium/webdriver/remote/response.rb:55:in `assert_ok'
C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/selenium-webdriver-4.10.0/lib/selenium/webdriver/remote/response.rb:34:in `initialize'
C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/selenium-webdriver-4.10.0/lib/selenium/webdriver/remote/http/common.rb:83:in `new'
C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/selenium-webdriver-4.10.0/lib/selenium/webdriver/remote/http/common.rb:83:in `create_response'
C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/selenium-webdriver-4.10.0/lib/selenium/webdriver/remote/http/default.rb:104:in `request'
C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/selenium-webdriver-4.10.0/lib/selenium/webdriver/remote/http/common.rb:59:in `call'
C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/selenium-webdriver-4.10.0/lib/selenium/webdriver/remote/bridge.rb:620:in `execute'
C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/selenium-webdriver-4.10.0/lib/selenium/webdriver/remote/bridge.rb:537:in `find_element_by'
C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/selenium-webdriver-4.10.0/lib/selenium/webdriver/common/search_context.rb:63:in `find_element'

Here is the current line, I am using to find the text box on the website.

driver.find_element(:id, 'number')

I have also tried :css and :xpath.

When I inspect the element, I get the following:

id = "number" type = "text"

selector = #number

xpath = //*[@id="number"]

1

There are 1 best solutions below

2
Rajagopalan On

Not sure what your program is, I have written the following program and it works fine for me.

require 'selenium-webdriver'

driver = Selenium::WebDriver.for :chrome

driver.navigate.to 'https://roomy-fire-houseboat.glitch.me/'

driver.find_element(id: 'number').send_keys '2'

driver.find_element(id: 'start').click

sleep 10

Can you try this and let me whether you face any problem.