Best Python code snippet using playwright-python
test_browsercontext_clearcookies.py
Source:test_browsercontext_clearcookies.py
...10# distributed under the License is distributed on an "AS IS" BASIS,11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.12# See the License for the specific language governing permissions and13# limitations under the License.14async def test_should_clear_cookies(context, page, server):15 await page.goto(server.EMPTY_PAGE)16 await context.add_cookies(17 [{"url": server.EMPTY_PAGE, "name": "cookie1", "value": "1"}]18 )19 assert await page.evaluate("document.cookie") == "cookie1=1"20 await context.clear_cookies()21 assert await context.cookies() == []22 await page.reload()23 assert await page.evaluate("document.cookie") == ""24async def test_should_isolate_cookies_when_clearing(context, server, browser):25 another_context = await browser.new_context()26 await context.add_cookies(27 [{"url": server.EMPTY_PAGE, "name": "page1cookie", "value": "page1value"}]28 )...
LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.
Get 100 minutes of automation test minutes FREE!!