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

查看:21
本文介绍了如何为自动化的 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 作为密码,这可能是提供一些测试凭据的机会 - 但我不知道如何.

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 Console->Test Lab->选择Dimensions,然后点击

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

显示高级选项

然后寻找

测试帐户凭据(可选)

然后填写如下:

输入用户名资源:您的用户名(电子邮件)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

输入密码资源:同上,但输入密码.同样,跳过 R.id,例如.edit_text_password

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

输入密码 :您将用于测试的密码,例如 testTEST123

似乎 Robo(测试机器人)在找到使用 ID 资源指定的 EditTexts 后立即输入凭据,但如果您有其他身份验证选项,则可能需要一些时间来确定单击哪个按钮登录如使用 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 足够的测试时间(测试超时),以防它在没有单击右键的情况下停留一段时间.

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.

如果您为 Robo 提供 Sign in With Google 按钮以使用其自己的 Google 凭据登录,请记住,如果您提供 Test account 凭据,这将不起作用.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天全站免登陆