-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
provide headless mode, partially addresses #1
- Loading branch information
Showing
1 changed file
with
4 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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") | ||
|
@@ -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() | ||
|