Profile and it certainly is possible to do that it's not actually all that difficult it's just not immediately obvious how to do it so let's take a look and see how it works.
To get started i've created a new excel workbook and in the visual basic editor i created a new module and written the basic code required to start a new instance of google chrome.
I'm relying on the selenium type library here so i've headed to the tools menu and chosen references and i've set a reference to the selenium type library already.
I'm going to assume that you already know how to set that up and if you're not sure then we do have a playlist which explains exactly how to do all that so this is your reference point if.
You need some help getting that set up if i just head back to the visual basic editor and i run this subroutine i'll find that i open up a new instance of chrome as expected but the profile that.
Really like to do is set the user profile to the wizal tutorials one when i start this new instance of chrome to do this i can use the set profile method of the chrome driver variable i.
Need to do this before i start the driver so let's give myself a couple of blank lines before cd dot start and then say cd dot set profile what i then need to do is pass in the.
Path to the folder which contains all of the user profile folders i've already got that folder open in a windows explorer window so it's called user data and it's part of the local app.
Data folder so it's part of your user profile rather than write out the full path to this folder i'm going to use a windows environment variable to get the path up.
To the local folder and then add on google chrome user data to the end so i'm going to use the environ function and then in some round brackets and some double quotes say local app data.
I can spell that eventually there we go
And then i can concatenate to the end of that backslash google backslash chrome backslash user data.Now before i run this subroutine again i need to make sure that i close down any open instance of google chrome which is currently using the user data folder so the open instance of chrome i had at the.
Start that i showed you the various videos in i need to close that one down having done that i can head back to the visual basic editor and then run the subroutine again and this time you'll.
See when we run the subroutine and the instance of chrome opens up i'm logged in as wisel tutorials now despite the name of the method we've just used here we're not.
Actually setting the profile that we're using we're just setting the location of the user data directory if we had multiple user profiles we haven't actually picked one here what.
Chrome is doing is just using the last logged in user profile so if i wanted to pick a different user profile if i head back to my user data folder i've got my default profile which.
Is ysl tutorials i've also got a couple of other profiles inventively called profile 1 and profile 2. so let's say i wanted to load google chrome logged in with profile 2..
In order to make that work i've got to add another line of code again before i start the browser or start the driver i need to say cd dot add argument and then in here in a set of double.
Quotes i'm going to say profile dash directory equals and then write out the name of the profile to folder so profile two just.
Like that
Okay having done that if i run the subroutine again this time i'll see that i'm logged in with a different user profile.Rather than the wisely tutorials one just to demonstrate that chrome will remember the last used profile if i head back to the visual basic editor and i just comment out the line i've added to.
Add the argument to specify the profile directory if i run the subroutine again it's going to use the same profile that's just been used in the previous example.
So if i wanted to go back to the wiseal tutorials profile i need to specify that with the same line of code so the yzal tutorials profile is stored in the default folder so i'm going to head back.
To the visual basic editor i'm going to bring back this line but then i'm going to change profile 2 to say default and if i run the subroutine again we'll find that this time it loads in loads up.
Logged in as ysl tutorials so there we go there's the basics of opening google chrome of this specific user profile hopefully that helps michael with his authentication issues.