1- Install Selenium
pip install -U selenium
2- Download Firefox from here and exract it next to your Test file
:
Download Firefox for Linux
Download Firefox for Windows
You can find all Firefox releases from here
3- Create a GoogleSSLSetupTest.py
file and paste this code ( This is your test file ):
from selenium import webdriver
from selenium.webdriver.firefox.options import Options
EXE_PATH = r'geckodriver.exe'
options = Options()
options.headless = True
driver = webdriver.Firefox(executable_path=EXE_PATH, options=options)
driver.get('http://google.com')
url = driver.current_url
if url.startswith("https://"):
print "Pass"
else:
print "Failed"
driver.quit()
The code above will test that we have been redirected successfully to a secure HTTPS connection when we request a none secure HTTP connection.
python GoogleSSLSetupTest.py
If the test successe it will print out Pass
, else it will print Failed
.
🔥 Note: You can take this concept further by intergate it with your Testing Framework |
---|