2016-07-12 310 views
5

我是新的selenium webdriver。我正在尝试注册http://way2automation.com/way2auto_jquery/index.phpSelenium Webdriver - 元素不可见

我能够切换到弹出并能够填写所有字段值。但是,当我试着点击提交按钮,它显示例外Exception in thread "main" org.openqa.selenium.ElementNotVisibleException: element not visible

我已经使用的XPath与下面的代码:

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

HTML是:

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

任何帮助将不胜感激。在此先感谢

+0

你能分享你如何切换到该弹出窗口?我已经在这里问它http://stackoverflow.com/questions/41828847/python-selenium-webdriver-cannot-switch-to-registration-pop-up – Yabko

回答

4

正如我在您提供的网站上看到url有两个Submit按钮都存在,所以,当你使用XPath .//*[@id='load_form']/div/div[2]/input它返回两个提交按钮,它去点击第一Submit按钮,这是不可见的形式,所以你应该尝试如下: -

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

希望它会工作.. :)

+0

@PGhanghar你欢迎..很高兴帮助你..: ) –

2

下面的方法成功地为我工作:

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(); 
相关问题