Am unable to click on element after executing a First test second test showing a org.openqa.selenium.NoSuchElementException . My code Here:

public class snapooh {
WebDriver driver; 

public void setup() throws Exception {
     driver =new FirefoxDriver();
     driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
     driver.get(" http://abc/sptest/home ");
     System.out.println("Page Launched");

public void login(){
    driver.findElement(By.id("emailaddress")).sendKeys("[email protected]");
  System.out.println("Login button pressed");

public void campaign() throws Exception {

      driver.findElement(By.xpath(" .//*[@id='homeMainContainer']/div[1]/div/div/div[1]/div/ul/li[4]/a")).click();
    //DateWidget Start date and end date

    driver.findElement(By.xpath("  .//*[@id='campnStartInput']")).click();
        WebElement   datepicker = driver.findElement(By.id("ui-datepicker-div"));  
        List<WebElement> rows=  datepicker.findElements(By.tagName("tr"));  
        List<WebElement> columns= datepicker.findElements(By.tagName("td"));  

                        for (WebElement cell: columns){  
                            //Select 20th Date   
                            if (cell.getText().equals("16")){  

                        driver.findElement(By.xpath("   .//*[@id='campnEndInput']")).click();
                        WebElement   datepicker1 = driver.findElement(By.id("ui-datepicker-div"));  
                        List<WebElement> rows1=  datepicker1.findElements(By.tagName("tr"));  
                        List<WebElement> columns1= datepicker1.findElements(By.tagName("td"));  
                        for (WebElement cell: columns1){  
                        //Select 20th Date   
                            if (cell.getText().equals("29")){  

    System.out.println("Campaign created");



My Error Trace here :

 org.openqa.selenium.NoSuchElementException: Unable to locate element:   {"method":"id","selector":"usrUtils"}
 Command duration or timeout: 10.08 seconds
 For documentation on this error, please visit:  http://seleniumhq.org/exceptions/no_such_element.html
 Build info: version: '2.53.0', revision: '35ae25b', time: '2016-03-15 17:00:58'
 System info: host: 'Akshay-PC', ip: '', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.7.0_80'
 *** Element info: {Using=id, value=usrUtils}
 Session ID: d2fcc233-1bb7-435c-ad51-c8958cba421c
 Driver info: org.openqa.selenium.firefox.FirefoxDriver
  • Selenium is not able to find the element. Either check the selector that you have used, or if the element appears after some time, then apply a wait and then do whatever you want to do with it. Jun 17, 2016 at 7:19

5 Answers 5


After you clicked loginenter button, some wait should be added to reload page. It will provide small delay which is helpful for SeleniumDriver to identify element. I would like to suggest you to add some condition to wait next element. Please try below code snippet

WebElement myDynamicElement = 
(new WebDriverWait(driver, 10)).until(ExpectedConditions.presenceOfElementLocated(By.id("usrUTils")));

You should wait for page load after click on button,so for that write below code :

WebElement element;
Webdriver driver;
WebDriverWait wait = new WebDriverWait(driver, 100);
element= wait.until(ExpectedConditions.elementToBeClickable(By.id("usrUtils")));

Why exception arise?

The reason behind the exception you have mentioned is because with your test script you are trying to locate an element that doesn't exist in the webpage you are trying to test.

How to resolve?

Well, along with the text you have provided, the console would also have given the line number in the test script where this exception occurred. I would go to that line in the test script and check what I've done wrong.

  • Assert with text or element to ensure you are on expected page/screen
  • I will suggest to use wait.untill(element.isVisible()) before Click() /Assert()
  • Have I provided a wrong value for searching the element?
  • Is the method wrong?
  • Am I missing something?

If answer to all these question is No and the element is indeed available in the webpage, I would apply implicit or explicit wait in the script to allow Selenium to wait for the element to load and then read it.

You can find the tutorials for implicit and explicit waits on the official Selenium website.

@Jagannatha, see if this works for you


I am not sure if this question is resolved, but I would like to share my thoughts. In TestNG, a method under @Test execute arbitrary or alphabetically. So, I believe the second method would execute first and hence dont find the element. You could try using "priority" attribute in @Test. I hope this helps. Thank you.


I wonder how you even able to open the application?

Because you have an empty space in side string many places.

Problem #1

Change from : driver.get(" ");

to : driver.get("");

Problem #2

Change from:

driver.findElement(By.xpath(" .//*[@id='homeMainContainer']/div[1]/div/div/div[1]/div/ul/li[4]/a")).click();

to :


Problem #3

Change from :

driver.findElement(By.xpath("   .//*[@id='campnEndInput']")).click();

to :


Hope this helps. If you still have issues, then update the question with your html code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.