How to take locators (xpath, etc) in Selenium and check locators in browser before using it in code to minimize the error?

In this video we will show you how to take locators (xpath/CSS Selector/id/name/ link text/class Name/tagName/partial link text) and checking it in browser (debugger tool) to make sure locator is correct and unique. Locators are nothing but exact location of any element on web page.

I hope you like this video. For any questions, suggestions or appreciation please contact us at: or email at:


<input class="input r4 wide mb16 mt8 username" type="email" value="" name="username" id="username" aria-describedby="error" style="display: block;">

How to write locator for above HTML code;
Xpath Syntax: //tagName[@attribute=’value’]
Xpath: //input[@name=’username’]

CSS selector Syntax: Tagname[attribute=’value’]
Tagname#id(id value)   (another syntax)
Tagname.classname (another syntax)
[attribute=’value’] (another syntax)

Css Selector:
Input. input r4 wide mb16 mt8 username
Another example of HTML code:
<span id="category-header-name" class="tax-category__nav--title-name active">Guide Not Allowed</span>
Text() and Contains(text()) syntax:
//htmltag[contains(text(), ‘value’)]
//span[text()=’ Guide Not Allowed’]


import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;

public class RediffE2E {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		System.setProperty("", "C:\\work\\Selenium\\chromedriver_win32_version98\\chromedriver.exe");
		WebDriver driver = new ChromeDriver();
		driver.findElement(By.cssSelector("a[title*='Sign in']")).click();
		driver.findElement(By.xpath("//input[contains(@name, 'procee')]")).click();

Leave a Reply

%d bloggers like this:
Available for Amazon Prime