test_navbar_navigate.py 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. # Copyright 2021-2025 Avaiga Private Limited
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
  4. # the License. You may obtain a copy of the License at
  5. #
  6. # http://www.apache.org/licenses/LICENSE-2.0
  7. #
  8. # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
  9. # an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
  10. # specific language governing permissions and limitations under the License.
  11. import inspect
  12. import re
  13. from importlib import util
  14. import pytest
  15. if util.find_spec("playwright"):
  16. from playwright._impl._page import Page
  17. from playwright.sync_api import expect
  18. from taipy.gui import Gui
  19. @pytest.mark.teste2e
  20. def test_navbar_navigate(page: "Page", gui: Gui, helpers):
  21. gui._set_frame(inspect.currentframe())
  22. gui.add_page(name="Data", page="<|navbar|id=nav1|> <|Data|id=text-data|>")
  23. gui.add_page(name="Test", page="<|navbar|id=nav1|> <|Test|id=text-test|>")
  24. helpers.run_e2e(gui)
  25. page.goto("./Data")
  26. page.expect_websocket()
  27. page.wait_for_selector("#text-data")
  28. page.click("#nav1 button:nth-child(2)")
  29. page.wait_for_selector("#text-test")
  30. expect(page).to_have_url(re.compile(".*Test"))
  31. page.click("#nav1 button:nth-child(1)")
  32. page.wait_for_selector("#text-data")
  33. expect(page).to_have_url(re.compile(".*Data"))