0

我在尝试单击表单中的按钮时遇到问题。我试过 xpath、cssselector、className、id,但还是找不到。

这是该按钮的 HTML 片段:

<input type="button" value="Continue" id="ni-reg-btn-register" class="btnNext ni-reg-btn-register">

我在 Java 中使用 WebDriver

获取此跟踪:
org.openqa.selenium.ElementNotVisibleException:元素当前不可见,因此可能无法与命令持续时间或超时交互:30.09 秒

频率:100%

浏览器:火狐

网址:https ://subscription.thetimes.co.uk/webjourney/webj_capturecustomerdetails

我已经一一尝试了以下每一行代码(但没有运气):

driver.findElement(By.className("btnNext ni-reg-btn-register")).click();
driver.findElement(By.cssSelector("buttons#ni-reg-btn-register.btnNext ni-reg-btn-register")).click();
List<WebElement> buttonlist=    driver.findElements(By.className("btnNext ni-reg-btn-register"));
driver.findElement(By.id("ni-reg-btn-register")).click();
driver.findElement(By.xpath("//*[@id="ni-reg-btn-register"]")).click();
4

3 回答 3

0

我能够Continue使用下面的 xpath 来单击按钮。

//input[@id='ni-reg-btn-register']
于 2013-04-30T11:53:37.550 回答
0

我在您提供的页面链接上找不到上述按钮.. 最好检查页面链接并尝试在页面加载后给出一些等待声明...

隐式等待会更好或更简单 Thread.sleep(2000);

于 2013-05-03T07:54:55.303 回答
0

I would suggest trying a WebDriverWait call to wait for the element in question to exist on the page prior to interacting with it. The Java documentation can be found here. It appears that while you are using the correct locator and your page is working, there is a timing issue where Selenium is trying to access the element prior to it being loaded.

EDIT: I was unable to locate an element on the provided page with the supplied id. I assume I am missing a step, but I did a search on the HTML for that page and found nothing.

于 2013-05-01T03:43:47.340 回答