Skip to content

Fix url protocol detection for non-http urls #1486

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/helper/Nightmare.js
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ class Nightmare extends Helper {
* ```
*/
async amOnPage(url, headers = null) {
if (url.indexOf('http') !== 0) {
if (!(/^\w+\:\/\//.test(url))) {
url = urlResolve(this.options.url, url);
}
const currentUrl = await this.browser.url();
Expand Down
2 changes: 1 addition & 1 deletion lib/helper/Protractor.js
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ class Protractor extends Helper {
* {{> ../webapi/amOnPage }}
*/
async amOnPage(url) {
if (url.indexOf('http') !== 0) {
if (!(/^\w+\:\/\//.test(url))) {
url = this.options.url + url;
}
const res = await this.browser.get(url);
Expand Down
2 changes: 1 addition & 1 deletion lib/helper/Puppeteer.js
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ class Puppeteer extends Helper {
* {{> ../webapi/amOnPage }}
*/
async amOnPage(url) {
if (url.indexOf('http') !== 0) {
if (!(/^\w+\:\/\//.test(url))) {
url = this.options.url + url;
}
await this.page.goto(url, { waitUntil: this.options.waitForNavigation });
Expand Down
35 changes: 35 additions & 0 deletions test/data/sandbox/page_slider.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!-- Example based oncode from https://www.w3schools.com/howto/howto_js_rangeslider.asp -->

<div id="slidecontainer">
<input
type="range"
min="1"
max="100"
value="50"
class="slider"
id="mySlider"
/>
</div>
<div><span>Value:</span> <span id="demo"></span></div>

<script>
var slider = document.getElementById("mySlider");
var output = document.getElementById("demo");
output.innerHTML = slider.value;

slider.oninput = function() {
output.innerHTML = this.value;
};
</script>

<style>
#slidecontainer {
width: 100%;
}
.slider {
width: 100%;
height: 25px;
background: #d3d3d3;
outline: none;
}
</style>
2 changes: 1 addition & 1 deletion test/helper/Puppeteer_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ describe('Puppeteer', function () {

describe('#dragSlider', () => {
it('should drag scrubber to given position', async () => {
await I.amOnPage('https://www.w3schools.com/howto/howto_js_rangeslider.asp');
await I.amOnPage(`file://${path.resolve(__dirname, '../data/sandbox/page_slider.html')}`);
await I.seeElementInDOM('#slidecontainer input');
const before = await I.grabValueFrom('#slidecontainer input');
await I.dragSlider('#slidecontainer input', 20);
Expand Down