How do I navigate and click buttons on an already open Chrome instance/window. So the scenario is, that an application named "ApplicationNAME" is installed on my Windows machine, but its not a Windows application, because when I run the application it is only opening a chrome instance (not the default Chrome browser). I am also able to see the Developers Tool of chrome, and I am able to inspect the elements which means a chrome instance is opened.

So the idea is to automate this Application using Python and Selenium. I am open for alternate suggestions too. Thank you!

I have used the below Python (3.7.3) code but it doesn't help, because it rather opens another Chrome browser or navigate to already open Chrome window rather than going into the desired "ApplicationNAME" chrome instance.

from pywinauto.application import Application, WindowSpecification
import time
import requests
import selenium
from selenium import webdriver

app = Application().start(cmd_line=u'"C:\\Program Files (x86)\\ApplicationName.exe" ')

chromewidgetwin = app[u'ApplicationName']


chromerenderwidgethosthwnd = chromewidgetwin[u'Chrome Legacy Window']


Driver = webdriver.Chrome ("C:\\chromedriver.exe")

  • You can not hijack an already open window, that's a deeply rooted lmitation in how selenium treats sessions. When you say "opening a chrome instance (not the default Chrome browser)" it sounds a lot as if you're working on an electron app or at least some other standalone chromium package for a web site. Could you possibly confirm if that is the case? If it is I'll leave an answer about how to work with those. – Daniel Nov 26 '19 at 11:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.