jeudi 14 juin 2018

ElementNotVisibleError when using headless chrome for testing in rails

I test following assumption And I click on the text "2018/2019" within ".year" with capybara/headless_chrome and constantly get the error

element not visible
    (Session info: headless chrome=67.0.3396.87)
    (Driver info: chromedriver=2.40.565386 (45a059dc425e08165f9a10324bd1380cc13ca363),platform=Mac OS X 10.13.5 x86_64) (Selenium::WebDriver::Error::ElementNotVisibleError)

I've already tried to adjust the window size, as suggested here. But it didn't work. My step definition:

When(/^(?:|I )click on the text "([^"]*)"(?: within "([^"]*)")?$/) do |link, selector|
  begin
    page.find(:css, selector).click
  end
end

The element is actually visible and found by Capybara

enter image description here

[1] pry(#<Cucumber::Rails::World>)> page.find(:css, ".year")
    => #<Capybara::Node::Element tag="a" path="/html/body/div[2]/div[2]/section/div[2]/div/div[1]/div[1]/div[2]/div/div[2]/ul/li/a">

But click fails

[2] pry(#<Cucumber::Rails::World>)> page.find(:css, ".year").click
    Selenium::WebDriver::Error::ElementNotVisibleError: element not visible

Why doesn't click work here?

Aucun commentaire:

Enregistrer un commentaire