2

I am trying to login into the following page using python, selenium and chrome:

https://www.etoro.com/login

You don't need my username and password to recreate this scenario. Use a made up username and password, it will work the same. If I open a 'normal' chrome window (so not using selenium) and try to login with any username/password (assuming it si incorrect) u get an 'invalid username/password' error.

normal chrome login

If I try to login using python selenium and chrome and use my username/password i get an error saying 'An error has occured, please try again'.

chrome login using selenium

Web page therefore recognises selenium and doesn't let me in. Is there anything I can do? I want this 'invalid username/password' also when using selenium and chrome, so that I can login with my correct username and password

Thanks in advance!

leeon
  • 51
  • 2
  • 8

1 Answers1

0

You cannot login using the normal chromedriver, but luckily you have two options:

Undetected chromedriver

Install it with pip install undetected-chromedriver (documentation), and then run

import undetected_chromedriver as uc
driver = uc.Chrome()
driver.get(url)
# do stuff to log in

Custom user profile

Alternatively, you can use the normal chromedriver and load a user profile where you are already logged in. With this method when you run driver.get(url) you will be already logged in, because it uses the cookies of the user profile. Here you can find a tutorial on how to create a user profile and load it in chromedriver

options = webdriver.ChromeOptions()
options.add_argument("user-data-dir=C:\\Users\\username\\AppData\\Local\\Google\\Chrome\\User Data")
options.add_argument("profile-directory=Profile 2")

driver = webdriver.Chrome(..., options=options)
driver.get(url)
# now you are already logged in
sound wave
  • 3,191
  • 3
  • 11
  • 29