Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 268
P Ghanghar Avatar asked Jul 12 '16 05:07

P Ghanghar


2 Answers

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..:)

like image 138
Saurabh Gaur Avatar answered Oct 11 '22 10:10

Saurabh Gaur


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();
like image 32
kumar Avatar answered Oct 11 '22 08:10

kumar