...">

How to solve timeout error in selenium webdriver with java?

My html

<form id="load_form" class="ajaxsubmit" method="post" action="ajax.php">
<input type="hidden" value="register" name="action">
<h3>Registration Form</h3>
<img id="loader" width="20" height="20" style="display:none;" src="images/loader.gif">
<p id="alert"></p>
<fieldset>
<fieldset>
<fieldset>
<fieldset>
<fieldset>
<fieldset>
<label>Username:</label>
<input type="text" required="" name="username">
</fieldset>

My java code

WebDriverWait wait = new WebDriverWait(driver,30);
WebElement element = wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//input[@name='username']")));
element.sendKeys("john");

Getting below error

An exception in the stream "main" org.openqa.selenium.TimeoutException: Timed after 30 seconds waiting for the visibility of the element located By.xpath: // input [@ name = 'username'] Assembly information: version: "2.53.0", version: '35ae25b', time: '2016-03-15 17:01:03'

Any help? I already tried to increase the wait but it doesn’t work

+4
source share
1 answer

<a > input username, , , , , , cssSelector, : -

WebDriverWait wait = new WebDriverWait(driver,30);

WebElement element = wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("div#load_box input[name = 'username']")));
element.sendKeys("john");
+1

Source: https://habr.com/ru/post/1650997/


All Articles