when the text attribute is set to
text-overflow: ellipsis;
the overflowed text will be displayed as "XX...
" (see screenshot for more )
how can I find the overflowed text/element
in webdriver?
thanks in advance
when the text attribute is set to
text-overflow: ellipsis;
the overflowed text will be displayed as "XX...
" (see screenshot for more )
how can I find the overflowed text/element
in webdriver?
thanks in advance
Probably the easiest/best way to do this is to use the JS innerText
property, e.g.
driver.findElement(lcoator).getAttribute("innerText");
If I remember correctly, some browsers use textContent
instead.
driver.findElement(lcoator).getAttribute("textContent");
This should get you the full text inside that element.
You could also pull innerHTML
and parse it (if needed) or remove the text-overflow
style from the element but these are harder/more complicated.
In case you have jQuery available in your project, you can write your own selector:
$.expr[':'].truncated = function (e) {
// you *might* want to check if css property "text-overflow"
// is set to "ellipsis" as well, to filter other truncations:
return e.offsetWidth < e.scrollWidth;
};
and go from there:
items = $('.your-selector:truncated');
(heavily based on the answers here)