How to fix webdriverio error : TypeError: Cannot read property 'then' of null?

How to fix webdriverio error : TypeError: Cannot read property 'then' of null?

嗨,我是 webdriverio 的新手,我收到以下错误消息, 无法读取 null 的 属性 'then' TypeError: 无法读取 属性 'then' of null

这是我的代码

it('Test case - User Add', () => {
browser.setTimeout({ implicit: 3111 })
userManagement.UserManagementMenu.click()
userManagement.NewUserButton.click()
userManagement.FirstName.setValue('EntryGate')
userManagement.Username.setValue('EGTestuser1')
userManagement.LastName.setValue('EGTestuser1')
userManagement.EmailAddress.setValue('EGTestuser1@test.com')
userManagement.Password.setValue('password1')
userManagement.Role.click().then(function(){
    browser.keys('ArrowUp')
    browser.keys('Enter')
})
userManagement.SaveUser.click()
});

});

经过几次 google 搜索后,我发现我没有在我的代码中处理 promise。 谁能纠正我的代码

Official doc says

The then() method returns a Promise. It takes up to two arguments: callback functions for the success and failure cases of the Promise.

如果你只想执行点击和一些键盘操作,你可以使用下面的代码

 it('some description', () => {
      userManagement.Role.click();
      browser.keys('ArrowUp');
      browser.keys('Enter');
      userManagement.SaveUser.click();    
 }