0

Can anybody help me out of getting tool tip from a tag which is the object location where there is no title or any other attributes that contain the tool tip value. My object location is present in the below tag:

<rect style="cursor: pointer; stroke: rgb(192, 192, 192); stroke-opacity: 0.000001; fill-opacity: 0.000001; fill: rgb(192, 192, 192);" x="634.5" y="46.5" width="50" height="130" rx="1" ry="1" stroke="#c0c0c0" stroke-opacity="0.000001" stroke-width="1" fill-opacity="0.000001" fill="#c0c0c0">

But the tool tip value is "Standard, DLOB, 16,545,429"

  • <rect style="cursor: pointer; stroke: rgb(192, 192, 192); stroke-opacity: 0.000001; fill-opacity: 0.000001; fill: rgb(192, 192, 192);" x="634.5" y="46.5" width="50" height="130" rx="1" ry="1" stroke="#c0c0c0" stroke-opacity="0.000001" stroke-width="1" fill-opacity="0.000001" fill="#c0c0c0"/> – Bunny May 13 '15 at 6:30
  • Did you try with xpath? – Helping Hands May 13 '15 at 10:24
  • Yes I tried with xpath, able to identify the element but unable to get the value from that element. driver.findelement(By.xpath(xpath)).getAttribute("value") returns null and tried with other attributes of the above mentioned element but no use – Bunny May 13 '15 at 14:12
  • Have you read this other SQA question about SVG and tooltips? – user246 May 13 '15 at 15:00
  • Yes I did, but there suggested ways are two. One of them is getAttribute() and other one is JavaScriptExecutor. I have tried with former which have explained earlier but with JavaScriptExecutor, how can we find the tooltip value for this issue? – Bunny May 14 '15 at 9:03
1

The problem is, tooltips are a browser thing (because they are ultimately an OS thing), not a web thing. The tooltip itself isn't attached to the DOM; therefore, webdriver can't "see" it. If the text is generated from something on the DOM, webdriver can read that, but in your example it is not. So there's no way to do this that I'm aware of.

  • Thank You. Uh is there any other way to get the value from any third party tool or any? – Bunny May 13 '15 at 14:09
  • I don't know of any offhand – Yamikuronue May 13 '15 at 14:27
  • Most likely the tooltip is driven by Javascript. When I mouse over Helping Hand's name in their comment to this question, I see a tooltip with their reputation. That's not stored in the anchor element, but it might be somewhere else in the DOM, or it might even the result of an additional server request. – user246 May 13 '15 at 15:01
  • 2
    @user246 It's not a Javascript thing. Their reputation is stored in the "title" attribute of the anchor element; the browser chooses to create atooltip that matches the "title" – Yamikuronue May 13 '15 at 15:19
0

In your code example, you've only given one small part of the svg - the rect. Is this a larger svg that has a tooltip just on the rect? If so, the tooltip is likely generated through javascript. You can get it through the JavaScriptExecutor - but you need to figure out which javascript function to call that will return the correct text.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.