ViewAsStudent

class autohandshake.ViewAsStudent(student_id: int, browser: autohandshake.src.HandshakeBrowser.HandshakeBrowser, stay_on_page: bool = False)

A sub-session in which the user logs in as a student.

Should be used as a context manager. Example:

with HandshakeSession(school_url, email) as browser:
    with ViewAsStudent(student_id):
        # do something
Parameters:
  • student_id (int) – the numeric Handshake id of the student to view as
  • browser (HandshakeBrowser) – a logged-in Handshake browser with a STAFF user type
  • stay_on_page (bool) – whether or not to stay on the same page when logging back out of the “View as Student” session. If False, navigate back to the Handshake homepage when the session is over. Defaults to False.
__enter__()

Log in as the specified student.

__exit__(exc_type, exc_val, exc_tb)

Stop viewing as the student and return to the career services view.

Example

from autohandshake import HandshakeSession, ViewAsStudent, CareerInterestsPage

student_id = 198427
career_clusters = ['Finance Cluster', 'STEM Cluster']

with HandshakeSession(school_url, email) as browser:
    with ViewAsStudent(student_id, browser):
        interests_page = CareerInterestsPage(student_id, browser)
        for cluster in career_clusters:
            interests_page.select_cluster_by_name(cluster)
        interests_page.save_interests()