我的应用程序有时会注入(inject) <base>
标记到网站中,然后创建一个新的 <script>
带有亲戚的标签 src
例如设置<base href="http://localhost:8080/chapters/de/auth/">
并注入(inject) <script src="build.js" type="text/javascript" />
导致浏览器从 http://localhost:8080/chapters/de/auth/build.js
下载脚本.
在testcafe中运行相同的应用程序时,结果略有不同。插入的碱基是 <base href-hammerhead-stored-value="http://localhost:8080/chapters/de/auth/" href="http://localhost:1337/Lj6CFUfNF/http://localhost:8080/chapters/de/auth/">
脚本是 <script src-hammerhead-stored-value="build.js" src="http://localhost:1337/Lj6CFUfNF!s!utf-8/http://localhost:8080/account/build.js" type="text/javascript" />
突然之前的相对URL build.js
变成了http://localhost:8080/account/build.js
与<base>
中的设置不一致
知道如何解决这个问题吗?
我在运行
测试咖啡馆:1.1.0
最佳答案
问题的原因在于注入(inject) base
和 script
标签的顺序。
如果 script
元素在 base
元素之前注入(inject),则会导致错误。
请在以下背景下跟踪我们的进展
https://github.com/DevExpress/testcafe/issues/3585 GitHub 上的问题。
关于javascript - 如何让 testcafe 尊重 `<base>` 标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55245256/