2015-04-07 111 views
0

尝试使用.type操作失败。这是一个使用角度的Web应用程序,不知道这是否与它有关。Dalek.js未设置元素值

我可以断言属性和元素的存在,而是试图用.TYPE或.setValue失败

下面是测试

module.exports = { 
    'Smoke test app.ablio': function (test) { 
test 
    .open('http://app.ablio.com') 
    .assert.title().is('ablio :: Communication Without Barriers', 'Title OK') 
    .open('https://app.ablio.com/signin') 
    .assert.attr('#sign-in', 'type', 'submit', "submit signin form exists") 
    .assert.exists('#username', "username form field exists") 
    .assert.attr('#username', 'type', 'text', "username form field is type text") 
    .assert.exists('#password', "password form field exists") 
    .assert.attr('#password', 'type', 'password',"password form field is type password") 
    .type('#username', 'testuser') 
    .assert.val('#username', 'testuser', 'Username was entered') 
    .screenshot ('shots/final.png') 
    .done(); 
    } 
}; 

的assert.val()失败:

输出:

dalek smoketest.js 
Running tests 
Running Browser: PhantomJS 
OS: mac 10.10 (Yosemite) 32bit 
Browser Version: 1.9.8 

RUNNING TEST - "Smoke test app.ablio" 
▶ OPEN http://app.ablio.com 
✔ TITLE Title OK 
▶ OPEN https://app.ablio.com/signin 
✔ ATTRIBUTE submit signin form exists 
✔ EXISTS username form field exists 
✔ ATTRIBUTE username form field is type text 
✔ EXISTS password form field exists 
✔ ATTRIBUTE password form field is type password 
▶ TYPE #username 
✘ VAL 
0 EXPECTED: testuser 
0 FOUND: 
0 MESSAGE: Username was entered 
▶ SCREENSHOT shots/final.png 
✘ TEST - "Smoke test app.ablio" FAILED 

6/7 assertions passed. Elapsed Time: 8.55 sec 

DalekJS CLI工具版本:0.0.5 个DalekJS本地安装:0.0.9

+0

好的,经过几个调试会话后,我可以看到Dalek只看到第一个DOM加载,而不是角度加载的DOM。有没有什么方法来等待角度来加载DOM? –

+0

这解决了这个问题,并提供对角度的支持:https://gist.github.com/ryanzec/7546175 –

回答

0

扫描的页面&那里的DOM,系统就会显示你有2个输入与username的ID。这对于一件事是无效的,其次,你试图填充的username是DOM层次结构中的第二个。如果它是第一个,它甚至可以工作,无论DOM无效。

我不认为这是一个角度特定的事情,因为我很难相信Angular本身会生成无效的DOM。

+0

我纠正了双重身份证,并没有帮助。因为第二个输入不是在第一个DOM负载上生成的,而是由角度生成的。 但使用ryanzec action .waitFor(scripts.angular)(http://gist.github.com/ryanzec/7546175)后,它按预期工作。 –