selenium-powershell icon indicating copy to clipboard operation
selenium-powershell copied to clipboard

Can I use "-profile" parameter in Start-Sefirefox ?

Open AcerScottLee opened this issue 7 years ago • 6 comments

AcerScottLee avatar Oct 17 '18 02:10 AcerScottLee

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?

AcerScottLee avatar Oct 17 '18 02:10 AcerScottLee

This is the current code:

function Start-SeFirefox {
    param([Switch]$Profile)

    if ($Profile) {
        #Doesn't work....

Apparently it is a known issue.

Sako73 avatar Mar 27 '19 12:03 Sako73

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

HumanEquivalentUnit avatar May 09 '19 01:05 HumanEquivalentUnit

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"

BenjaminBaxleyINAP avatar Sep 20 '19 20:09 BenjaminBaxleyINAP

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

fenchu avatar Oct 31 '19 14:10 fenchu

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

the-mentor avatar Nov 18 '19 19:11 the-mentor