Re: [webdriver] How to get only visible webelement from xpath?

2,386 views
Skip to first unread message

Simon Stewart

unread,
Jun 13, 2012, 5:54:27 AM6/13/12
to webd...@googlegroups.com

Get all the elements using path and then iterate over them, filtering entries by a call to "isDisplayed".

Simon (from a phone)

On Jun 13, 2012 8:47 AM, "mohit khatri" <mohit.k...@gmail.com> wrote:
Hi,

I would like to fetch only those web element which are visible on page using xpath. But in the page source there is no "style" tag present. So how would i get those elements?

I'm using driver.findelement(By.xpath("")). I can get visible elements by driver.findelement(By.xpath("")).isDisplayed() but I don't want to use isDisplayed() method.

I just want to pass xpath of those elements which are visible on page. Below is sample html code of my webpage.

<div class="sdf">
<a rel="nofollow" id="Link_5" href="/abc-html" title="xyz" class="PQR">Button Name</a>
</div>

--
You received this message because you are subscribed to the Google Groups "webdriver" group.
To view this discussion on the web visit https://groups.google.com/d/msg/webdriver/-/tlE7btyyfXwJ.
To post to this group, send email to webd...@googlegroups.com.
To unsubscribe from this group, send email to webdriver+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/webdriver?hl=en.

mohit khatri

unread,
Jun 15, 2012, 1:08:24 AM6/15/12
to webd...@googlegroups.com
Is there any other way without using isDisplayed?
To unsubscribe from this group, send email to webdriver+unsubscribe@googlegroups.com.

Mike Riley

unread,
Jun 15, 2012, 11:36:58 AM6/15/12
to webd...@googlegroups.com
I don't think so, but why would you not want to use that method?

Once you have a list of all the elements, you build up a second smaller list of those that are displayed.  Where is the problem with that?

Mike

suneel kumar

unread,
Nov 5, 2015, 4:49:27 PM11/5/15
to webdriver

isDisplayed() is consuming lot of time. If there is a way to fetch while finding itself, that would be much more faster.
To unsubscribe from this group, send email to webdriver+...@googlegroups.com.

AVINASH NIMBHORE

unread,
Nov 6, 2015, 12:47:27 AM11/6/15
to webd...@googlegroups.com
In that case you can use WebDriverWait to wait for particular element to become visible[By applying ExpectedCondition class].
Here you can set timeout which you feel element may take for loading on page.
 

To unsubscribe from this group and stop receiving emails from it, send an email to webdriver+...@googlegroups.com.

To post to this group, send email to webd...@googlegroups.com.

Nikhil Bhoski

unread,
Nov 6, 2015, 1:43:00 AM11/6/15
to webd...@googlegroups.com
not sure exactly what you are looking at , but did you try using Rendered WebElement instead ..

Regards
NIkhil 
Reply all
Reply to author
Forward
0 new messages