WebElement password send.key doesnot work | Selenium Training|Java|WebDriver|TestNG|Frameworks|Videos

webElement password send.key doesnot work

M
Post on 29/08/2015

WebElement email= driver.findElement(By.id("Email"));
email.sendKeys("santsah1006@gmail.com");
driver.manage().window().maximize();
WebElement button = driver.findElement(By.name("signIn"));
button.click();
WebElement password = driver.findElement(By.id("Passwd"));
password.sendKeys("xxxxx");


===========Error==============
Exception in thread "main" org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"id","selector":"Passwd"}
Command duration or timeout: 22 milliseconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.47.1', revision: '411b314', time: '2015-07-30 02:56:46'
System info: host: 'Archana', ip: '192.168.181.1', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_45'
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{applicationCacheEnabled=true, rotatable=false, handlesAlerts=true, databaseEnabled=true, version=40.0.3, platform=WINDOWS, nativeEvents=false, acceptSslCerts=true, webStorageEnabled=true, locationContextEnabled=true, browserName=firefox, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}]
Session ID: 10da9f25-98bb-43b7-b160-8761d03e0399
*** Element info: {Using=id, value=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:595)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:348)
at org.openqa.selenium.remote.RemoteWebDriver.findElementById(RemoteWebDriver.java:389)
at org.openqa.selenium.By$ById.findElement(By.java:215)
at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:340)
at practice3.selenium_basic.main(selenium_basic.java:46)
Caused by: org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"id","selector":"Passwd"}
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.47.1', revision: '411b314', time: '2015-07-30 02:56:46'
System info: host: 'Archana', ip: '192.168.181.1', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_45'
Driver info: driver.version: unknown
at <anonymous class>.FirefoxDriver.prototype.findElementInternal_(file:///C:/Users/Archana/AppData/Local/Temp/anonymous146101851973440910webdriver-profile/extensions/fxdriver@googlecode.com/components/driver-component.js:10667)
at <anonymous class>.FirefoxDriver.prototype.findElement(file:///C:/Users/Archana/AppData/Local/Temp/anonymous146101851973440910webdriver-profile/extensions/fxdriver@googlecode.com/components/driver-component.js:10676)
at <anonymous class>.DelayedCommand.prototype.executeInternal_/h(file:///C:/Users/Archana/AppData/Local/Temp/anonymous146101851973440910webdriver-profile/extensions/fxdriver@googlecode.com/components/command-processor.js:12643)
at <anonymous class>.DelayedCommand.prototype.executeInternal_(file:///C:/Users/Archana/AppData/Local/Temp/anonymous146101851973440910webdriver-profile/extensions/fxdriver@googlecode.com/components/command-processor.js:12648)
at <anonymous class>.DelayedCommand.prototype.execute/<(file:///C:/Users/Archana/AppData/Local/Temp/anonymous146101851973440910webdriver-profile/extensions/fxdriver@googlecode.com/components/command-processor.js:12590)

M
Reply on 30/08/2015

Please post URL that which site you referred to automated login page

and

try with the below code

WebElement email= driver.findElement(By.id("Email"));
email.sendKeys("santsah1006@gmail.com");
driver.manage().window().maximize();
WebElement password = driver.findElement(By.id("Passwd"));
password.sendKeys("xxxxx");
WebElement button = driver.findElement(By.name("signIn"));
button.click();

M
Reply on 31/08/2015

NoSuchElementException occurs when selenium cannot find a element. basically your program cannot find the password field.