Forums

Selenium shows an old screen | Python

I'm trying to automate my workflow with reddit using selenium with python but why do I keep getting this old login screen and not the new one

Why am I getting this https://gyazo.com/9b8bc716ea2bf53b0861b60a7391a95b

when basically I should get this https://gyazo.com/b01fdd4aca67a438aab4997e68adb39c

What site is that on and what code are you using?

I'm following this code and I keep getting the old screen when I screenshot from the driver

https://help.pythonanywhere.com/pages/selenium/

The site is reddit

It looks like the first screenshot shows a web site without any styling -- it's possible that the styling is being loaded asynchronuously or dependent on JS? If so, you may need to do some selenium trickery to wait until everything loads properly.

I made it to sleep for 50 second and didnt work , I keep getting the old screen and I getting element isn't located because the screen keeps showing the old one , i tried to host on Heroku and It works perfectly Here's my code

def logIn_selenium(driver,us,pw):
driver.get("https://www.reddit.com/login")

sleep(50)

username = driver.find_element(By.XPATH,"//*[@id='loginUsername']")
username.send_keys(us)
password = driver.find_element(By.XPATH,"//*[@id='loginPassword']")
password.send_keys(pw)
password.send_keys(Keys.RETURN)
sleep(5)
try:
    error = driver.find_element(By.CLASS_NAME,"AnimatedForm__errorMessage")
    if error.text == "Incorrect username or password":
        driver.quit()
        return "Incorrect username or password"
except:
    pass

return driver

if u noticed that im only typing username and password for the new reddit screen but selenium shows my old screen with a third input which is 2FA code ,while my account on reddit no 2FA is enabled

That sounds like it's some sort of issue either with reddit or with your interaction with reddit. We cannot help with either of those.

then why does the same code runs perfectly on Heroku

I don't know