P Ghanghar
P Ghanghar

Reputation: 73

Selenium Webdriver - Element not visible

I am new to selenium webdriver. I am trying to do registration for http://way2automation.com/way2auto_jquery/index.php.

I am able to switch to pop up and able to fill all field values. But when I try to click on SUBMIT button it shows exception Exception in thread "main" org.openqa.selenium.ElementNotVisibleException: element not visible

I have used Xpath with below code:

driver.findElement(By.xpath(".//*[@id='load_form']/div/div[2]/input")).click();

HTML is:

<div class="span_1_of_4" align="center">
<input class="button" type="submit" value="Submit">

Any help will be greatly appreciated. Thanks in advance

Upvotes: 5

Views: 1359

Answers (2)

kumar
kumar

Reputation: 66

The following approach worked successfully for me:

WebElement ele=driver.findElement(By.cssSelector("div#load_box input.button")));
WebDriverwait wb= new WebDriverwait(20,driver)l
wb.until(ExpectedConditions.ElementVisible(ele)));
ele.click();

Upvotes: 2

Saurabh Gaur
Saurabh Gaur

Reputation: 23825

As I see in your provided website url there are two Submit buttons are present, so when you are using xPath .//*[@id='load_form']/div/div[2]/input it returns two submit button and it goes to click on first Submit button which is not visible on the form, So you should try as below :-

driver.findElement(By.cssSelector("div#load_box input.button")).click();

Hope it will work..:)

Upvotes: 4

Related Questions