Can I launch Selenium ChromeDriver using cookies from an actual Chrome installation?

So, I run the selenium test using IntelliJ IDEA + chromedriver on an Ubuntu machine ...

In my Google Chrome installation, I signed up for an account, say, Google. When I access http://accounts.google.com in the selenium test, I get to the login page instead of the real account management page.

I am sure that I do not quite understand how Selenium and the chrome driver work, but I remember that having Google Chrome installed in the default location is one of the requirements for running the selenium test with the chrome driver.

Can I run in the context of my installed browser, that is, have access to my browser history and cookies?

+4
source share
1 answer

Each time Selenium opens a browser (Chrome / Firefox / IE), it opens the canonical form of this browser. As a tester, you can configure browser settings using the DesiredCapabilities object, and for chrome, you can also use the ChromeOptions object to pass chrome command line arguments.

To choose your profile

ChromeOptions options = new ChromeOptions();
options.addArguments("user-data-dir=/path/to/your/custom/profile");

Learn more about chrome driver features: https://sites.google.com/a/chromium.org/chromedriver/capabilities

More on the user-data-dir command-line option for chrome:
https://www.chromium.org/user-experience/user-data-directory

+3
source

Source: https://habr.com/ru/post/1619202/


All Articles