0

While trying the below code

driver.findElement(By.id("txt_UserName")).click();
driver.findElement(By.xpath(".//*[@id='txt_UserName'][@name='txt_UserName'][@class='formInput']")).sendKeys(new String("karthik"));
driver.findElement(By.name("txt_Password")).clear();

I am getting the following error :

Exception in thread "main" org.openqa.selenium.InvalidArgumentException: Expected [object Undefined] undefined to be a string
  • Can you share HTML dom structure? – saurabhguptacse May 2 '17 at 14:40
4

It seems that you have mismatched your coding standards.

WebElement userName= driver.findElement(By.id("txt_UserName"));
userName.clear();
userName.sendKeys("karthik");

WebElement paswd= driver.findElement(By.id("txt_Password"));
paswd.clear();
paswd.sendKeys("Enter your Password");

paswd.submit();

Confirm once your locators of Username & Password field and use it in above code....

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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