F
F
fandorin_official2019-05-30 07:33:39
Python
fandorin_official, 2019-05-30 07:33:39

How to use authorization in autotests?

All good.
Who knows if I can use the authorization on the site that was performed on the site earlier when running autotests?
For example, there is a task to write an autotest for ok.ru. Logged into the site, everything is chin-chin. But when the autotest starts, there is no authorization, you need to log in, etc.
Is it possible to somehow use an already authorized session when starting an autotest?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
nekitvand, 2019-05-30
@nekitvand

It would be best to look in the direction of the cookie dump.
https://stackoverflow.com/questions/15058462/how-t...

M
Michael, 2019-05-30
@moonz

To do this, you need to launch the browser with the profile parameter. On the first run, selenium will create a folder where the cookies will be stored, on subsequent runs they will be picked up

options = webdriver.ChromeOptions()
options.add_argument(r"user-data-dir=C:\profile_folder")
driver = webdriver.Chrome(executable_path="C:\\chromedriver.exe", chrome_options=options)

That is, you can use the construction:
driver.get(" https://ok.ru ")
time.sleep(1000)
Pass authorization manually through the browser window.
Close the browser window (not by stopping the script, but by handles)
Profit!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question