All in One Selenium Cheatsheet
All in One Selenium Cheatsheet
@Test (invocationCount = 3)
@Test (invocationCount = 7, threadPoolSize = 2)
TestNG XML File
<suite name="TestNGSuite" parallel="methods" thread-
count="4">
<listeners>
<listener class-name="packagename.classname"></listener>
</listeners>
<parameter name="Data1" value="10" />
<parameter name="Data2" value="3" />
<test name="TestNGTest">
<groups>
<run>
<exclude name="Test.*" />
<include name="SmokeTest" />
</run>
</groups>
<classes>
<class name="packagename.classname"/>
</classes>
</test> <!-- TestNGTest -->
</suite> <!-- TestNGSuite -->
Author Haradhan Pal
YouTube https://www.youtube.com/c/HaradhanAutomationLi
brary?sub_confirmation=1
Different approach to create XPath and CSS Selector
Description XPath CSS Selector
Whole WebPage /html html
Whole WebPage body /html/body body
image element //img img
Link //a[@href = 'url'] a[href = 'url']
Direct Child //div/a div > a
Id //tagName[@id=’idValue’] tagName#idValue
Class //tagName[@class=’classValu tagName.Value of Class
e’] attribute
Attribute //tagname[@attribute- tagName[attribute=Valu
name=’value1′] e of attribute]
Multiple Attributes //input[@type='submit' and tagname[attribute1='val
@name='btnLogin'] ue1'][attribute2='value2'
]
Contains //*[contains(@type,'sub')] <HTML
tag><[attribute*=sub
String]>
Starts with //tagname[starts- <HTML
with(@attribute, ‘Start tag><[attribute^=prefix
value’)] of the String]>
Ends with //tagname[ends- <HTML
with(@attribute, ‘End value’)] tag><[attribute$=suffix
of the String]>
Matches //*[matches(@type,'value')] N/A