Cheatography
https://cheatography.com
Locators
ID |
Name |
Link Text |
CSS Selector - Tag and ID, Tag and Class, Tag and Attribute, Tag ID Class and Attribute , Inner Text |
DOM - GetElementById, GetElementByName,dom:name,dom:index |
XPATH |
Implicit Wait Vs Explicit Wait Vs Fluent Wait
This wait can be considered as element detection timeout. Once defined in a script, this wait will be set for all the Web Elements on a page. |
This wait can be considered as conditional wait, and is applied to a particular Web Element with a condition |
Selenium keeps polling to check whether that element is available to interact with or not. |
WebDriverWait wait = new WebDriverWait(Driver, 90); |
Driver.manage().timeouts().implicitlyWait(90, TimeUnit.SECONDS); |
wait.until(ExpectedConditions.visibilityOfElementsLocatedBy(By.xpath("//input[@type='text']"))); |
Fluent Wait you have an element which sometime appears in just 1 second and some time it takes minutes to appear. In that case it is better to use fluent wait, as this will try to find element again and again until it find it or until the final timer runs out.
Browser Commands
Get command |
Get Title Command |
Get current Url Command |
Get Page Source Command |
Close Command |
Quit Command |
Refresh Command |
testNG Annotations
@Test |
@BeforeMethod |
@AferMethod |
@BeforeClass |
@BeforeGroup |
@AfterGroup |
@BeforeTest |
@AfterTest |
@BeforeSuite |
@AfterSuite |
|
|
Web Element Commands
Elements can be found by using |
By Id |
By Name |
By Class Name |
By Tag Name |
By Link Text |
By Partial Link Text |
By CSS |
By Xpath |
findElement Vs findElements
Returns a single WebElement |
Returns List of WebElements. |
Syntax: WebElement findElement(By by) |
Syntax: java.util.List<WebElement> findElements(By by) |
Exception :NoSuchElementException |
Exception:emptyListofWebElementObject |
Browser Navigation Commands
To Command |
Refresh Command |
Back Command |
Forward Command |
Switch Commands
driver.switchTo.window("WindowName") |
driver.switchTo.frame("FrameName") |
driver.SwitchTo.alert() |
Difference between '/' and '//'
Single Slah '/' -> Look for the element immediately inside its parent element |
Eg : Absolute path :/html/body/form/div/div[3]/[p1]/a |
Double Slah '//' -> Look for any child or grand child inside parent element |
eg: Releative path ://*[@id:loginform][p1]/a |
DropDown
selectByVisibleText |
selectByIndex |
selectByValue |
|
|
|
Created By
Metadata
Favourited By
Comments
No comments yet. Add yours below!
Add a Comment
Related Cheat Sheets