Re: webdriver : find the count of search results (findElements)

1,018 views
Skip to first unread message

Mike Riley

unread,
Mar 7, 2013, 3:43:43 PM3/7/13
to webd...@googlegroups.com
If your XPath is correct you would get 12, provided all 12 are present in the DOM at the time you do the call.  I can't verify your XPath with seeing it and the HTML, but if Firebug verifies it then it probably is correct.

Is it possible the DOM is not completely built at the time you are doing the search?

You might need to wait until something is present that would only be there after what you are searching for has been completely rendered.

Mike

On Tuesday, March 5, 2013 8:27:34 AM UTC-8, g.laxmi...@gmail.com wrote:
Hi,

I have a  search scenario, where i will be entering some search string based on which i will get the results .

for example : If search for fan --> : i will get some 12 results for fan ..
however when i give something like

xpath of the search results ;--> which is actully poing to 12 results in Firebug :: xpath is correct .

mycode is looks like this :


List<WebElement>Options = driver.findElements(By.xpath("xpath of the search results"));
sysout(Options.size());
which is actually giving results as 5:  which actually supposed to give 12;


onemore point : once the searh is done .. results willbe displayed after doing the scroll .. I mean results comes in scroll.. does it makes any difference .. ?

Pls help me ..




Umamaheshwar Thota

unread,
Mar 8, 2013, 3:09:56 AM3/8/13
to webd...@googlegroups.com
laxmi,

You can get the xpath by using below correctly. By using the below u will not even get the header count. You will get the count of no. of records in the table.

int xpathcount= driver.findElements(By.xpath(xpath>1)).size();
system.out.println(xpathcount)


cheers,
Umamaheshwar Thota
Reply all
Reply to author
Forward
0 new messages