使用android espresso自动进行深层链接 [英] Automating deep linking using android espresso

查看:78
本文介绍了使用android espresso自动进行深层链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想编写espresso脚本来测试深层链接,但不知道如何开始.寻找可以帮助我获得更多想法的解决方案,可能是逐步入门的过程.

I want to write espresso scripts to test deep linking and have no idea how to begin with. Looking for solutions that'll help me get more idea, possibly step by step procedure on how to get started.

例如:我正在寻找一种情况,例如您在gmail点击中获得了一个链接,该链接上应将用户定向到移动应用程序.我如何开始使用espresso测试类似的东西?

For ex : I am looking for a scenario like you get a link in gmail tapping on which user should be directed towards the mobile app. How do I get started to test something like this using espresso ?

谢谢.

推荐答案

从活动规则开始

 @Rule
 public ActivityTestRule<YourAppMainActivity> mActivityRule =
            new ActivityTestRule<>(YourAppMainActivity.class, true, false);

然后,您需要一些内容来解析链接中的uri并返回意图

Then you want something to parse the uri from the link and return the intent

String uri = "http://your_deep_link_from_gmail"; 
private Intent getDeepLinkIntent(String uri){
        Intent intent = new Intent(Intent.ACTION_VIEW,
                Uri.parse(uri))
                .setPackage(getTargetContext().getPackageName());


        return intent;
    }

然后,您希望活动规则启动意图

Then you want the activity rule to launch the intent

Intent intent = getDeepLinkIntent(deepLinkUri);
mActivityRule.launchActivity(intent);

这篇关于使用android espresso自动进行深层链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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