Reputation: 13
Recently I am upgrading my watir-webdriver frame work currently it is Watir-wedbriver0.8.0 and Firefox 40. After it's done , found span.text can't output the part which is invisible by scroll bar. here is an example, here is a datagrid, it is a spancollection. I want to loop all values in datagrid and output them, but finally only the values which can be viewed in one screen is output. if change the solution of windows to make the scroll bar missing and all values is viewed in one screen, it will output all. But class_name can work normally. Any one have solution about this?
Code is here:
table_row_spans = @browser.get_current_frame_span(header_span_id).spans
table_row_spans.each do |table_cell|
puts table_cell.text
puts table_cell.class_name
end
Upvotes: 1
Views: 139
Reputation: 1
Try the following method ;) The following method scrolls a particular element, which exists within a div (e.g. a grid div id), into view. This method moves the element into view by moving the scroll bar. Therefore it is important to find the iv_id that the particular scroll bar belongs to. The element_to_scroll_to is the actual object whose location will be scrolled into view.
def scoll_div_element_into_view(div_id, element_to_scroll_to)
# Find the x and y coordinate of the element.
wd_point = element_to_scroll_to.wd.location
# Scroll to it.
execute_script('document.getElementById(arguments[0]).scrollTo(arguments[1],arguments[2]);', div_id, wd_point.x, wd_point.y)
end
Upvotes: 0
Reputation: 474161
You might solve it by scrolling into view of the last span element in the list:
browser.execute_script('arguments[0].scrollIntoView();', table_row_spans.last)
Or, do it for every matching element:
table_row_spans.each do |table_cell|
browser.execute_script('arguments[0].scrollIntoView();', table_cell)
puts table_cell.text
puts table_cell.class_name
end
Upvotes: 1