How to log in with a two step authentication using selenium in python

Viewed 99

The login options are either using facebook or apple which then directs you to a new page where you have to login on those services and then it redirects you back. Or entering your email, it then sends you an email with a link that when clicked opens the page but then logged in.

How can I automate this? By saving the cookies? How would I do that in this case?

picture of the log in field

1 Answers

you can save your logged-in session by doing the following:

i am Linux User

in Ubuntu:

import os

dir_path = os.getcwd()

profile = os.path.join(dir_path, "profile", "facebook")

option.add_argument(r"user-data-dir={}".format(profile))

browser = webdriver.Chrome(options=option,executable_path='./chromedriver')

if you use windows it will only change the way of indicating the path of the chromedriver. If it has in its default system path, just delete this path indication (valid for both Linux and Windows)

Related