1

I'm using Selenium, Chrome and Python 3.10. I'm trying to automate login to "opensea.io" site. Site doesn't have a classic login page. It's login only through installed MetaMask wallet extension. When i click "Login" extension is open a popup and wait my actions (click to buttons and enter a password).

My python script open "login" page ('https://opensea.io/login') find a MetaMask button and click it. But after that Crome extension open popup and it's not a page or tab. I can't find a way how to interact with this popup window to click a button for example

enter image description here

How to connect to this popup to interact with him? I want to find buttons and click it for example or fill data to input fields

Chrome Task Manager says this window is part of an extension: enter image description here

Massimo
  • 836
  • 3
  • 17
  • 38
  • I'm not sure about selenium, but perhaps you should try pyautogui instead since it's a brand new OS window, rather than the controlled browser – OneCricketeer Jan 16 '23 at 14:22
  • You have 3 options. (1) Automatically install the extension when the driver is started (this require to have the extension stored locally). (2) Login using cookies (you have to create a profile on google chrome, manually login to the site, then tell selenium to use the cookies of that profile so that when you load the page in selenium it is already logged in). (3) Use pyautogui to interact with the popup (the popup is not part of the html hence selenium doesn't see it) – sound wave Jan 16 '23 at 14:43
  • 1) i have installed extension as you can see. 2) it's doesn't matter that im using cookies or not because after 24hours its need to login to wallet and site again. its a wallet limitation 3) i'm see that window in Chrome task manager - that mean that is a part of chrome. to be precise, this is a window part of chrome extension. but I'll try to read about pyautogui – Massimo Jan 16 '23 at 15:19
  • I agreed to massimo. Extensions are part of chrome. Can you try switching the window or tab selenium? Try logging all the windows after clicking login. If this helps don't forget to push the code here. https://www.browserstack.com/guide/test-chrome-extensions-in-selenium this might help I guess – rick Jan 16 '23 at 16:01
  • Ah sorry i misunderstood about the popup, I thought it was the popup that appears when you want to install an extension. When you say "it's not a page or tab", are you talking about the small window on the right side of the screenshot? – sound wave Jan 16 '23 at 16:30
  • Anyway, did you try `driver.switch_to.window(driver.window_handles[1])`? You should then be able to interact with the popup window – sound wave Jan 16 '23 at 16:33
  • driver.window_handles - that's first what i checked. and i see just one handle and nothing more. in Crome task manager window looks like not a tab but part of extension. about the link above (test-chrome-extensions) - i need to read it. maybe it helps – Massimo Jan 17 '23 at 18:30

1 Answers1

0

You can do that by switching between windows

# "i" represent index of the window
driver.switch_to.window(driver.window_handles["i"])

you can search window by title and then jump into it

# Get all windows
all_windows = driver.window_handles

# Find the MetaMask popup window by its handle
meta_mask_window = None
for window in all_windows:
    if window != current_window:
       if driver.title == "MetaMask Notification" :
          driver.switch_to.window(window)