Java – how to send cookies with selenium webdriver?

Every time I run my test, the first step is to log in, not I get to the page If you run this test, the login operation usually takes a lot of time

How do I log in?

Use chrome and Firefox driver and Java language

Solution

Create cookies using Java API, as follows:

Cookie ck = new Cookie("name","value");
driver.manage().addCookie(ck);

Create cookies using Python APIs as follows:

driver.add_cookie({'name': 'foo','value': 'bar'})
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>