Home > Blockchain >  Selenium (Powershell) Run as a different user
Selenium (Powershell) Run as a different user

Time:01-14

I want to start Selenium (Google Chrome - WebDriver) as a different user and I am pretty much lost as I don't know where to add $mycreds. This is quite easy to achieve if I want to start a normal Chrome session, however, I am stuck when it comes to achieving this using Selenium. Any advice ?

$username = "domain\name"
$password = ConvertTo-SecureString "password" -AsPlainText -Force
$mycreds = New-Object System.Management.Automation.PSCredential -ArgumentList $username, $password
$Driver = Start-SeChrome
Enter-SeUrl -Url 'https://www.google.com/' -Driver $Driver

If I try to pass it along using -Arguments , it will still use my account to open the browser without returning any error.

$Driver = Start-SeChrome -Arguments $mycreds

CodePudding user response:

The easy way to do this is by starting Powershell as-another-user instead. Make sure you have the module set up for that user as well as any other environment stuff you might need.

The selenium-powershell module itself does not support starting the selenium drivers as a different user from the current one.


You may also want to make sure you're using an updated version of the module as well, since (in pre-release):

Start-SeChrome and other have been removed in favor of Start-SeDriver -Browser Chrome (#100)

  •  Tags:  
  • Related