diff --git a/lib/taiko.js b/lib/taiko.js index 7aa44b3dc..01569e887 100644 --- a/lib/taiko.js +++ b/lib/taiko.js @@ -733,7 +733,7 @@ module.exports.goto = async ( options = { navigationTimeout: defaultConfig.navigationTimeout }, ) => { validate(); - if (!/:\/\//i.test(url)) { + if (!/^about:|:\/\//i.test(url)) { url = 'http://' + url; } if (options.headers) { diff --git a/test/unit-tests/goto.test.js b/test/unit-tests/goto.test.js index e3ee8b568..3e350a38f 100644 --- a/test/unit-tests/goto.test.js +++ b/test/unit-tests/goto.test.js @@ -83,6 +83,20 @@ describe(test_name, () => { expect(actualUrl).to.equal(expectedUrl); }); + it('should not add protocol http:// if url is "about:*"', async () => { + let aboutBlank = 'about:randomString'; + let expectedUrl = aboutBlank; + await taiko.goto(aboutBlank); + expect(actualUrl).to.equal(expectedUrl); + }); + + it('should add protocol http:// for url with port specified', async () => { + let urlWithPort = 'localhost:8080'; + let expectedUrl = 'http://' + urlWithPort; + await taiko.goto(urlWithPort); + expect(actualUrl).to.equal(expectedUrl); + }); + it('should configure provided headers for the domain', async () => { let options = { headers: { Authorization: 'Basic cG9zdG1hbjpwYXNzd29y2A==' },