繁体   English   中英

实习生框架-LeadFoot-无法找到元素

[英]Intern framework - LeadFoot - unable to locate element

我正在使用Leadfoot实习生框架编写功能测试用例。 测试用例:输入表单字段,然后单击一个按钮,将打开一个引导程序模版。 我要做的就是验证模态上存在的元素的显示属性。

但是,当我尝试通过id'viewBtn'查找元素时,它找不到并抛出:NoSuchElement:[POST http:// localhost:4444 / wd / hub / session / e23a975b60188479d599d2 43505ce9cb / element / 0.1521919297986265-4 / element / {“ using”:“ id”,“ value”:“ viewBtn tBtn”}]没有这样的元素:无法找到元素:{“ method”:“ id”,“ selector”:“ viewBtn”}

define(function (require){
    var registerSuite = require('intern!object');
    var assert = require('intern/chai!assert');

    registerSuite({
        name:'Test Page',
        'Continue':function(){
            return this.remote
             .get(require.toUrl('http://sdfsdfs'))
             .setFindTimeout(5000)
            .findById('to')
            .click()
            .type('john')
            .end()                      
            .findById('from')
            .click()
            .type('man')            
            .end()          
            .findById('message')
            .click()
            .type('hello')
            .end()          
            .findByCssSelector("[name=formName]").findByClassName('btn')
            .click()
            .end()
            .setFindTimeout(5000)
            .findById('viewBtn')
            .isDisplayed()
            .then(function(text){
                assert.equal(text,'true','Not Displayed');
            })
        }
    });
})

;

当元素中存在id时,为什么会引发错误。 我也在每个find方法之后调用end方法。

您似乎未在正确的上下文中搜索。 在下面的代码段中,两个发现和findById之间只有一个end 这意味着findById('viewButton')的上下文是名称为“ formName”的元素(这样, findById仅在name =“ formName”元素内/下搜索),因为只有findByClassName调用已结束:

.findByCssSelector("[name=formName]").findByClassName('btn')
.click()
.end()
.setFindTimeout(5000)
.findById('viewButton')

要搜索整个文档(假设是这样),请调用end(2)结束两个查找。

另外,请注意setFindTimeout是持久性的,因此除非更改值,否则只需调用一次即可。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM