单击提交按钮在Selenium Webdriver中不起作用 [英] click on submit button not working in selenium webdriver
问题描述
我试图单击注册表格中的创建帐户"按钮. 按钮在html页面中的定位方式如下:
I trying to click on the create account button in registration form. this is how the button locate in the html page:
<div id="submitContainer"><button type="submit" class="large"><span><strong> Create Account </strong></span></button></div>
这是按钮xpath:
//*[@id="submitContainer"]/button/span/strong
问题是按钮没有id,他位于div内. 我尝试使用id,xpath,css,name来使用,但是所有这些都不起作用:
the problem is that the button don't have id, he locate inside a div. I try to use by id,xpath,css,name, but all of this not working:
driver.findElement(By.id("submitContainer")).click();
driver.findElement(By.xpath("//*[@id='submitContainer']/button/span/strong")).click();
driver.findElement(By.tagName("Create Account")).click();
driver.findElement(By.className("large")).click();
谢谢!
推荐答案
在您的示例中,除了最后一个示例之外,您并未将按钮定位为目标.现在,您的最后一个示例实际上应该找到按钮元素:
In your examples, except for the last one, you are not targeting the button. Now your last example, should actually locate the button-element:
driver.findElement(By.className("large")).click();
能否请您发布您收到的错误消息?
Could you please post the error message you are getting?
页面上是否有一个className为"large"的元素?
Are there more than one element on the page with className "large"?
这篇关于单击提交按钮在Selenium Webdriver中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!