Click here to Skip to main content
15,887,027 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
C#
Exception in thread "main" org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"xpath","selector":"//*[@id='Passwd']"}
Command duration or timeout: 13 milliseconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.48.2', revision: '41bccdd', time: '2015-10-09 19:55:52'
System info: host: 'Sheetal', ip: '192.168.1.20', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_40'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{applicationCacheEnabled=true, rotatable=false, handlesAlerts=true, databaseEnabled=true, version=43.0.4, platform=WINDOWS, nativeEvents=false, acceptSslCerts=true, webStorageEnabled=true, locationContextEnabled=true, browserName=firefox, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}]
Session ID: 301cb82d-2ba9-4c3f-924f-7283ea73f919
*** Element info: {Using=xpath, value=//*[@id='Passwd']}
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
	at java.lang.reflect.Constructor.newInstance(Unknown Source)
	at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)
	at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
	at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:647)
	at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:353)
	at org.openqa.selenium.remote.RemoteWebDriver.findElementByXPath(RemoteWebDriver.java:490)
	at org.openqa.selenium.By$ByXPath.findElement(By.java:361)
	at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:345)
	at GmailLogin.main(GmailLogin.java:19)
Caused by: org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"xpath","selector":"//*[@id='Passwd']"}
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.48.2', revision: '41bccdd', time: '2015-10-09 19:55:52'
System info: host: 'Sheetal', ip: '192.168.1.20', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_40'
Driver info: driver.version: unknown
	at <anonymous class>.FirefoxDriver.prototype.findElementInternal_(file:///C:/Users/PC-4/AppData/Local/Temp/anonymous855050823488946320webdriver-profile/extensions/fxdriver@googlecode.com/components/driver-component.js:10659)
	at <anonymous class>.FirefoxDriver.prototype.findElement(file:///C:/Users/PC-4/AppData/Local/Temp/anonymous855050823488946320webdriver-profile/extensions/fxdriver@googlecode.com/components/driver-component.js:10668)
	at <anonymous class>.DelayedCommand.prototype.executeInternal_/h(file:///C:/Users/PC-4/AppData/Local/Temp/anonymous855050823488946320webdriver-profile/extensions/fxdriver@googlecode.com/components/command-processor.js:12534)
	at <anonymous class>.DelayedCommand.prototype.executeInternal_(file:///C:/Users/PC-4/AppData/Local/Temp/anonymous855050823488946320webdriver-profile/extensions/fxdriver@googlecode.com/components/command-processor.js:12539)
	at <anonymous class>.DelayedCommand.prototype.execute/<(file:///C:/Users/PC-4/AppData/Local/Temp/anonymous855050823488946320webdriver-profile/extensions/fxdriver@googlecode.com/components/command-processor.js:12481)


What I have tried:

C#
import java.util.concurrent.TimeUnit;

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

public class GmailLogin {

	public static void main(String[] args) {

		WebDriver driver = new FirefoxDriver();
		driver.get("http://gmail.com");
		driver.findElement(By.id("Email")).sendKeys("MYEMAILID");
		driver.findElement(By.id("next")).click();
		
		driver.findElement(By.xpath("//*[@id='Passwd']")).sendKeys("MYPASSWORD");
		driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
		
		driver.findElement(By.id("signIn")).click();
		
		//driver.findElement(By.name("Passwd")).sendKeys("123");
		//WebElement username = driver.findElement(By.id("Email"));
		//username.sendKeys("MyEmailID");

	}

}
Posted
Updated 4-Feb-16 22:39pm
v2
Comments
jimmson 5-Feb-16 4:59am    
Did you even read error message? You have an explanation on the first line you sent..
Pratikde01 5-Feb-16 5:26am    
i read that error but i don't understood why it is not recognizing xpath value??
jimmson 5-Feb-16 5:56am    
Did you try to use By.id("Passwd")? Not sure why it's not working with xpath, it seems valid.
Pratikde01 5-Feb-16 6:00am    
yes i used By.id("Passwd") and By.name("Passwd") also as you can see i have comment that bt it is not working
jimmson 5-Feb-16 6:07am    
Try to add some timeout after clicking to 'next' button. Please look at this: http://stackoverflow.com/a/20093953

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900