Best Python code snippet using playwright-python
test_browsercontext_storage_state.py
Source:test_browsercontext_storage_state.py
...12# See the License for the specific language governing permissions and13# limitations under the License.14import json15import pytest16def test_should_capture_local_storage(context, is_webkit, is_win):17 if is_webkit and is_win:18 pytest.skip()19 page1 = context.new_page()20 page1.route("**/*", lambda route: route.fulfill(body="<html></html>"))21 page1.goto("https://www.example.com")22 page1.evaluate("localStorage['name1'] = 'value1'")23 page1.goto("https://www.domain.com")24 page1.evaluate("localStorage['name2'] = 'value2'")25 state = context.storage_state()26 origins = state["origins"]27 assert len(origins) == 228 assert origins[0] == {29 "origin": "https://www.example.com",30 "localStorage": [{"name": "name1", "value": "value1"}],...
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!!