Search code examples
watirpage-object-gem

how to check to see if is in viewpoint


I'm sporadically receiving the following:

Selenium::WebDriver::Error::UnknownError: unknown error: Element <tr _ngcontent-c7="">...</tr> is not clickable at point (1101, 18). Other element would receive the click: <div _ngcontent-c1="" class="col-md-6">...</div>
  (Session info: chrome=64.0.3282.140)
  (Driver info: chromedriver=2.33.506120 (e3e53437346286c0bc2d2dc9aa4915ba81d9023f),platform=Windows NT 6.1.7601 SP1 x86_64)

This occurs from a page that has a table where the rows extend past the viewpoint.

the method that I'm using to select a random row in the table

def get_random_row
  random_row = rand(1..self.policy_results_row_count)
  row = self.policy_results_element.row_element(:index => random_row)
  row.focus
  self.wait_until(10, 'Row not in focus') do
     row.visible?
  end
row.click 
end

Is there a way to check to see if an element within Viewport after #focus?


Solution

  • The fact that it is or is not in the viewport makes no difference inherently. What will make a difference is how the responsive design of the CSS is working for your application at different resolutions. You can change the window size if that makes a difference. If the issue is that there is a static header that the element is hiding under, you can use the excellent watir-scroll gem to move the element out from under the static header.