Selenium Webdriver-元素不可见 [英] Selenium Webdriver - Element not visible

查看:225
本文介绍了Selenium Webdriver-元素不可见的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Selenium Webdriver的新手.我正在尝试注册http://way2automation.com/way2auto_jquery/index.php.

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

我可以切换到弹出窗口,并且可以填写所有字段值.但是,当我尝试单击 SUBMIT 按钮时,它显示了异常Exception in thread "main" org.openqa.selenium.ElementNotVisibleException: element not visible

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

我已将Xpath与以下代码结合使用:

I have used Xpath with below code:

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">

任何帮助将不胜感激.预先感谢

Any help will be greatly appreciated. Thanks in advance

推荐答案

我在您提供的网站中看到的 url 存在两个Submit按钮,因此当您使用xPath .//*[@id='load_form']/div/div[2]/input时,它将返回两个提交按钮,然后单击第一个Submit按钮,该按钮在表单上不可见,因此您应该尝试如下:-

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();

希望它会工作..:)

这篇关于Selenium Webdriver-元素不可见的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆