简体   繁体   中英

how to open chrome with a specific google account with pywinauto

Recently I have been trying to automate a log in process which has lots of hoops to jump through like scheduling a time slot on a google calendar and opening 2 programs and I have started building it with pywinauto already and put a lot of work into figuring it out.

The issue I am having is that when i open chrome with:

from pywinauto.application import Application
chrome_dir = '"C:\Program Files\Google\Chrome\Application\chrome.exe"'
start_args = ' --force-renderer-accessibility --start-maximized https://#URLHERE#.com'
app = Application(backend="uia").start(chrome_dir+start_args)

it opens with the wrong google profile and I need it to open with the other.

I have tried reading through the documentation and have had a really hard time coming up with a solution to this. I also tried to just open it with the profile selector but I would much rather not have to click on something which may not come up right away or change in the future to get the right account. I would much rather it just be done when launching. Any ideas?

It would open using PyAutoGUI, then you would select to choose profile when starting in Chrome. Using this pywinauto I don't know how to use it, and I'm also on linux, so I can't test it here to help you.

To open Google Chrome with a specific profile you have to add --profile-directory=PROFILE

There's a super easy way to identify the profile directory: go to chrome://version and check the Profile Path. Assuming you are seeing /path/to/your/PROFILE, use --user-data-dir=/path/to/your --profile-directory=PROFILE. If your user data directory is the default location (the last paragraph in the answer) you can omit it.

I found the answer here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM