getXpathCount returning 0
Page 1 of 1 • Share •
getXpathCount returning 0
This is my code for finding the row count of a table in a pop up window..I check if the table exists in the pop up window, and it returns me true as well as if a fetch a cell value from the table, then also i am getting a value..but when it try to fetch the row count or column count of the table, it returns value as 0..
What could be the problem..the table exists..but not able to fetch the rowcount..
for (int second = 0;; second++) {
if (second >= 90) fail("timeout");
try { if (selenium.isElementPresent("//html/body/form/div/table/tbody/tr[4]/td/div/div/div/table/tbody/tr[2]/td[2]")){
System.out.println("element present");
String tesstt = selenium.getText("//html/body/form/div/table/tbody/tr[4]/td/div/div/div/table/tbody/tr[2]/td[4]");
System.out.println("tesstt value==>"+tesstt);
if (selenium.isElementPresent("popupFrame"))
{
selenium.selectFrame("popupFrame");
System.out.println("Pop up frame selected");
//Thread.sleep(15000);
int rowCount=selenium.getXpathCount("//html/body/form/div/table/tbody/tr[4]/td/div/div/div/table/tbody/tr").intValue();
System.out.println("rowCount===="+rowCount);}
else
System.out.println("Pop up frame not found");
break; }
}
catch (Exception e) {
System.out.println("Exception: element not present");
}
Thread.sleep(1000);
}
What could be the problem..the table exists..but not able to fetch the rowcount..
for (int second = 0;; second++) {
if (second >= 90) fail("timeout");
try { if (selenium.isElementPresent("//html/body/form/div/table/tbody/tr[4]/td/div/div/div/table/tbody/tr[2]/td[2]")){
System.out.println("element present");
String tesstt = selenium.getText("//html/body/form/div/table/tbody/tr[4]/td/div/div/div/table/tbody/tr[2]/td[4]");
System.out.println("tesstt value==>"+tesstt);
if (selenium.isElementPresent("popupFrame"))
{
selenium.selectFrame("popupFrame");
System.out.println("Pop up frame selected");
//Thread.sleep(15000);
int rowCount=selenium.getXpathCount("//html/body/form/div/table/tbody/tr[4]/td/div/div/div/table/tbody/tr").intValue();
System.out.println("rowCount===="+rowCount);}
else
System.out.println("Pop up frame not found");
break; }
}
catch (Exception e) {
System.out.println("Exception: element not present");
}
Thread.sleep(1000);
}
useroforacle- Posts: 1
Join date: 2010-08-31
Re: getXpathCount returning 0
add Thread.sleep() before getXpathCount
freesky- Amateur

- Posts: 67
Join date: 2011-04-13
Re: getXpathCount returning 0
Hi,
Try to something like this,
int rowCount = (Integer)selenium.getXpathCount("//table[@id='active-reg']/tbody/tr");
System.out.println("rowCount = "+rowCount);
~ Harri...
Try to something like this,
int rowCount = (Integer)selenium.getXpathCount("//table[@id='active-reg']/tbody/tr");
System.out.println("rowCount = "+rowCount);
~ Harri...
mgharikrishnan- Active particpant

- Posts: 10
Join date: 2011-06-20
Smart solution for Webtables
You can use following code
int rowcount=0
while(selenium.iselementPresent("//html/body/form/div/table/tbody/tr[4]/td/div/div/div/table/tbody/true](rowcount+1)+"])){
rowcount++;
}
System.out.println("Total rows -- "+rowcount);
Regards
Ashish
For selenium training visit:
qtpselenium.com/samplevideos/selenium/seleniumvideos.php
int rowcount=0
while(selenium.iselementPresent("//html/body/form/div/table/tbody/tr[4]/td/div/div/div/table/tbody/true](rowcount+1)+"])){
rowcount++;
}
System.out.println("Total rows -- "+rowcount);
Regards
Ashish
For selenium training visit:
qtpselenium.com/samplevideos/selenium/seleniumvideos.php
ashish_techie- Amateur

- Posts: 50
Join date: 2011-08-09
Similar topics» getXpathCount returning 0
» Steps To Take If You Are Returning Your Nextbook
» how to use getXpathCount, isAlertPresent() ,isElementPresent and removeAllSelections
» SEARS Returns Advice
» Reset to original setting WPDN
» Steps To Take If You Are Returning Your Nextbook
» how to use getXpathCount, isAlertPresent() ,isElementPresent and removeAllSelections
» SEARS Returns Advice
» Reset to original setting WPDN
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
» sample webdriver code for php users
» which standalone server to use
» Dynamic Drop Down Selection
» It is possible to find list of all URL's exist in any web page in selenium ide
» It is possible to compare 2 same images in selenium IDE.
» how to compare 2 ULR's which is exist in same web page (View page source).
» Web Driver: Unable to click a link present inside the frame of a frameset
» Help me to get dynamicaly loaded options of dropdown in Selenium RC -Junit test case