kazurayam / chromedriverfactory

A Java library that enables you to launch Selenium ChromeDriver using an existing user Profile. That let you to carry cookies over multiple HTTP sessions via user Profile.
0 stars 0 forks source link

new project : CarryingCookieOverSessionsViaProfile #38

Closed kazurayam closed 2 years ago

kazurayam commented 2 years ago

v0.6.0-SNAPSHOT has a test CarryCookieOverSessionsViaProfile. This test code is important to prove the value of the chromedriverfactory library.

This test code depends on the Selenium 4 (Chrome DevTools Protocol support). On the other hand the chromedriverfactory library should work on Selenium 3. This mismatch makes the tests failing.

I should create a new project for CarryingCookieOverSessionsViaProfile test. I will make it dependent on Selenium 4, whereas I will make the chromedriverfactory library dependent on Selenium 3 only.

kazurayam commented 2 years ago

I have made it:

https://github.com/kazurayam/CarryingCookieOverSessionsViaChromeProfile

kazurayam commented 2 years ago

In the #37, I added a new class CookieServer, which is a HTTP Server. This server helps ChromeDriver as a pair of HTTP Client and HTTP Server.

The CookieServer can emit the following message in the console:

Starting ChromeDriver 96.0.4664.45 (76e4c1bb2ab4671b8beba3444e61c0f17584b2fc-refs/branch-heads/4664@{#947}) on port 30054
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
[1642383724.864][WARNING]: This version of ChromeDriver has not been tested with Chrome version 97.
1 17, 2022 10:42:05 午前 org.openqa.selenium.remote.ProtocolHandshake createSession
情報: Detected dialect: W3C

<<<< Request received
method = GET
uri = /
body = 

==== Cookies cooked
in the request:  no cookies found
in the response: cookies=[timestamp=Mon, 17 Jan 2022 01:42:05 GMT; Max-Age=35;]

>>>> Response sent
/ is a directory.

<<<< Request received
method = GET
uri = /favicon.ico
body = 

==== Cookies cooked
in the request:  cookies=[timestamp=Mon, 17 Jan 2022 01:42:05 GMT]
in the response: cookies=[timestamp=Mon, 17 Jan 2022 01:42:05 GMT; max-age=35]

>>>> Response sent
favicon.ico is not found.

This message is very informative. We can trace how the cookies were processed by the server; and we can tell what sort of cookies browsers sent and received during HTTP session.

kazurayam commented 2 years ago

v0.6.0-SNAPSHOT has a test CarryCookieOverSessionsViaProfile used the CDP API of Selenium 4 in order to monitor the activities by browser for Cookies.

Now I do not need the CDP API. I should revive the CarryCookieOverSessionsViaProfile test without CDP provided with the new CookieServer.

kazurayam commented 2 years ago

I will restore the CarryingCookieOverSssionsViaProfile test in the chromedriverfactory project without relying on the CDP API of Selenium 4, but with CookieServer.

kazurayam commented 2 years ago

I have restored it https://github.com/kazurayam/chromedriverfactory/blob/master/src/test/groovy/com/kazurayam/webdriverfactory/chrome/CarryingCookieOverSessionsViaProfile.groovy

The code is much simpler than the code using CDP API. The code provides enough diagnostics how cookies are operated. I like this.