Show Menu

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.



Driver Initia­liz­ation

Load firefox from different location:­tPr­ope­rty­(“w­ebd­riv­er.f­ir­­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­ndE­lem­ent­(­("q")­).s­end­Key­s("Se lenium 3");
Locating by Name­ndE­lem­ent­(­me(­"­q")).se­ndKeys ("Se­lenium 3");
Locating by Xpath­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­­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­ndE­lem­ent­(­ass­Nam­e("p­rof­ile­hea­der­"));
Locating by TagName­ndE­lem­ent­(By.ta­gNa­me(­"­sel­ect­")).C lick();
Locating by LinkText­ndE­lem­ent­(­nkT­ext­("NextP age"­)).c­li­ck();
Locating by Partia­lLi­nkText­ndE­lem­ent­(­rti­alL­ink­Tex­t(" NextP")­).c­lick();

Selenium Navigators

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


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

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