[Feature]: Make page.goto work with URL objects
See original GitHub issueContext:
GOOD Playwright Version: 0.10.0BAD Playwright Version: 0.11.0Operating System: Mac OS X 10.14.6Extra: node@11.15.0 npm@6.7.0
Code Snippet
const url = new URL(baseUrl)
url.pathname = "theusers/thepassword"
url.searchParams.append("reset_thepassword_token", 1)
// ERROR IN THIS PART
const changePasswordPage = page.goto(url) // alternative: url.href
// ERROR IN THIS PART
await Promise.all([
// ...etc,
changePasswordPage
])
Describe the bug feature
I have a piece of code where I construct a URL
object and pass that to the page.goto
function.
I just noticed that the url in page.goto
is typehinted as string:
After the helper function for localhost was added, the page.goto(URL)
now throws an error: TypeError: urlString.startsWith is not a function
I understand the alternative is to simply access the URL.href
property, my question is:
- Would it be a good idea to support passing a URL object instead of just a string?
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
How to use URL Objects (URL Interface) - JavaScript Tutorial
URL objects are especially useful when combining them with the Fetch API in order to make HTTP requests. Support me on Patreon: ...
Read more >URL() - Web APIs - MDN Web Docs - Mozilla
The URL() constructor returns a newly created URL object representing the URL defined by the parameters.
Read more >Creating a URL - The Java™ Tutorials
The easiest way to create a URL object is from a String that represents the human-readable form of the URL address. This is...
Read more >JavaScript: Go to URL: A Complete Guide - Career Karma
To navigate to a new URL, use the location object from the Browser's History API. The session history lets you reassign the location...
Read more >How to get the browser to navigate to URL in JavaScript
If you want to simulate clicking on a link, use location.href If you want to simulate an HTTP redirect, use location.replace Note that...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@aesyondu Nah, let’s keep it simple. Strings work good for us so far.
@ddayguerrero Hi! I closed your PR regarding this - sorry for confusion. In general, we don’t think this whole change worth the hassle - it doesn’t really bother that much our clients.
This is a good one - filed https://github.com/microsoft/playwright/issues/1257 to address this.
HI, As per my requirement, I wanna access the below code instead of the full URL I wanna set the hostname into env variables outside of the tes.journey.js file and access it into my playwright code.
await page.goto(‘http://www.google.com’);
I need like this below way: const URL =“env path address of HOST”; await page.goto(url);
so, plz suggested ur ideas of code for this.
Thanks in advance!!!