Automation using selenium is a great experience. It provides many way to identif an object or element on the web page.
But sometime we face the problems of idenfying the objects on a page which have same attributes. When we get more than
one element which are same in attribute and name like multiple check boxes with same name and same id. More than one button having
same name and ids. There are no way to distingues those element. In this case we have problem to instruct selenium to identify a perticular
object on a web page.
I am giving you a simple example . In the below HTML source there are 6 check boxes are there having same type and same name.
It is really tough to select third or fifth.
Thare are some function we can use in Xpath to identify the abject in above cases.
An XPath expression can return one of four basic XPath data types:
* String
* Number
* Boolean
* Node-set
XPath Type : Functions
Node set : last(), position(), count(), id(), local-name(), namespace-uri(), name()
String : string(), concat(), starts-with(), contains(), substring-before(), substring-after(), substring(), string-length(), normalize-space(), translate()
Boolean : boolean(), not(), true(), false(), lang()
Number : number(), sum(), floor(), ceiling(), round()
I will show you how we can use some of these above functions in xpath to identify the objects.
<html>
<body>
<input type='checkbox' name='chk'>first
<br><input type='checkbox' name='chk'>second
<br><input type='checkbox' name='chk'>third
<br><input type='checkbox' name='chk'>forth
<br><input type='checkbox' name='chk'>fifth
<br><input type='checkbox' name='chk'>sixth
</body>
</html>
selenium.click("xpath=(//input[@type='checkbox'])[last()]");
selenium.click("xpath=(//input[@type='checkbox'])[position()=2]");
Click on first link
selenium.click("xpath=(//a[@name='a1'])[position()=1]");
selenium.waitForPageToLoad("80000");
Click on second link
selenium.click("xpath=(//a[@name='a1'])[position()=2]");
selenium.waitForPageToLoad("80000");
Click on last link
selenium.click("xpath=(//a[@name='a1'])[last()]");
selenium.waitForPageToLoad("80000");
Click on thrid link
selenium.click("xpath=(//a[@name='a1'])[position()=3]");
selenium.waitForPageToLoad("80000");
But sometime we face the problems of idenfying the objects on a page which have same attributes. When we get more than
one element which are same in attribute and name like multiple check boxes with same name and same id. More than one button having
same name and ids. There are no way to distingues those element. In this case we have problem to instruct selenium to identify a perticular
object on a web page.
I am giving you a simple example . In the below HTML source there are 6 check boxes are there having same type and same name.
It is really tough to select third or fifth.
Thare are some function we can use in Xpath to identify the abject in above cases.
An XPath expression can return one of four basic XPath data types:
* String
* Number
* Boolean
* Node-set
XPath Type : Functions
Node set : last(), position(), count(), id(), local-name(), namespace-uri(), name()
String : string(), concat(), starts-with(), contains(), substring-before(), substring-after(), substring(), string-length(), normalize-space(), translate()
Boolean : boolean(), not(), true(), false(), lang()
Number : number(), sum(), floor(), ceiling(), round()
I will show you how we can use some of these above functions in xpath to identify the objects.
<html>
<body>
<input type='checkbox' name='chk'>first
<br><input type='checkbox' name='chk'>second
<br><input type='checkbox' name='chk'>third
<br><input type='checkbox' name='chk'>forth
<br><input type='checkbox' name='chk'>fifth
<br><input type='checkbox' name='chk'>sixth
</body>
</html>
selenium.click("xpath=(//input[@type='checkbox'])[last()]");
selenium.click("xpath=(//input[@type='checkbox'])[position()=2]");
Click on first link
selenium.click("xpath=(//a[@name='a1'])[position()=1]");
selenium.waitForPageToLoad("80000");
Click on second link
selenium.click("xpath=(//a[@name='a1'])[position()=2]");
selenium.waitForPageToLoad("80000");
Click on last link
selenium.click("xpath=(//a[@name='a1'])[last()]");
selenium.waitForPageToLoad("80000");
Click on thrid link
selenium.click("xpath=(//a[@name='a1'])[position()=3]");
selenium.waitForPageToLoad("80000");
How to Write in iFrame in selenium
When you write any mail in gmail you can see the body is a iframe we can write in it using
String = selenium.getEval("var bodytext=\" Writing text in iframe body with the help of http://automationtricks.blogspot.com \"; var iframe_locator=\"css=table:contains('Subject:') +* iframe\";
var iframe_body=selenium.browserbot.findElement(iframe_locator).contentWindow.document.body; if (browserVersion.isChrome){
iframe_body.textContent=bodytext;
} else if(browserVersion.isIE){
iframe_body.innerText=bodytext;
}
");
If all check boxes size increasing or decreasing dynamically and all check boxes having same values then how to check each and every check boxes.
ReplyDeleteThis is very informative blog and nice article , I really like your technique of writing a blog. More screenshots gives the clear representation.. I book marked it to my bookmark site list and will be checking back in the near future Selenium Training in Chennai gives you the entire stuff about all the Selenium Components. Among that, the above mentioned IDE is the baby steps to learn other 2 components.
ReplyDeleteHello Ramesh,
ReplyDeleteA nice article here with some useful tips for beginners. Thanks for this helpful information I agree with all points you have given to us. I will follow all of them. Here are some more link which I also useful for freshers.
Free Selenium Tutorials |
Great read, Selenium has brought evolution to automation world.Thanks for taking a time to share a wonderful article.I share this website my office mate and friend circle.I'll be to provide that real-time Selenium Automation Training in Chennai.We having to provide that Latest version selenium 3.0.
ReplyDeleteSelenium Training in Chennai
Real Estate Consultant in Chennai
ReplyDeleteReal Estate Private Equity in India
Real Estate Advisory Companies in India
Real Estate Research in Chennai
Real Estate Tax Advisor in Chennai
Portfolio Management Services in Chennai
Thanks for your correct information,you are providing some good helpful information.
ReplyDeleteOnline Robot Framework Training
Great content thanks for sharing this informative blog which provided me technical information keep posting.
ReplyDeleteHadoop Training in Chennai
Hadoop Training in Bangalore
Big data training in tambaram
Big data training in Sholinganallur
Big data training in annanagar
This is an awesome post.Really very informative and creative contents. These concept is a good way to enhance the knowledge.I like it and help me to development very well.Thank you for this brief explanation and very nice information.Well, got a good knowledge.
ReplyDeletePython training in marathahalli
Python training in pune
AWS Training in chennai
A good blog always comes-up with new and exciting information and while reading I have feel that this blog is really have all those quality that qualify a blog to be a one.I wanted to leave a little comment to support you and wish you a good continuation. Wishing you the best of luck for all your blogging efforts read this.
ReplyDeleteData Science training in Chennai
Data science training in bangalore
Data science training in pune
Data science online training
You know what you’re talking about, why waste your intelligence on just posting videos to your blog when you could be giving us something enlightening to read?
ReplyDeleteindustrial safety course in chennai
You got an extremely helpful website I actually have been here reading for regarding an hour. I’m an initiate and your success is incredibly a lot of a concept on behalf of me.
ReplyDeleteangularjs-Training in sholinganallur
angularjs-Training in velachery
angularjs Training in bangalore
angularjs Training in bangalore
angularjs Training in btm
One of the best blogs that I have read till now. Thanks for your contribution in sharing such a useful information. Waiting for your further updates.
ReplyDeleteFrench Class in Mulund
French Coaching in Mulund
French Classes in Mulund East
German Classes in Mulund
German Language Classes in Mulund
German Classes in Mulund West
German Coaching Center near me
Thanks for sharing this valuable information to our vision. You have posted a worthy blog keep sharing.
ReplyDeletehadoop training in bangalore
hadoop training in bangalore
Big Data Course in Chennai
Big Data Hadoop Training in Chennai
Hadoop Course in Chennai
Thank you for sharing such a nice and interesting blog with us. Hope it might be much useful for us. keep on updating...!!
ReplyDeleteArticle submission sites
Guest posting sites
Excellent strategy and that helped me to get into the next level of the technology.
ReplyDeleteselenium testing course in chennai
selenium course
iOS Training in Chennai
French Classes in Chennai
web designing training in chennai
Big Data Training in Chennai
JAVA J2EE Training in Chennai
JAVA J2EE Training Institutes in Chennai
java training course in chennai
Amazing work. Extra-ordinary way of capturing the details. Thanks for sharing. Waiting for your future updates.
ReplyDeleteSpoken English Classes in Chennai
Best Spoken English Classes in Chennai
Spoken English Class in Chennai
Spoken English in Chennai
Node JS Training in Chennai
Node JS Course in Chennai
Node JS Advanced Training
Node JS Training Institute in chennai
Amazing work. Extra-ordinary way of capturing the details. Thanks for sharing. Waiting for your future updates.
ReplyDeleteSpoken English Classes in Chennai
Best Spoken English Classes in Chennai
Spoken English Class in Chennai
Spoken English in Chennai
Node JS Training in Chennai
Node JS Course in Chennai
Node JS Advanced Training
Node JS Training Institute in chennai
It would have been the happiest moment for you,I mean if we have been waiting for something to happen and when it happens we forgot all hardwork and wait for getting that happened.
ReplyDeletepython Training institute in Pune
python Training institute in Chennai
python Training institute in Bangalore
I have visited this blog first time and i got a lot of informative data from here which is quiet helpful for me indeed.
ReplyDeleteData Science course in rajaji nagar
Data Science with Python course in chenni
Data Science course in electronic city
Data Science course in USA
Data science course in pune | Data Science Training institute in Pune
Data science course in bangalore
Learned a lot from your blog, share more like this.
ReplyDeleteAWS Training in Chennai
DevOps Training in Chennai
Data Science Course in Chennai
ccna course in Chennai
Python Training in Chennai
R Programming Training in Chennai
Angularjs Training in Chennai
RPA Training in Chennai
Blue Prism Training in Chennai
You are an amazing writer. No words to describe your blog. Way to go.
ReplyDeleteXamarin Training in Chennai
Xamarin Course in Chennai
Xamarin Training Course
Xamarin Classes
Xamarin Training in Velachery
Xamarin Training in Tambaram
Xamarin Training in Anna Nagar
Great Article. Wonderful writing. You are an amazing author. Waiting for your future post.
ReplyDeleteIonic Training in Chennai
Ionic Course in Chennai
Ionic Course
Ionic 2 Training
Ionic 2 Course
Ionic Training in Adyar
Ionic Training in Porur
Ionic Training in OMR
Title:
ReplyDeleteNo.1 Oracle Training Institute in Chennai | Infycle Technologies
Get Oracle Certification in Chennai for making your career as a shining sun with Infycle Technologies. Infycle Technologies is the best Oracle training institute in Chennai, providing complete hands-on practical training of professional specialists in the field. In addition to that, it also offers numerous programming language tutors in the software industry such as Big Data, Java, Python, AWS, Hadoop, etc. Once after the training, interviews will be arranged for the candidates, so that, they can set their career without any struggle. Of all that, 200% placement assurance will be given here. To have the best career, call 7502633633 to Infycle Technologies and grab a free demo to know more.
best training institute in chennai
Infycle Technologies, the best software training institute in Chennai offers the best Python training in Chennai for tech professionals and freshers. In addition to the Python Training Course, Infycle also offers other professional courses such as Data Science, Oracle, Java, Power BI, Digital Marketing, Big Data, etc., which will be trained with 100% practical classes. After the completion of training, the trainees will be sent for placement interviews in the top MNC's. Call 7502633633 to get more info and a free demo.
ReplyDeleteWant to do a No.1 Data Science Course in Chennai with a Certification Exam? Catch the best features of Data Science training courses with Infycle Technologies, the best Data Science Training & Placement institutes in and around Chennai. Infycle offers the best hands-on training to the students with the revised curriculum to enhance their knowledge. In addition to the Certification & Training, Infycle offers placement classes for personality tests, interview preparation, and mock interviews for clearing the interviews with the best records. To have all it in your hands, dial 7504633633 for a free demo from the experts.
ReplyDeleteThis post is so interactive and informative.keep update more information...
ReplyDeleteDevOps course in Tambaram
DevOps Training in Chennai
Great post. keep sharing such a worthy information.
ReplyDeleterest api testing training in chennai
api testing training