Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Capybara webkit driver found overlaps element, how can I click one of them?

Capybara webkit driver see my css incorrectly. It sees(displays) my button overlaps another button, while selenium driver got no problem.

Is there anyway I can click on it? may be execute script or something?

like image 867
Tanapat Sainak Avatar asked Jun 17 '14 09:06

Tanapat Sainak


1 Answers

With Capybara you can trigger click events instead of directly clicking on an element like so:

page.find("#some_element").trigger("click")

The problem is this doesn't work in Selenium. So what you can do is conditionally perform a standard capybara click or a trigger("click") based on the current javascript driver, which would look something like:

if Capybara.javascript_driver == :selenium
  page.find("#some_element").click
else
  page.find("#some_element").trigger("click")
end

Obviously this is less than ideal, but it's the best way I've found to deal with situations like these.

like image 94
Shane O'Connor Avatar answered Nov 16 '22 04:11

Shane O'Connor