Skip to content

Commit

Permalink
provide headless mode, partially addresses #1
Browse files Browse the repository at this point in the history
  • Loading branch information
Huitzilo committed Feb 15, 2022
1 parent 9686a8e commit e6d533c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion connect_UHVPN.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
' obtaining the authentification cookie through a browser' +\
' that is controlled through Selenium.')
parser.add_argument('-u','--username', help="UH username ([email protected])")
parser.add_argument('-s', '--silent', nargs='?', const=True, help="Use headless mode, i.e. don't show the browser window")
args = parser.parse_args()

username = args.username
Expand All @@ -26,6 +27,8 @@
service = Service(executable_path=ChromeDriverManager().install())
options = Options()
options.page_load_strategy = 'normal'
if silent:
options.headless = True
driver = webdriver.Chrome(service=service, options=options)
time.sleep(3)
driver.get("http://uhvpn.herts.ac.uk")
Expand All @@ -43,7 +46,7 @@
driver.switch_to.default_content()
iframe = driver.find_element(By.ID, "duo_iframe")
iframe.send_keys('\n')
WebDriverWait(driver,timeout=60).until(title_is("Secure Connect Secure - Home"))
WebDriverWait(driver,timeout=10).until(title_is("Secure Connect Secure - Home"))
dsid_cookie = driver.get_cookie('DSID')
print(dsid_cookie['value'])
driver.quit()
Expand Down

0 comments on commit e6d533c

Please sign in to comment.