diff --git a/core/example-tests/example.js b/core/example-tests/example.js index f843e609e3..c96fcca383 100644 --- a/core/example-tests/example.js +++ b/core/example-tests/example.js @@ -1,6 +1,13 @@ const exec = require('child_process').exec; var simpletestCookie; + +if (typeof process.env.SIMPLETEST_BASE_URL === 'undefined') { + console.error('Missing SIMPLETEST_BASE_URL environment variable.'); + exit(1); +} +const BASEURL = process.env.SIMPLETEST_BASE_URL; + /** * @param browser * @param cookieValue @@ -8,11 +15,14 @@ var simpletestCookie; */ const setupCookie = function (browser, cookieValue) { return browser + // See https://bugs.chromium.org/p/chromedriver/issues/detail?id=728#c10 + .url(BASEURL) .setCookie({ name: 'SIMPLETEST_USER_AGENT', - value: cookieValue, - path: '/d8/', - domain: 'localhost', + // Colons needs to be URL encoded to be valid. + value: encodeURIComponent(cookieValue), + path: BASEURL.split(extractHostname)[1], + domain: extractHostname(BASEURL), }); }; @@ -32,8 +42,8 @@ module.exports = { 'Demo test Frontpage' : function (browser) { setupCookie(browser, simpletestCookie) - .url('http://localhost/d8/') - .assert.containsText('#main', 'Home') + .url(BASEURL) + .assert.containsText('main', 'Log in') .end(); } };