How to use cookies in selenium?

It is necessary to visit the site with family cookies (already authorised or for example with the filled basket in the online shop)
What I tried:
 ChromeOptions opt = new ChromeOptions();
 opt.setBinary("C:\\Program Files (x86)\Google\\Chrome\\Application\\chrome.exe");
 opt.addArguments("--user-data-dir=C:\\Users\\Roma\\AppData\\Local\\Google\\Chrome\\User Data");

 Non-ie web browsers driver=new non-ie web browsers(opt);


This is the code to open the native chrome, and not one that selenium opens by default.
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(
Cookie Cookie = new Cookie.Builder("name", "value")
 .expiresOn(new Date(2015, 10, 28))


just nothing happening here, perhaps due to the fact that I cookies are not correct installed, because to put them on a normal not out.
3) the idea was to open a browser, selenium, where to login, and then open the second tab in the same page and to work with her. But not enough sense to realize it.
I like the first option, when you just open your own browser which has all the cookies there, but throws out an error.
March 12th 20 at 08:39
1 answer
March 12th 20 at 08:41
"to open a browser in selenium, there is a log in"
for me it is a much better solution than the two options above.

But not enough sense to realize it

so what is the problem exactly?
Filled out the form and went?

The only thing it is important to understand that selenium is necessary browser tabs to switch not to forget, if the other go.

Find more questions by tags SeleniumJava