From 005197bf32e7a24f23726191b92b010ab937c9b0 Mon Sep 17 00:00:00 2001 From: Node <8974108+qwenode@users.noreply.github.com> Date: Thu, 30 Sep 2021 09:14:04 +0800 Subject: [PATCH 1/3] Solve #130 when cookies expiry is 0, unable to successfully adding cookie --- remote.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/remote.go b/remote.go index 09a16cb..375e9d3 100644 --- a/remote.go +++ b/remote.go @@ -10,6 +10,7 @@ import ( "errors" "fmt" "io/ioutil" + "math" "mime" "net/http" "net/url" @@ -1009,6 +1010,9 @@ func (wd *remoteWD) GetCookies() ([]Cookie, error) { } func (wd *remoteWD) AddCookie(cookie *Cookie) error { + if cookie.Expiry==0 { + cookie.Expiry = math.MaxUint32 + } return wd.voidCommand("/session/%s/cookie", map[string]*Cookie{ "cookie": cookie, }) From 452e9480c1cf2cf22ba5bd751abcb7fee7c1f380 Mon Sep 17 00:00:00 2001 From: Node <8974108+qwenode@users.noreply.github.com> Date: Fri, 29 Oct 2021 13:20:43 +0800 Subject: [PATCH 2/3] go fmt --- remote.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/remote.go b/remote.go index 375e9d3..e62554e 100644 --- a/remote.go +++ b/remote.go @@ -1010,7 +1010,7 @@ func (wd *remoteWD) GetCookies() ([]Cookie, error) { } func (wd *remoteWD) AddCookie(cookie *Cookie) error { - if cookie.Expiry==0 { + if cookie.Expiry == 0 { cookie.Expiry = math.MaxUint32 } return wd.voidCommand("/session/%s/cookie", map[string]*Cookie{ From eaaaa05990374f730d185c7df256a90ffd5fd3f1 Mon Sep 17 00:00:00 2001 From: Node <8974108+qwenode@users.noreply.github.com> Date: Fri, 29 Oct 2021 13:26:24 +0800 Subject: [PATCH 3/3] add document in the AddCookie method in the Selenium interface. --- remote.go | 1 + 1 file changed, 1 insertion(+) diff --git a/remote.go b/remote.go index e62554e..c867c91 100644 --- a/remote.go +++ b/remote.go @@ -1010,6 +1010,7 @@ func (wd *remoteWD) GetCookies() ([]Cookie, error) { } func (wd *remoteWD) AddCookie(cookie *Cookie) error { + //if cookie.Expiry is zero, AddCookie is not effective, @see https://github.com/tebeka/selenium/issues/130 if cookie.Expiry == 0 { cookie.Expiry = math.MaxUint32 }