Selenium chromedriver 要使用cucumber/selenium单击按钮吗

Selenium chromedriver 要使用cucumber/selenium单击按钮吗,selenium-chromedriver,cucumber-jvm,Selenium Chromedriver,Cucumber Jvm,我不熟悉黄瓜测试。我想要一个帮助,其中的网页包含一个按钮,我想点击。我尝试了以下可能的方法: (1) findElement(By.xpath(“//按钮[包含(text(),'addnew')])))”)。单击() (2) driver.findElement(By.linkText(“添加新”))。单击() (3) driver.findElement(By.xpath(“//按钮[@ng click='addNewSelection*'))).click() (4) String str=

我不熟悉黄瓜测试。我想要一个帮助,其中的网页包含一个按钮,我想点击。我尝试了以下可能的方法:
(1) findElement(By.xpath(“//按钮[包含(text(),'addnew')])))”)。单击()
(2) driver.findElement(By.linkText(“添加新”))。单击()
(3) driver.findElement(By.xpath(“//按钮[@ng click='addNewSelection*'))).click()
(4) String str=driver.findElement(按.tagName(“按钮”)).getAttribute(“ng单击”)
(5) 字符串productHref=driver.findElement(By.partialLinkText(“属性”)).getAttribute(“href”)
(6) findelelement(By.xpath(“//html/body/header/nav/ol/li[2]/a”))。单击();

上述措施都不起作用。这是我的html:

    <button class="btn btn-default om-add-new-btn ng-binding" ng-click="addNewSelection()">Add New</button>

添加新的

Selenium为cucumber测试提供了一个非常棒的web驱动程序,但是对于测试步骤来说,它可能是一个相当冗长和复杂的工具

我会彻底推荐使用水豚宝石为任何网络相关的步骤

然后,配置后,您只需使用以下代码单击按钮:

click_button('Add New')

我希望这有帮助

感谢Pheonexx的帮助,但在我的公司,我只需要使用angularjs。我花了2天的时间做这个,但仍然找不到解决方案。我进一步研究,发现它可以用angularjs量角器工作。我试过了。但是当我尝试使用element(by.model('model')).sendKeys('AD');)访问元素时,仍然出现此错误:失败:1)块消息描述:未知错误:未知错误:未定义角度(会话信息:chrome=43.0.2357.134)(驱动程序信息:chromedriver=2.15.322448(52179c1b310fec1797c81ea9a20326839860b7 d3),平台=Windows NT 6.3 x86_64)堆栈跟踪:未知错误:未定义角度(会话信息:chrome=43.0.2357.134)