【发布时间】:2012-02-01 01:04:42
【问题描述】:
我想编写一个 selenium 测试来检查当我登录到我的应用程序,然后重新打开浏览器时,我是否使用保存的 cookie 自动登录。
我认为这可能可以在两个 #{selenium} 块之间调用 clearSession() ,但这似乎也清除了 cookie。我已经测试过这个功能可以手动工作。
任何想法我会如何测试这个。
供参考:这是我尝试过的。
#{fixture delete:'all', load:'../conf/User.yml' /}
#{selenium}
deleteAllVisibleCookies()
// Open the home page, and check that no error occurred
open('/')
waitForPageToLoad(1000)
assertNotTitle('Application error')
open('/login')
type('usernameOrEmail', 'marchaos')
type('password', 'password')
clickAndWait('css=input[type=submit]')
assertTextPresent('Welcome marchaos')
clearSession()
#{/selenium}
#{selenium}
// Open the home page, and check that no error occurred
open('/')
waitForPageToLoad(1000)
assertTextPresent('Welcome marchaos')
#{/selenium}
在最后一个 assertTextPresent() 失败
【问题讨论】:
标签: cookies selenium playframework