ferrum: Click on chrome invisible element not work.
Following is a example.

I want to click on all of “全部” in the scroll view, but only 4 of them available, there left 16 “全部” invisible, for make left ones visible, use can move scroll bar or use keyboard page down.
That is, i can find out full 20 “全部” element use click_node = popup.xpath('.//span[contains(text(), "全部")]'),
but only 4 of them can click, others is not clickable, for now, i have to trigger keyboard like this:
while click on invisbile element failed # try click again.
instance.keyboard.type(:pagedown)
sleep
end
but this solution is is crisp , and error-prone, behavior not controllable.
I don’t sure if this is a issue, because i think any element which can retrieve, it should accept browser click event.
Anyway, if this is not a issue, is there exists a robust way to make one invisible element can be visible? (move scroll bar automatically), or do a function, check one element is visible?
Thank you.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 1
- Comments: 16 (16 by maintainers)
we wanna keep ferrum as simple as possible:
https://github.com/rubycdp/ferrum/pull/141#discussion_r561893810
However, I think, it’s nice to have
Ferrum::Node#in_viewport?andFerrum::Node#scroll_into_viewmethods to have a simpler way to handle it without additional cuprite logic.Also see https://stackoverflow.com/a/72717388/322020
I’m doing some issue gardening 🌱🌿 🌷 and came upon this issue. Since it’s quite old and doesn’t seem like a problem with Ferrum (just that OP wants something that is handled by Cuprite). Maybe we can close this issue?
By closing some old issues we reduce the list of open issues to a more manageable set.
That’s exactly my initial thought, Ferrum does things straightforward, no magic. Cuprite is compatible with the other drivers and has some magic inside because in Capybara you click_link and a lot of things happen. I think we can move those little missing pieces from Cuprite but we should never use them as hidden behavior on click, you should do them explicitly.
I think if you use
Cupritedriver it might work because Ferrum appeared from it, and now we are in transition of things from Cuprite to Ferrum and back. First of all there’strigger(:click)method there, and second it uses some JS to move node into viewport before clicking, Ferrum is more straightforward and doesn’t do anything for now. But it’s on my todo list