У меня есть код в nodejs для селена с использованием скрипта соды.Как генерировать динамические утверждения в nodejs soda
Если вы видите мой скрипт ниже, найдите verifyData() Проведено тестирование строк для значений фиксированных столбцов. Я хочу генерировать эти утверждения динамически, только номер строки будет отличаться от столбца всегда будет одинаковым, как это сделать. Я могу передать номер строки этим методам.
Вторая вещь, если вы видите с утверждением, что я использовал функцию(), можем ли мы захватить err/assertfail здесь?
var browser = soda.createClient({
.....
});
browser
.chain
.session()
.setSpeed(speed)
.setTimeout(2000)
.open('/')
.and(login('[email protected]', 'x1212GQsdtpS'))
.and(verifyData())
.end(function(err){
console.log('error');
});
function login(user, pass) {
return function(browser) {
browser
.click('css=a#loginButton')
.type('css=input.input-medium.email',user)
.type('css=input.input.pwd',pass)
.clickAndWait('css=a.btn.login')
.assertTextPresent('Clients',function(){ console.log('logged in ok')})
}
}
function verifyData() {
return function(browser) {
browser
//Row 1 testing
.assertText('css=div.keyYears table tbody tr:nth-child(1) td:nth-child(3)','some text',function(){ console.log('looks good')})
.assertText('css=div.keyYears table tbody tr:nth-child(1) td:nth-child(5)','some text')
.assertText('css=div.keyYears table tbody tr:nth-child(1) td:nth-child(6)','some text')
.assertText('css=div.keyYears table tbody tr:nth-child(1) td:nth-child(7)','some text')
//Row 2 testing
.assertText('css=div.keyYears table tbody tr:nth-child(2) td:nth-child(3)','some text1',function(){ console.log('looks good')})
.assertText('css=div.keyYears table tbody tr:nth-child(2) td:nth-child(5)','some text1')
.assertText('css=div.keyYears table tbody tr:nth-child(2) td:nth-child(6)','some text1')
.assertText('css=div.keyYears table tbody tr:nth-child(2) td:nth-child(7)','some text1')
}
}