Question

I have to print the hover box information content on to stdout and i tried it in the below fashion it didn't work for me .

data = $browser.div(:class => "homeSectionLabel textWidget",:text => /Pool A/ ).hover

print "Data  #{data} \n"

And the other problem that i have other widget called Pool B with same class name . How to access that hover information

<div class="widgetContainer poolContainer">
<div class="healthBadge healthUnknown" style="top: -5px; left: -5px;"></div>
<div class="homeSectionLabel textWidget">Pool‌·A</div>
<div class="perfDisplay homePoolPerf">
</div>
<div class="homePoolVolText textWidget">9‌·Volumes,‌·0‌·Snapshots</div>
<div class="spaceMeterContainer poolMeter" style="width: 265px; height: 20px;">
</div>
<table class="tableWidget homeTiers" cellspacing="0" cellpadding="0" border="0">
</table>
</div>

Anyhelp is really appreciated .

Thanks!
Aditya

Was it helpful?

Solution

This is not much of an answer at the moment, but what I have to say won't fit in a comment

The 'content' as in the text within a div is normally accessed with the .text method

'tooltip' text can be done in a number of ways, it could be via alt attributes, it could be via javascript triggered via an 'onmouseover' event, or it could be CSS driven usually via the :hover psuedoclass.

if a div is merely changing it's display property or location so that it becomes visible to the user, then all you need to do is figure out how to locate that div, and get the .text from it

mydata = browser.div(:how => 'what').text

If the content of the div (or some other container) is changing as a result of the mouseover/hover, then you need to simulate the action, wait a brief bit to allow client side code to run, and THEN get the .text from the container that was changed.


Without seeing a page that has the code working on it, it is hard to tell which is the case, although given that I see nothing like 'onmouseover' in the code you supplied, my first bet would be on this being CSS driven.

The code you have above is returning the result of the div object executing the .hover method, and that is going to be nil as far as I know since that method causes something to happen, but does NOT return a value.

Is the 'Pool A' the text you are trying to capture, or is it what you mouse_over to cause the other text to become visible to the user? If it is what you mouseover, then have you searched the HTML to see if you can find the text that appears in some other div?

If you just need to get the text from every div of a given class, then try something like this

browser.divs(:class => "homeSectionLabel textWidget").each do |div|
  puts div.text
end

OTHER TIPS

Based on the most recent comment, this will gather the class names from all of the divs on the page and print it to the console.

$browser.divs.each do |div|
puts div.class
end

Replace "puts div.class" with a file directive if you want it in a file. Any output here is simple Ruby.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top