使用TestCafe-如何阻止移动网络智能应用横幅显示?

问题描述 投票:0回答:2

我正在测试的网页使用HTML中的以下属性在iOS设备上显示Apple智能应用横幅:

name="apple-itunes-app"
content="app-id=foobar"
rel="manifest"
href="/CompanyName/mobile/include/manifest.json"

但是,我不希望显示此内容。通常,如果涉及到请求,我会使用TestCafe Request Mocker,但是此横幅似乎没有使用请求,它只是出现了!“网络”标签中没有清单请求。

如何使用TestCafe本机功能或任何合适的Node包来阻止智能应用程序横幅?

javascript ios testing testcafe smartbanner
2个回答
0
投票

TestCafe没有任何可用于Smart App标语的API。

尝试以下线程中的解决方法,它描述了如何防止智能应用横幅显示在iPad上:

Prevent Smart app banner from showing on iPad


0
投票

您可以尝试使用ClientScripts机制从页面中删除标题元标记。请参考以下文章以获取详细信息:https://devexpress.github.io/testcafe/documentation/using-testcafe/common-concepts/inject-scripts-into-tested-pages.html

我准备了一个例子:

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Math Ninja iPhone/iPod Touch Game | Making Addition, Subtraction, Multiplication, and Division Fun!</title>
    <meta name="apple-itunes-app" content="app-id=370144476"/>
    <link rel="stylesheet" type="text/css" href="reset.css"/>
    <link rel="stylesheet" type="text/css" href="style.css"/>
</head>
<body>
</body>
</html>

测试代码:

import { ClientFunction } from 'testcafe';

fixture `fixture`
    .page `http://localhost:8080`;


const removeBanner = ClientFunction(() => {
    var banner = document.querySelector('meta');

    banner.parentNode.removeChild(banner);
});

test.clientScripts({ content: `
    var banner = document.querySelector('meta');

    banner.parentNode.removeChild(banner);
` })(`test`, async t => {
    await t.wait(5000);
});
© www.soinside.com 2019 - 2024. All rights reserved.