-1

I have successfully loaded my chrome profile with selenium that has pre-installed extensions.

The extension in question is called Private Internet Access, but i have tried others and cannot communicate with them

I am trying to figure out how i can open the extension below and enter username&password and click login button. I have tried finding the elements in by id and class but it doesnt find them. Can someone point me down the right line for this. Thanks

Screenshot

Greg Burghardt
  • 17,900
  • 9
  • 49
  • 92
Frank
  • 1
  • 1
  • 1
    Please [edit] your question to include more information about the extension you want to interact with. It is a little difficult to tell from the screenshot, although the screenshot is helpful. – Greg Burghardt Sep 01 '22 at 12:53
  • done, its private internet access extension, – Frank Sep 01 '22 at 14:12
  • The name of the extension is good, but is there a link with more information? – Greg Burghardt Sep 01 '22 at 14:54
  • https://chrome.google.com/webstore/detail/private-internet-access/jplnlifepflhkbkgonidnobkakhmpnmh?hl=en – Frank Sep 01 '22 at 15:15
  • I'm not finding much about this either. There is a similar Python question: [How do I interact with a chrome extension?](https://stackoverflow.com/q/55646658/3092298), which is unanswered, but has lots of good links. There is also [How to test Chrome extensions in Selenium](https://www.browserstack.com/guide/test-chrome-extensions-in-selenium) on BrowserStack. Sorry I cannot help more. – Greg Burghardt Sep 01 '22 at 16:00

1 Answers1

1

I've not had the ability to try this - however I've done a lot of work with Selenium and I've created my own chrome extension.

That extension popup in the top right actually a different web page. You won't be able to interact with it due to how it's presented, but you can navigate to it.

Try this:

  1. Open up your extension, right click anywhere and select Inspect. This will open up devtools for the popup.

inspect on extensions

  1. In devtools, go to the console and type document.url. This will give you the URL of that popup page. (you'll also see it at the top of the title bar) devtools popup

That gibberish-looking bit in the middle doesn't change - it's your chrome extension identifier. From when I created my extension and 18 months worth of updates (including migrating from chrome extension manifest v2 to v3) it has not changed for me. I think you'll be safe to use it.

  1. Go to that URL to make sure it works. In my case it's chrome-extension://ojhcleddagaoaplflbafhpekcciikdop/popup.html enter image description here

You'll notice you'll lose some of the page styling compared to the popup. When you design the popup you give it fixed dimensions - when you open it as a normal webpage, you lose that and everything gets stretched.

  1. Finally - for your automation - put that chrome-extension:\\ url as the first step in your selenium script and do your sign in. Then, carry on with the rest of your test.
RichEdwards
  • 3,423
  • 2
  • 6
  • 22
  • Thanks for the response. Unfortunatly for my particular use case opening in a seperate tab will not work. An event on the main page cause this popup to appear and at this point I would like to enter usernamer and password, sorry i didnt make that clear in original post – Frank Sep 02 '22 at 11:01
  • 1
    @Frank: I don't think what you want to do is possible. I linked to more information that basically agrees with this answer. Maybe navigate to the extension login page first, and then proceed to the system under test? – Greg Burghardt Sep 02 '22 at 12:42