目前我正在嘗試使用zombie.js爲我的網站運行自動化測試。現在我正在努力讓一個人自動註冊。對於註冊表單使用3周不同的div看起來像這樣Zombie.js Button not enabled
頁代碼:
<form>
<div id=step1>
<div id=step2>
<div id=step3>
</form>
...
...
<button id="nextStep" class="btn btn-primary" role="button"
onClick="signupNext()">Cnt. </button>
SignupNext是一個JavaScript函數,它禁用按鈕,然後一些簡單的事情 後重新啓用按鈕。
殭屍代碼:
browser
.visit(https://example.com, function(){
browser.fill(....)
browser.fill(....)
browser.pressButton('#nextStep', function(){
browser.fill(...)
browser.fill(...)
browser.pressButton('#nextStep', function(){ //THIS LINE Errors
...
...
});
});
})
殭屍引發錯誤 「按鈕被禁用」 第二.pressButton。就我對zombiejs的理解而言,在我看來,pressButton應該等待事件完成,然後執行回調函數。
*新zombiejs
使用promises API Zombie提供的結果與使用回調的事件完全相同,但使用更簡潔的語法。這不應該改變目前打破的任何事情。 –