0

I tried entering text in textarea using driver.findElement(By.classname("aoT")).sendKeys("hello") but it is throwing an exception Expected [object Undefined] undefined to be a string.

public class Test_sele {
static WebDriver driver;
public static void main(String[] args) throws InterruptedException {
    System.setProperty("webdriver.gecko.driver","C:\\ffdriver\\geckodriver.exe");
    driver = new FirefoxDriver();
    driver.get("https://www.gmail.com");
    Thread.sleep(20000);
    WebElement compose = driver.findElement(By.className("z0"));
    compose.click();
    Thread.sleep(10000);
    //WebElement to = driver.findElement(By.className("aoT"));
    //System.out.println(to);
    //to.sendKeys("na");
    //to.click();
    //to.sendKeys("na");
    driver.findElement(By.className("aoT")).clear();
    driver.findElement(By.className("aoT")).sendKeys("hello");
    driver.close();

}

}

Please help me out with other alternative or some modification Thanks

1
  • why revert an edit that improves your post formatting? just curious. Commented May 9, 2017 at 9:14

2 Answers 2

2

This could be a problem of the Selenium and Firefox version you are using. Try downgrading Firefox and use the latest version of the gecko driver.

Try the following code:

driver.findElement(By.name("to")).click();
Thread.sleep(1000);
driver.findElement(By.name("to")).clear();
driver.findElement(By.name("to")).sendKeys("[email protected]");
Sign up to request clarification or add additional context in comments.

Comments

0

Try using

driver.findElement(By.xpath("xpath for your element")).clear();
driver.findElement(By.xpath("xpath for your element")).sendKeys("test");

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.