1

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
1
  • Can you share HTML dom structure? May 2, 2017 at 14:40

1 Answer 1

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....

0

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.