1010# of linux is required for the script to run correctly as well.
1111# Otherwise, use pyvirtualdisplay.
1212
13- import time , sys , glob , os , traceback
13+ import sys
1414from selenium import webdriver
15- from selenium .webdriver .chrome .options import Options
16- from selenium .webdriver .support .wait import WebDriverWait
17- from selenium .webdriver .support import expected_conditions
18- from selenium .webdriver .common .by import By
1915from selenium .common .exceptions import WebDriverException
2016
17+ if sys .platform .startswith ("linux" ):
18+ chromedriver_path = "/usr/lib/chromium-browser/chromedriver"
19+ elif sys .platform .startswith ("darwin" ):
20+ chromedriver_path = "chromedriver"
21+ else :
22+ print "Unsupported Operating System"
23+ sys .exit (3 )
24+
2125class bcolors :
2226 HEADER = '\033 [95m'
2327 OKBLUE = '\033 [94m'
@@ -34,25 +38,27 @@ class bcolors:
3438# First argument is optional, if not specified will search path.
3539
3640try :
37- driver = webdriver .Chrome ('/usr/lib/chromium-browser/chromedriver' , chrome_options = chromeOps )
41+ driver = webdriver .Chrome (chromedriver_path , chrome_options = chromeOps )
3842except WebDriverException as e :
3943 error = e .__str__ ()
4044
4145 if "executable needs to be in PATH" in e .__str__ ():
42- print "ChromeDriver isn't installed. Check test/chrome/README.md for instructions on how to install ChromeDriver"
46+ print "ChromeDriver isn't installed. Check test/chrome/README.md\
47+ for instructions on how to install ChromeDriver"
4348 sys .exit (0 )
4449 else :
4550 driver .quit ()
4651 raise e
47- sys .exit (2 )
52+
53+ print '' #New line
4854
4955driver .get ('http://libssh.org/robots.txt' )
5056
5157#Page Loaded
5258
5359if driver .current_url .startswith ('https' ):
5460 print bcolors .OKGREEN + "HTTP to HTTPS redirection successful" + bcolors .ENDC
55- elif ( driver .current_url .startswith ('http' ) ):
61+ elif driver .current_url .startswith ('http' ):
5662 print bcolors .FAIL + "HTTP to HTTPS redirection failed" + bcolors .ENDC
5763 sys .exit (1 )
5864
0 commit comments