Selenium Chrome驱动程序不识别证书,但手动浏览正常工作。

huangapple go评论73阅读模式
英文:

Selenium Chrome driver does not recognize certificates, but manual browsing works fine

问题

I am encountering an issue with Selenium and Chrome where the browser does not recognize certificates when using the Selenium Chrome driver.
Strangely, when I manually open Google Chrome and visit the same websites, everything works fine.
Below is the code I'm using:

from seleniumwire import webdriver
from webdriver_manager.chrome import ChromeDriverManager

chromeOptions = webdriver.ChromeOptions()
chromeOptions.add_argument('--ignore-certificate-errors')

driver = webdriver.Chrome(executable_path=ChromeDriverManager().install(), chrome_options=chromeOptions)
driver.get("https://www.google.com")

However, when I run the code, I get the following result:

Selenium Chrome驱动程序不识别证书,但手动浏览正常工作。

Could someone please help me understand what I might be doing wrong?

英文:

I am encountering an issue with Selenium and Chrome where the browser does not recognize certificates when using the Selenium Chrome driver.
Strangely, when I manually open Google Chrome and visit the same websites, everything works fine.
Below is the code I'm using:

from seleniumwire import webdriver
from webdriver_manager.chrome import ChromeDriverManager

chromeOptions = webdriver.ChromeOptions()
chromeOptions.add_argument('--ignore-certificate-errors')

driver = webdriver.Chrome(executable_path=ChromeDriverManager().install(), chrome_options=chromeOptions)
driver.get("https://www.google.com")

However, when I run the code, I get the following result:

Selenium Chrome驱动程序不识别证书,但手动浏览正常工作。

Could someone please help me understand what I might be doing wrong?

答案1

得分: 1

Since you are using selenium wire You need to install the certificate in your local machine
You can also get the certificate by running the following command

python -m seleniumwire extractcert
or

python3 -m seleniumwire extractcert

You can also get the file from below link also just copy-paste it to a file and name it "ca.crt"

Cert

Once you have the ".crt" file downloaded you have to import the certificate.
In MAC Open Keychain Access and then import items and then import the .crt file, then search for "Selenium Wire CA" cert, double click, expand the trust section and select Always trust, after this you should not see "Not Secured" in Chrome anymore

For windows
Launch MMC (mmc.exe) -> Choose File -> Add/Remove Snap-ins -> Choose Certificates, then choose Add -> Choose My user account
-> Choose Add again and this time select Computer Account -> Move the new certificate from the Certificates-Current User -> Trusted Root Certification Authorities into Certificates (Local Computer) -> Trusted Root Certification Authorities.

Reference

英文:

Since you are using selenium wire You need to install the certificate in your local machine
You can also get the certificate by running the following command

python -m seleniumwire extractcert

or

python3 -m seleniumwire extractcert

You can also get the file from below link also jut copy paste it to a file and name it "ca.crt"

Cert

Once you have the ".crt" file downloaded you have to import the certificate.
In MAC Open Keychain Access and them import items and them import the .crt file , then search for "Selenium Wire CA" cert , double click , expand the trust section and select Always trust, after this you should not see Not Secured in chrome anymore

For windows
Launch MMC (mmc.exe) -> Choose File > Add/Remove Snap-ins -> Choose Certificates, then choose Add -> Choose My user account
-> Choose Add again and this time select Computer Account -> Move the new certificate from the Certificates-Current User -> Trusted Root Certification Authorities into Certificates (Local Computer) -> Trusted Root Certification Authorities.

Reference

huangapple
  • 本文由 发表于 2023年5月14日 23:27:00
  • 转载请务必保留本文链接:https://go.coder-hub.com/76248260.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定