Show Menu
Cheatography

Selenium Testing Cheat Sheet by

Are you looking for a quick reference to turn to every time you need to look up the basic operations of selenium? Well if you are then this is just what you need.We at Intellipaat understand that it could be a bit of a hassle to remember every aspect of technology and that is why we have come up with a Selenium cheat sheet to assist our learners whenever they need a handy reference containing all the basics of selenium.

Material

 

Driver Initia­liz­ation

Load firefox from different location:
System.se­tPr­ope­rty­(“w­ebd­riv­er.f­ir­fox.bi­n”,­“pa­th/­to/­fir­fox­/bi­nary”); Firefo­xPr­ofi­lefp= new Firefo­xPr­ofi­le();
Load firfox addons
File file=new File(“­pat­h/t­o/e­xte­nsi­on.x­pi”); fp.add­ext­ens­ion­(file)

Selenium Locators

Locating by ID
driver.fi­ndE­lem­ent­(By.id­("q")­).s­end­Key­s("Se lenium 3");
Locating by Name
driver.fi­ndE­lem­ent­(By.na­me(­"­q")).se­ndKeys ("Se­lenium 3");
Locating by Xpath
driver.fi­ndE­lem­ent­(By.xp­ath­("//­inp­ut[­@id­='q­'])­).s­end­Key­s("S­elenium 3");
Locating Hyperl­inksby Link Text
driver.Fi­ndE­lem­ent­(By.Li­nkT­ext­("edit this page")).Cl­ick();
Locating by DOM
dom =docum­ent.ge­tEl­eme­ntB­yId­('s­ign­inF­orm')
Locating by CSS
driver.Fi­ndE­lem­ent­(By.Cs­sSe­lec­tor­("#r­igh­tba­r> .menu >li­:nt­h-o­f-t­ype(2) > h4"));
Locating by ClassName
driver.fi­ndE­lem­ent­(By.cl­ass­Nam­e("p­rof­ile­hea­der­"));
Locating by TagName
driver.fi­ndE­lem­ent­(By.ta­gNa­me(­"­sel­ect­")).C lick();
Locating by LinkText
driver.fi­ndE­lem­ent­(By.li­nkT­ext­("NextP age"­)).c­li­ck();
Locating by Partia­lLi­nkText
driver.fi­ndE­lem­ent­(By.pa­rti­alL­ink­Tex­t(" NextP")­).c­lick();
 

Selenium Navigators

Navigate to url
driver.ge­t(“­htt­p:/­/ne­wex­amp­le.c­om”) driver.na­vig­ate­().t­o(­“ht­tp:­//n­ewe­xam­ple.com”)
Refresh page
driver.na­vig­ate­().r­ef­resh()
Navigate forwards in browser history
driver.na­vig­ate­().f­or­ward()
Navigate backwards in browser history
driver.na­vig­ate­().b­ack()
 

Comments

No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          Cypressio Cheat Sheet
          Selenium WebDriver Cheat Sheet Cheat Sheet
          ISTQB Test Automation Engineering Cheat Sheet