unable to send data to text field using sendkeys

I’m trying to work on this tutorial http://toolsqa.com/cucumber/first-cucumber-selenium-java-test/

when I try to send data to text field I’m getting an exception ; Exception in thread “main” org.openqa.selenium.InvalidArgumentException: Expected [object Undefined] undefined to be a string.

I’m using the code bellow ;

package CucumberTest;
import java.io.File;

import java.io.IOException;

import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.firefox.FirefoxBinary;

import org.openqa.selenium.firefox.FirefoxDriver;

import org.openqa.selenium.firefox.FirefoxProfile;
public class SeleniumTest1 {
public static void main(String[] args) throws InterruptedException, IOException {

// TODO Auto-generated method stub
//create a new instance of the Firefox driver
WebDriver driver;
System.setProperty("webdriver.gecko.driver","C:\\geckodriver\\geckodriver.exe");
File pathToBinary = new File("C:\\MozillaFirefox\\firefox.exe");

FirefoxBinary ffBinary = new FirefoxBinary(pathToBinary);

FirefoxProfile firefoxProfile = new FirefoxProfile();

driver = new FirefoxDriver(ffBinary,firefoxProfile);
//Put a Implicit wait, this means that any search for elements on the page could take the time the implicit wait is set for before throwing exception

driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
//Launch the online store
driver.get("http://www.store.demoqa.com");

driver.findElement(By.xpath("//a[@class='account_icon']")).click();

System.out.println("Login Successfully");

// Find the element that's ID attribute is 'log' (Username)
// Enter Username on the element found by above desc.
driver.findElement(By.id("log")).sendKeys("testuser_1");
// Find the element that's ID attribute is 'pwd' (Password)
// Enter Password on the element found by the above desc.
driver.findElement(By.id("pwd")).sendKeys("Test@123");
// Now submit the form. WebDriver will find the form for us from the element
driver.findElement(By.id("login")).click();
// Print a Log In message to the screen
System.out.println("Login Successfully");
// Find the element that's ID attribute is 'account_logout' (Log Out)
driver.findElement (By.xpath(".//*[@id='account_logout']/a")).click();
// Print a Log In message to the screen
System.out.println("LogOut Successfully");
// Find the element that's ID attribute is 'account'(My Account)
driver.quit();
}
}

 

 

Default Asked on May 8, 2017 in Selenium WebDriver.
Add Comment
  • 0 Answer(s)
  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.