Selenium Forum: Functional And Regression Testing Tool.
Would you like to react to this message? Create an account in a few clicks or log in to continue.
Search
Display results as :
Advanced Search
Latest topics
AEM Training | Free Online DemoWed Apr 21, 2021 5:45 pmazharuddin
c# PageFactory - issue initializing elementsFri Nov 01, 2019 8:40 pmthegoatboy
Selenium making automatic connection to random urlsMon Jul 08, 2019 12:58 pmrepairtechsolutions1
How can we design the custom framework in Selenium RCMon Jun 24, 2019 2:26 pmrandybonnettes
What are the new features in Selenium 3.0Tue Jun 18, 2019 5:37 pmpappyvicky
What are you using Selenium for? Fri Apr 12, 2019 3:52 amzhl
LIMITATIONS OF SELENIUMWed Apr 10, 2019 11:23 amswara
Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

Go down
avatar
divya_agsrdk
Professional
Professional
Posts : 93
Join date : 2013-01-17

program to provide total number of objects present / available on the page Empty program to provide total number of objects present / available on the page

Wed Mar 20, 2013 3:40 pm
import com.thoughtworks.selenium.*;
@SuppressWarnings("deprecation")
public class objectcount extends SeleneseTestCase {
public void setUp() throws Exception {
setUp("http://www.google.com/","*firefox");
}
public void testloginlogout(){
selenium.setSpeed("1000");
selenium.open("/mail/help/intl/en/logout.html#hl=en");
selenium.waitForPageToLoad("30000");
selenium.windowMaximize();
int num = selenium.getXpathCount("//p").intValue();
System.out.println("The number of option elements present are " +num);
}
}

Here
int num =selenium.getXpathCount("//p").intValue();

what is //p here?

hw to get that
Advisor
Advisor
------------------------
------------------------
Posts : 387
Join date : 2009-07-30
Location : India
https://seleniumforum.forumotion.net

program to provide total number of objects present / available on the page Empty Re: program to provide total number of objects present / available on the page

Thu Mar 21, 2013 8:29 pm
p is the one of the element in HTML known as paragraph where all elements reside into that tag.

this code search for every p tag in view source/Xpath on that basis it will give you number of elements exist on page whether it's image, link, button, text field , list or radio button.

Hope this will help You. best of luck.

bye
avatar
divya_agsrdk
Professional
Professional
Posts : 93
Join date : 2013-01-17

program to provide total number of objects present / available on the page Empty Re: program to provide total number of objects present / available on the page

Wed Mar 27, 2013 1:32 pm
In gmail.com page, i m getting output as 9 objects for the above Program.
i think its not correct it has many objects.
instead of giving //p, how to find all the objects reside on the web page?

here getxpathcount ( ) ---- here wt parameter need to pass. wt it does?
kashyap_guru
kashyap_guru
Active particpant
Active particpant
Posts : 24
Join date : 2013-10-16
Age : 37
Location : India

program to provide total number of objects present / available on the page Empty Re: program to provide total number of objects present / available on the page

Fri Oct 25, 2013 1:38 pm
Can't you identify objects based on "INPUT" tag?

All objects are initialized with INPUT tag only.

EX: storeXpathcount | //input | count

For image and a tag, you need to fire one more command and store it elsewhere.
Sponsored content

program to provide total number of objects present / available on the page Empty Re: program to provide total number of objects present / available on the page

Back to top
Permissions in this forum:
You cannot reply to topics in this forum