Skip to content
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

[Feature]: Make page.goto work with URL objects #1006

Closed
aesyondu opened this issue Feb 14, 2020 · 5 comments
Closed

[Feature]: Make page.goto work with URL objects #1006

aesyondu opened this issue Feb 14, 2020 · 5 comments

Comments

@aesyondu
Copy link
Contributor

aesyondu commented Feb 14, 2020

Context:

  • GOOD Playwright Version: 0.10.0
  • BAD Playwright Version: 0.11.0
  • Operating System: Mac OS X 10.14.6
  • Extra: 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:

async goto(url: string, options: GotoOptions = {}): Promise<network.Response | null> {

After the helper function for localhost was added, the page.goto(URL) now throws an error: TypeError: urlString.startsWith is not a function

if (urlString.startsWith('localhost') || urlString.startsWith('127.0.0.1'))

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?
@dgozman dgozman changed the title [REGRESSION]: page.goto(URL) no longer works [Feature]: page.goto(URL) no longer works Feb 27, 2020
@ddayguerrero
Copy link

ddayguerrero commented Mar 4, 2020

👋 Hi! I've been playing around with Playwright for a bit — definitely some good stuffs! I'd be interested in tackling this issue.

While this looks like a straightforward enhancement, I have a few questions:

  1. What is the scope? I noticed that in many places, the API currently expects url: string. Is the issue specific for Page and Frames? This might have some impact of the versioning.

  2. What is everyone's thoughts on using union types or method overloading to accept string and URL?

  3. Do we have more details on Playwright's contribution guidelines?

@aesyondu aesyondu changed the title [Feature]: page.goto(URL) no longer works [Feature]: Make page.goto work with URL objects Mar 5, 2020
@aslushnikov
Copy link
Collaborator

Would it be a good idea to support passing a URL object instead of just a string?

@aesyondu Nah, let's keep it simple. Strings work good for us so far.

  1. What is the scope? I noticed that in many places, the API currently expects url: string. Is the issue specific for Page and Frames? This might have some impact of the versioning.

@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.

  1. Do we have more details on Playwright's contribution guidelines?

This is a good one - filed #1257 to address this.

@ddayguerrero
Copy link

No worries, thanks for the heads up! Shall we expect to see more newcomer friendly issues in the future?

@aslushnikov
Copy link
Collaborator

Shall we expect to see more newcomer friendly issues in the future?

@ddayguerrero oh, definitely! Please keep an eye on the repo :)

@sadik13
Copy link

sadik13 commented Jun 28, 2021

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!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants