@@ -31,14 +31,7 @@ e.g. http://example.com/some404page)
31
31
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/interactions/CookiesTest.java#L30-L32" >}}
32
32
{{< /tab >}}
33
33
{{< tab header="Python" >}}
34
- from selenium import webdriver
35
-
36
- driver = webdriver.Chrome()
37
-
38
- driver.get("http://www.example.com ")
39
-
40
- # Adds the cookie into current browser context
41
- driver.add_cookie({"name": "key", "value": "value"})
34
+ {{< gh-codeblock path="examples/python/tests/interactions/test_cookies.py#L5-L9" >}}
42
35
{{< /tab >}}
43
36
{{< tab header="CSharp" text=true >}}
44
37
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/CookiesTest.cs#L32-L34" >}}
@@ -87,18 +80,7 @@ It returns the serialized cookie data matching with the cookie name among all as
87
80
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/interactions/CookiesTest.java#L38-L42" >}}
88
81
{{< /tab >}}
89
82
{{< tab header="Python" >}}
90
- from selenium import webdriver
91
-
92
- driver = webdriver.Chrome()
93
-
94
- # Navigate to url
95
- driver.get("http://www.example.com ")
96
-
97
- # Adds the cookie into current browser context
98
- driver.add_cookie({"name": "foo", "value": "bar"})
99
-
100
- # Get cookie details with named cookie 'foo'
101
- print(driver.get_cookie("foo"))
83
+ {{< gh-codeblock path="examples/python/tests/interactions/test_cookies.py#L13-L20" >}}
102
84
{{< /tab >}}
103
85
{{< tab header="CSharp" text=true >}}
104
86
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/CookiesTest.cs#L40-L44" >}}
@@ -151,18 +133,7 @@ If browser is no longer available it returns error.
151
133
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/interactions/CookiesTest.java#L52-L66" >}}
152
134
{{< /tab >}}
153
135
{{< tab header="Python" >}}
154
- from selenium import webdriver
155
-
156
- driver = webdriver.Chrome()
157
-
158
- # Navigate to url
159
- driver.get("http://www.example.com ")
160
-
161
- driver.add_cookie({"name": "test1", "value": "cookie1"})
162
- driver.add_cookie({"name": "test2", "value": "cookie2"})
163
-
164
- # Get all available cookies
165
- print(driver.get_cookies())
136
+ {{< gh-codeblock path="examples/python/tests/interactions/test_cookies.py#L24-L32" >}}
166
137
{{< /tab >}}
167
138
{{< tab header="CSharp" text=true >}}
168
139
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/CookiesTest.cs#L51-L64" >}}
@@ -217,16 +188,7 @@ It deletes the cookie data matching with the provided cookie name.
217
188
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/interactions/CookiesTest.java#L74-L77" >}}
218
189
{{< /tab >}}
219
190
{{< tab header="Python" >}}
220
- from selenium import webdriver
221
- driver = webdriver.Chrome()
222
-
223
- # Navigate to url
224
- driver.get("http://www.example.com ")
225
- driver.add_cookie({"name": "test1", "value": "cookie1"})
226
- driver.add_cookie({"name": "test2", "value": "cookie2"})
227
-
228
- # Delete a cookie with name 'test1'
229
- driver.delete_cookie("test1")
191
+ {{< gh-codeblock path="examples/python/tests/interactions/test_cookies.py#L35-L43" >}}
230
192
{{< /tab >}}
231
193
{{< tab header="CSharp" text=true >}}
232
194
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/CookiesTest.cs#L70-L73" >}}
@@ -284,16 +246,7 @@ It deletes all the cookies of the current browsing context.
284
246
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/interactions/CookiesTest.java#L100-L105" >}}
285
247
{{< /tab >}}
286
248
{{< tab header="Python" >}}
287
- from selenium import webdriver
288
- driver = webdriver.Chrome()
289
-
290
- # Navigate to url
291
- driver.get("http://www.example.com ")
292
- driver.add_cookie({"name": "test1", "value": "cookie1"})
293
- driver.add_cookie({"name": "test2", "value": "cookie2"})
294
-
295
- # Deletes all cookies
296
- driver.delete_all_cookies()
249
+ {{< gh-codeblock path="examples/python/tests/interactions/test_cookies.py#L47-L55" >}}
297
250
{{< /tab >}}
298
251
{{< tab header="CSharp" text=true >}}
299
252
{{< gh-codeblock path="examples/dotnet/SeleniumDocs/Interactions/CookiesTest.cs#L92-L97" >}}
@@ -381,18 +334,7 @@ public class cookieTest {
381
334
}
382
335
{{< /tab >}}
383
336
{{< tab header="Python" >}}
384
- from selenium import webdriver
385
-
386
- driver = webdriver.Chrome()
387
-
388
- driver.get("http://www.example.com ")
389
- # Adds the cookie into current browser context with sameSite 'Strict' (or) 'Lax'
390
- driver.add_cookie({"name": "foo", "value": "value", 'sameSite': 'Strict'})
391
- driver.add_cookie({"name": "foo1", "value": "value", 'sameSite': 'Lax'})
392
- cookie1 = driver.get_cookie('foo')
393
- cookie2 = driver.get_cookie('foo1')
394
- print(cookie1)
395
- print(cookie2)
337
+ {{< gh-codeblock path="examples/python/tests/interactions/test_cookies.py#L59-L71" >}}
396
338
{{< /tab >}}
397
339
{{< tab header="CSharp" >}}
398
340
using OpenQA.Selenium;
0 commit comments