1
votes

I have a div element which turns visible on mouse hover. Is there any way to make it visible with watir-webdriver?

br.div.hover doesnt fail but the element itself is still not visible.

(byebug) @browser.tr.div(:class =>'top-actions').hover
nil
(byebug) @browser.tr.div(:class =>'top-actions').visible?
false
1
Are you sure you are hovering over the right element? The hover events only bubble up, so it is possible that you need to hover over an element within the div. If there is nothing in the div, it might help to show the HTML for the div and related Javascript. It is possible that the div is listening for an event that is not fired by the hover. - Justin Ko
As it appears the div was set visible when hovering over another div on the page. So simply hovering over the other div solved the problem. :) thx. - MichaelR

1 Answers

0
votes

I would say, Yes you can make the object visible. Like as i can imagine in your case the object has a javascript event on 'hover'. You can simply execute a javascript on the div object to change the visible property.

For eg. in Selenium-webdriver --

WebDriver driver = new AnyDriverYouWant(); JavascriptExecutor js; if (driver instanceof JavascriptExecutor) { js = (JavascriptExecutor)driver; } js.executeScript("document.getElementById('someId').visible = true"); OR js.executeScript("document.getElementById('someId').display = block");