test_navbar_navigate.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. # Copyright 2023 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. if frame := inspect.currentframe():
  22. gui._set_frame(frame)
  23. gui.add_page(name="Data", page="<|navbar|id=nav1|> <|Data|id=text-data|>")
  24. gui.add_page(name="Test", page="<|navbar|id=nav1|> <|Test|id=text-test|>")
  25. helpers.run_e2e(gui)
  26. page.goto("./Data")
  27. page.expect_websocket()
  28. page.wait_for_selector("#text-data")
  29. page.click("#nav1 button:nth-child(2)")
  30. page.wait_for_selector("#text-test")
  31. expect(page).to_have_url(re.compile(".*Test"))
  32. page.click("#nav1 button:nth-child(1)")
  33. page.wait_for_selector("#text-data")
  34. expect(page).to_have_url(re.compile(".*Data"))