如何为自动android测试提供登录凭据? [英] How to provide login credentials to an automated android test?

查看:156
本文介绍了如何为自动android测试提供登录凭据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种向我的应用程序提供登录"的方式,以便自动登录"并可以测试整个应用程序.当前,它当然被登录屏幕阻止了.

I'm looking for a way to "provide a login" to my app so an automated test "is logged in" and can test the entire app. Currently it's of course blocked by the login-screen.

由于我正在使用SmartLock for Passwords,这可能是为测试提供一些凭据的机会-但我不知道如何.

Because I'm using SmartLock for Passwords, this might be a chance to provide some credentials for the test - but I don't know how.

在测试过程中是否存在一些最佳做法来提供凭据以/跳过登录?我可以想到一个特殊的buildType/-flavor来模拟登录,但是这种方式不能用于测试发行版.

Is there some best-practice to provide credentials to / skip the login during a test? I could think of a special buildType / -flavor which is mocking the login but this way it can't be used to test a release build.

当我可以测试最终发行版本时很棒,当测试成功时可以将其发布到商店.这样,我也可以在PlayStore中使用嵌入式的发布前报告(这真的很好).

It would be great when I could test a final release build which can be uploaded to the store when the test succeeds. This way, I could use the embedded pre-launch-reports in the PlayStore as well (which would be really nice).

推荐答案

转到Firebase控制台->测试实验室"->选择尺寸",然后单击

Go to Firebase Console->Test Lab->Select Dimensions, then click

显示高级选项

然后查找

测试帐户凭据(可选)

然后填写以下内容:

Enter username resource : 用户名的名称(电子邮件)EditText资源,跳过R.id部分,因此对于R.id.edit_text_email输入edit_text_email

Enter username resource : name of your username (email) EditText resource, skipping the R.id part, so for R.id.edit_text_email input edit_text_email

Enter password resource :与上述相同,但输入密码.再次,跳过R.id,例如. edit_text_password

Enter username :您用于测试的用户名或电子邮件,例如test@mywebsite.com

Enter password :用于测试的密码,例如testTEST123

似乎Robo(测试bot)一旦找到用ID资源指定的EditText,便会输入凭据,但是如果您还有其他身份验证选项,可能会花点时间找出要单击哪个按钮来登录如使用Google登录"和继续使用Facebook".在尝试了其他服务几分钟后,似乎幸运地按下了右键,使用您提供的凭据继续进行身份验证.

It seems Robo (the test bot) types in the credentials as soon as it finds the EditTexts specified with the ID resources, yet may take a little while figuring out which button to click to log in if you have other auth options such as 'Sign in with Google' and 'Continue with Facebook'. After a few minutes of attempts in other services it seems to luckily press the right button to continue through the authentication using the credentials you provide.

在撰写本文时,尚无法编写登录行为的脚本,因此无法建议使用哪些按钮进行身份验证,因此只需使用上述方法并为Robo提供足够的测试时间即可(控制台中的Test timeout)以防万一它没有单击右键就停留一会儿.

At the time of writing this, there is no way to script a login behaviour and as such suggest which buttons to use for authentication, so just use the method above and give Robo enough test time (Test timeout in the Console) in case it sticks around without clicking the right button for a while.

如果您提供Sign in With Google按钮供Robo使用其自己的Google凭据登录,请记住,如果您提供Test account credentials,则此操作将无效. IE.为了能够使用Sign in with Google,请确保您未提供任何其他登录凭据,否则它将失败.

If you provide Sign in With Google button for Robo to use its own Google credentials to sign in, remember that this will not work if you provide the Test account credentials. Ie. to be able to use Sign in with Google make sure your haven't provided any other login credentials, otherwise it will fail.

注意:您可以使用类似的方法使Robo填写其他EditText字段-检查测试实验室文档以获取更多信息.

Note: You can make Robo fill in other EditText fields using a similar method - check the Test Lab documentation for more info.

这篇关于如何为自动android测试提供登录凭据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆