The case is the following: there are n panels on a page. Iterate through each panel: click on a specific element, then find the text of its child element which appears only after a click.
I can use methods like .has_css?, but that does not help me here.
Obviously it would be helpful to use find here, but it does not work on Capybara::Node::Element
page.all(:css, panelCss).each do |panel|
counter+=1
if panel.has_css?(elemCss)
Actions.c 'Yay! Found #'+counter.to_s
res = panel.find(:css, elemCss).text #**should be replaced**
end
end
As far as I remember, I have done the same thing in past by combining capybara and jquery, but could not find the decision yet. Brief googling also did not help.
P.S. Of course, I can iterate directly through clickable elements, make a click and then get the text of a child element instead of iterating through their parent panels, but there are 2 reasons:
- I need it for the future code
- there could be more than 1 child element after clicking, so it seems I have to search within page.all node anyway.
finddoesn't work on Capybara::Node::Element?findshould be callable on any element capybara returns and will scope the find to that element. Also what isActions.cdoing? - Thomas Walpole