Skip to content
This repository has been archived by the owner on Jul 8, 2023. It is now read-only.

browser.pages() returns same URL and title for all pages #56

Open
AfzalivE opened this issue Dec 19, 2019 · 6 comments
Open

browser.pages() returns same URL and title for all pages #56

AfzalivE opened this issue Dec 19, 2019 · 6 comments

Comments

@AfzalivE
Copy link

AfzalivE commented Dec 19, 2019

const browser = await foxr.connect()
const pages = await browser.pages()

the pages const returns the following, instead of details of each page

[{"_events":{},"_eventsCount":0,"_browser":{"_events":{"disconnected"
:[null,null,null,null,null]},"_eventsCount":1},"_id":"50"},{"_events":{},"_eventsCount":0,"_browser
":{"_events":{"disconnected":[null,null,null,null,null]},"_eventsCount":1},"_id":"52"},{"_events":{
},"_eventsCount":0,"_browser":{"_events":{"disconnected":[null,null,null,null,null]},"_eventsCount"
:1},"_id":"54"},{"_events":{},"_eventsCount":0,"_browser":{"_events":{"disconnected":[null,null,nul
l,null,null]},"_eventsCount":1},"_id":"56"}]

Is this intentional or is something happening that I'm not aware of?

Thanks

@deepsweet
Copy link
Owner

that's how pages looks like when you print it to console, actually it's an array of pages that should work as intended, just like in Puppeteer.

@AfzalivE
Copy link
Author

AfzalivE commented Dec 20, 2019

hmm, but when I did page.title(), that was blank too for all of them :/

edit: Ah nvm, that's also an async function. Thanks for this library! Very useful!

@AfzalivE
Copy link
Author

@deepsweet Okay slightly different issue but:

    const pages = await browser.pages()
    log.info(`Found ${pages.length} pages`)

    log.info((await pages[0].title()))
    log.info((await pages[1].title()))

when I do this (where log.info is just a logging line), it prints the same title for all pages, and same url. Even though they're different tabs with different URLs

@deepsweet
Copy link
Owner

sounds like an interesting bug, I'll take a look early next week. thanks!

@deepsweet deepsweet reopened this Dec 20, 2019
@deepsweet deepsweet changed the title browser.pages() returns events browser.pages() returns same URL and title for all pages Dec 20, 2019
@AfzalivE
Copy link
Author

Yeah so the reason for this is that it doesn't look like Selenium has any capability of getting content or title for all window handles. Only able to get that from the active one.

So it's basically

for (page of pages) {
  await page.bringToFront()
  await page.title() // and now the title will be correct
}

Would be nice if foxr can do this by itself though

@alexbartisro
Copy link

I can confirm @AfzalivE's described behavior

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

No branches or pull requests

3 participants