Reputation: 1
I have a selenium code trying to sendkeys()
I am using firefox 35.0.1
and selenium webdriver 2.44
and eclipse Luna
WebDriver d1 = new FirefoxDriver()
d1.get("www.xx.com")
WebElement username=d1.findElement(By.xpath(".//*[@id='login_username']/input"))
WebElement password=d1.findElement(By.xpath(".//*[@id='login-assword']/input"))
username.sendKeys("admin")
password.sendKeys("welcome")
This enters the values and deletes it before I submit the values. tried adding
d1.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS)
Thread.sleep(x);
but nothing is working please help me out.
Upvotes: 0
Views: 365
Reputation:
Try using Thread.sleep after clicking into the text field and then do a sendKeys(). If that doesn't work, try waiting until the document is loaded entirely. See below function:
void waitForPageLoad(WebDriver driver)
{
ExpectedCondition<Boolean> pageLoadCondition = new ExpectedCondition<Boolean>()
{
public Boolean apply(WebDriver driver)
{
return ((JavascriptExecutor)driver).executeScript("return document.readyState").equals("complete");
}
};
wait.until(pageLoadCondition);
}
Upvotes: 1