1

I have the following .dll files in order to run selenium through powershell: enter image description here

You can ignore the extension files. Basically what I want to have happen is to use the Start-Job command in order to open two chrome browsers at the same time, and go to different url's.

Here is my script:

temp.ps1

# set the location to the current one where the dll's are
Set-Location -Path $args[0]
Get-ChildItem -Filter "*.dll" | ForEach-Object { Add-Type -Path $_.Name } # this will get all the dll's

# start chrome
$options = New-Object OpenQA.Selenium.Chrome.ChromeOptions
$options.BinaryLocation = "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
$chrome = New-Object OpenQA.Selenium.Chrome.ChromeDriver($options)
$chrome.Navigate().GoToUrl("http://www.google.com")

Running this opens a chrome window at google.comenter image description here

For now, I just want to test to see if I can open two different chrome apps at the same time and have them both go to google.com

Here is that script:

enter image description here

Running through powershell window does not do what I expect? It opens two chrome browsers but does not navigate to them, also checking the job details reveals no error messages?

enter image description here

K Split X
  • 3,405
  • 7
  • 24
  • 49
  • I would appreciate if one of you all tried it and just duplicated what I did to see if it works in yours? The files I got from nuget packages, specified here: https://wesum.wordpress.com/2017/08/26/first-blog-post/ – K Split X May 06 '18 at 01:50

1 Answers1

1

Posting here for visibility - hopefully this saves someone else a bit of stress:

My function was working perfectly when run directly, but failed quietly whenever it was run via Start-Job. It would cease right at the point of starting the ChromeDriver service.

I resolved this problem by instructing ChromeDriver to hide the command prompt window, by passing in "HideCommandPromptWindow" during the service instantiation.

# Hook into our Chrome session on the Debugger port
$ChromeOptions = New-Object OpenQA.Selenium.Chrome.ChromeOptions
$ChromeOptions.debuggerAddress = "127.0.0.1:1111"

# Pass our configuration into ChromeDriver.exe
$ChromeService = [OpenQA.Selenium.Chrome.ChromeDriverService]::CreateDefaultService()
$ChromeService.HideCommandPromptWindow = $true

# Start ChromeDriver
$ChromeDriver = New-Object OpenQA.Selenium.Chrome.ChromeDriver($ChromeService, $ChromeOptions)
Romeowns
  • 11
  • 1