使用Nightwatch无法点击模式中的元素
我正在用Nightwatch写一些testing,而且我在testing的最后,我有1个问题,我不明白。 我有一个button提交的东西,然后当他们点击提交,一个模式popup,询问他们是否确定。 我试图点击“是的,我确定”,但是守夜人没有find这个元素。 以下是我的代码。
点击提交button(这工作)
.getLocationInView('#objective-content-intro > div > div > div > div:nth-child(4) > div > div:nth-child(8) > div > div > a') .assert.visible('#objective-content-intro > div > div > div > div:nth-child(4) > div > div:nth-child(8) > div > div > a') .click('#objective-content-intro > div > div > div > div:nth-child(4) > div > div:nth-child(8) > div > div > a')
点击“是,我确定”button(这不起作用)
.getLocationInView('body > div.sweet-alert.hiddenField.showSweetAlert.visible > div.sa-button-container > div > button') .assert.visible('body > div.sweet-alert.hiddenField.showSweetAlert.visible > div.sa-button-container > div > button') .waitForElementPresent('body > div.sweet-alert.hiddenField.showSweetAlert.visible > div.sa-button-container > div > button', 3000, 'Click on \"Yes, submit it!\"') .pause(3000) .click('body > div.sweet-alert.hiddenField.showSweetAlert.visible > div.sa-button-container > div > button')
我只是得到一个错误,说它无法find元素。
尝试这个
.waitForElementPresent('#location > of > modal',20000, 'Some message here to show while running test') .pause(1000) .execute(function(){ document.querySelector('body > div.sweet-alert.hiddenField.showSweetAlert.visible > div.sa-button-container > div > button').click() });
- 如何在nightwatchjs项目中使用npm模块
- 如何在使用NightwatchtestingNode.js项目时在Travis CI上运行Selenium Server
- 用于Nightwatch.js的MongoDB数据库清理程序
- NightWatch – 无法在具有值的input上find具有xpath定位器的元素
- 如何让Nightwatch.js在Internet Explorer上运行testing
- 期望元素不包含文本
- NemoJs vs NightWatchJS? 的优点和缺点
- 运行Nightwatch.jstesting时如何获得当前运行testing的浏览器名称?
- 使用NightWatchJStesting脚本进行条件testing