且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何断言在selenium测试用例的登录成功?

更新时间:1970-01-01 07:56:54

您不是检查错误的密码是否让用户登录。

Your not checking to see if the wrong password got the user logged in.

您需要在登录后放入一个测试用例,

You need to put a test case to check after logging in, if some particular text appears.

例如,如果用户成功登录,欢迎屏幕显示Hi UserName。因此,如果在您的selenium脚本命中 loginBtn

Like for example, if the user successfully logs in, the welcome screen shows "Hi UserName". So you need to assert if the text is present after your selenium script hits on the loginBtn

目前你正在做的是发送一些文本作为密码,selenium显然不知道密码是否不正确,除非你验证输入结果不正确的密码。

Currently all you are doing is sending "some" text as the password, selenium will obviously not know if the password is incorrect, unless you validate the outcome of entering an incorrect password.

编辑

RUBY的程式码片段 -

A code snippet in RUBY-

assert(@driver.find_element(:tag_name => "body").text.include?("Welcome UserName"),"The User successfully logs in")