0 votes
1 view
in Devops and Agile by (19.8k points)

Every time when I run my test first step is login and then I get to the desired page. I run this test often log in operation takes a lot of time.

How can I pass a login operation?

Using Chrome and Firefox drivers, java language.

1 Answer

0 votes
by (63.4k points)

Create cookies using the Java API as follows:

Cookie ck = new Cookie("name", "value");

driver.manage().addCookie(ck);

Create cookies using the Python API as follows:

driver.add_cookie({'name': 'foo', 'value': 'bar'})

For those who need to set more detailed information on Cookie besides name and value you can use:

 Cookie cookie = new Cookie.Builder("name", "value")

    .domain(".mydomain.com")

    .expiresOn(new Date(2019, 07, 18))

    .isHttpOnly(true)

    .isSecure(false)

    .path("/mypath")

    .build();

driver.manage().addCookie(cookie);

I hope this helps!

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...