javascriptautomated-testse2e-testingtestcafebase-tag

How to make testcafe respect the `<base>` tag


My application at some point injects <base> tag into the website and after that creates a new <script> tag with relative src

For example sets <base href="http://localhost:8080/chapters/de/auth/"> and injects <script src="build.js" type="text/javascript" /> resulting into browser downloading script from http://localhost:8080/chapters/de/auth/build.js.

When running the same application in testcafe, the result is slightly different. Inserted base is <base href-hammerhead-stored-value="http://localhost:8080/chapters/de/auth/" href="http://localhost:1337/Lj6CFUfNF/http://localhost:8080/chapters/de/auth/"> and script is <script src-hammerhead-stored-value="build.js" src="http://localhost:1337/Lj6CFUfNF!s!utf-8/http://localhost:8080/account/build.js" type="text/javascript" />

Suddenly the previously relative URL build.js turned into http://localhost:8080/account/build.js which is inconsistent with what is set in <base>

Any idea how to get around this?

I am running

testcafe: 1.1.0


Solution

  • The cause of the issue is in the order of injecting base and script tags. If the script element is injected before the base element, it will lead to an error. Please track our progress in the context of https://github.com/DevExpress/testcafe/issues/3585 issue on GitHub.