[Python] How can I make Selenium/Python wait for the user to login before continuing to run?

Discussão em 'Python' iniciado por Stack, Março 14, 2025.

  1. Stack

    Stack Membro Participativo

    I'm trying to run a script in Selenium/Python that requires logins at different points before the rest of the script can run. Is there any way for me to tell the script to pause and wait at the login screen for the user to manually enter a username and password (maybe something that waits for the page title to change before continuing the script).

    This is my code so far:

    from selenium import webdriver
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support.ui import Select
    from selenium.common.exceptions import NoSuchElementException
    from selenium.webdriver.common.keys import Keys
    import unittest, time, re, getpass

    driver = webdriver.Firefox()
    driver.get("https://www.facebook.com/")

    someVariable = getpass.getpass("Press Enter after You are done logging in")

    driver.find_element_by_xpath('//*[@id="profile_pic_welcome_688052538"]').click()

    Continue reading...

Compartilhe esta Página