Shivam Sahil
Shivam Sahil

Reputation: 4921

How to avoid SSL certification error in Selenium Webdriver using Python?

Here's a simple python code to go to a particular website:

import pandas as pd
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from time import sleep
from selenium.webdriver.common.by import By
import time

profile=webdriver.ChromeOptions()
profile.add_argument('--ignore-certificate-errors')
driver =webdriver.Chrome(r'C:\Utility_Tools\WebDriver\chromedriver.exe')
driver.get('www.google.com')

But since I haven't entered the url so it throws error. Whereas if I use this statement:

driver.get('https://www.google.com/')

Error Disappears. Since my database contains websites without SSL certifications is there any way to browse through them only? Here's my attempt but this too failed:

profile=webdriver.ChromeOptions()
profile.add_argument('--ignore-certificate-errors')
driver =webdriver.Chrome(r'C:\Utility_Tools\WebDriver\chromedriver.exe',options=profile)
driver.get('www.google.com')

The error I trigger each time I run the code is shown below:

errorhandler.py", line 242, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.InvalidArgumentException: Message: invalid argument (Session info: chrome=79.0.3945.130)

Upvotes: 1

Views: 4782

Answers (1)

Guy
Guy

Reputation: 50809

The problem is on get(), www.google.com is not a valid url. For not secure you can use http rather than https

driver.get('http://www.google.com')

Upvotes: 2

Related Questions