Open AcerScottLee opened 6 years ago
This is the current code:
function Start-SeFirefox {
param([Switch]$Profile)
if ($Profile) {
#Doesn't work....
Apparently it is a known issue.
It looks like this works to make a FireFox driver which ignores SSL certificate checks:
$firefoxOptions = [OpenQA.Selenium.Firefox.FirefoxOptions]::new()
$firefoxOptions.AddAdditionalCapability('acceptInsecureCerts', $true, $true)
$Driver = New-Object -TypeName "OpenQA.Selenium.Firefox.FirefoxDriver" -ArgumentList @($firefoxOptions)
From here:https://github.com/mozilla/geckodriver/issues/563#issuecomment-288711235
For those that want to run this for Chrome, here's the command for that: $ChromeOptions = [OpenQA.Selenium.Chrome.ChromeOptions]::new() $ChromeOptions.AcceptInsecureCertificates = $true $driver = New-Object -TypeName "OpenQA.Selenium.Chrome.ChromeDriver" -ArgumentList @($ChromeOptions)
I also wanted my script to not wait for the page to finish loading before going to the next command in PS, so you can also add this line to the options: $ChromeOptions.PageLoadStrategy = "None"
There is something fishy with Selenium.Firefox.WebDriver 0.25.0/0.26.0 and profiles. seems like the FirefoxProfile object is readonly:
$prof = New-Object OpenQA.Selenium.Firefox.FirefoxProfile($profilePath)
PS > $prof.ProfileDirectory
PS > $prof.ProfileDirectory = $profilePath
'ProfileDirectory' is a ReadOnly property.
At line:1 char:1
+ $prof.ProfileDirectory = $profilePath
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : PropertyAssignmentException
It looks like this works to make a FireFox driver which ignores SSL certificate checks:
$firefoxOptions = [OpenQA.Selenium.Firefox.FirefoxOptions]::new() $firefoxOptions.AddAdditionalCapability('acceptInsecureCerts', $true, $true) $Driver = New-Object -TypeName "OpenQA.Selenium.Firefox.FirefoxDriver" -ArgumentList @($firefoxOptions)
From here:mozilla/geckodriver#563 (comment) If people are interested in this we can add it as a flag to Start-SeFirefox. Let me know if you are interested in that .
-DM
First Thanks your selenium with powershell, Because I love to use powershell for automation. I had a website of self-signed, and I use
$Driver = Start-SeFirefox -Profile $MyProfilePath
but not working.. Can anyone give me some advice?