Reputation: 3225
This is HTML where I try to find selected input
I try to sendkey() to this input like this
String xPath = "//*[@id='id_username']";
WebDriverWait wait = new WebDriverWait(driver, 30);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(xPath))).sendKeys("text");
Always get this error org.openqa.selenium.TimeoutException
. Usually I get this error when element is not visible in setted time.
There is no iframe in entire html.
Which may be the cause?
Upvotes: 1
Views: 2261
Reputation: 193058
You need to consider a couple of points as follows:
String
try to define the xpath as an object of By
.sendKeys()
instead of ExpectedConditions method visibilityOfElementLocated() use elementToBeClickable() method.<input>
try to construct a granular xpathYour code block will be as:
By xPath = By.xpath("//form[@action='/accounts/register/']/fieldset[@class='fieldset_main']//input[@id='id_username' and @name='username']");
new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(xPath)).sendKeys("text");
Upvotes: 1