I want to automate a extension page (its for work so i sadly wont be able to share it)
My goal will hopefully be able to click on the extension button, automatically or manually it doesn’t matter which will then present a little login GUI which can also be done manually. After that a page automatically opens up and i want to automate that page.
- Asked chat gpt 10s prompts
- Load extension automatically, manually press button and login and use context.pages to get the new page (didn’t seem to get recognized)
- Loaded extension, opened a new page, manually press the extension button and login but this time copy and paste the new page’s url into the previously opened page (i used both page.wait_for_timeout and input() to give me the time to login) using page.content() caused <html><head></head><body></body></html> to be returned even though the page was opened and couldnt be controlled
- Last attempt was loading the extension, manually logged in and then sent the url to a input() which then sent the string to a page.goto() which caused this error to occur: navigating to “moz-extension://1ffaff82-3337-48b5-a30e-bd59b78fe116/html/orders.html”, waiting until “load”
Is there any ideas on how i can get around this? If not maybe selenium can do so?
If you want to get into testing this here are some things to get you started:
https://addons.mozilla.org/en-US/firefox/addon/forest-stay-focused-be-present/ this extension works similar, in that you click the extension button and when you press the settings button in the gui that pops up it takes you to another page from the extension (moz-extension://6e489b0e-61ec-41d6-b205-a6f560505902/options.html)
Some code:
from playwright import sync_api as pw
with pw.sync_playwright() as p:
browser: pw.Browser = p.firefox.launch(
headless= False,
args=[
'--load-extension=extension.xpi'
]
)
context: pw.BrowserContext = browser.new_context()