Skip to content
Snippets Groups Projects
Commit 4bcebe76 authored by Hague Matthew UXAC009's avatar Hague Matthew UXAC009
Browse files

add(moodle): add code for odd firefox in select-users

parent 1b9b5cac
Branches
No related tags found
No related merge requests found
......@@ -7,8 +7,8 @@
# If passed an assignment URL, it searches for the submissions page. If
# passed the user page it uses that directly.
#
# Usage:
# python3 assignment-select-users.py <mod_code> <ids.csv> <page-url>
# Usage: python3 assignment-select-users.py <mod_code> <ids.csv>
# <page-url>
#
# mod_code can be a comma-separated list
#
......@@ -22,6 +22,11 @@
# single click with this script
#
# Looks up ID numbers to email via LDAP
#
# You may want to edit FIREFOX_BINARY below or just a different browser
# instead of webdriver.Firefox. You may also want to externally set the
# environment variable TMPDIR if there's some reason you don't want to
# put a temporary Firefox profile in your normal /tmp (unlikely).
import browser_cookie3
import csv
......@@ -36,6 +41,7 @@ from typing import Dict, List, Optional, Set
from selenium import webdriver
from selenium.webdriver import Firefox
from selenium.webdriver.common.by import By
from selenium.webdriver.firefox.options import Options
LDAP_URI='ldaps://directory.rhul.ac.uk'
LDAP_BASE='DC=cc,DC=rhul,DC=local'
......@@ -50,6 +56,10 @@ WAIT_TIMEOUT = 10 # s
USER_PAGE = re.compile(".*/user/index.php.*")
# Leave blank for default binary
FIREFOX_BINARY = ""
#FIREFOX_BINARY = "org.mozilla.firefox"
class Browser:
"""Simple container of browser setup and teardown
......@@ -60,7 +70,12 @@ class Browser:
self.driver = None
def __enter__(self):
self.driver = webdriver.Firefox()
if len(FIREFOX_BINARY) > 0:
ops = Options()
ops.binary_location = FIREFOX_BINARY
self.driver = webdriver.Firefox(options=ops)
else:
self.driver = webdriver.Firefox()
self.driver.implicitly_wait(WAIT_TIMEOUT)
return self
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment