Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Call for Presentations - Qt World Summit

    Unsolved Test PyQt5 GUI Headless on Windows for GitLab CI/CD

    General and Desktop
    pyqt5 headless qtqpaplatform qtooltip
    1
    1
    183
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A
      adamhendry last edited by

      I can run PyQt5 headless by setting the environment variable

      QT_QPA_PLATFORM=offscreen
      

      However, I'm not able to pass my test that a tooltip message appears when hovering over a toolbar button. I know this to work because the test passes when I run it in windowed mode:

      def test_toolbar_statusbar_and_tooltip_messages(app: MainApp, qtbot: QtBot) -> None:
          """Test for correct status bar message when a toolbar item is hovered.
      
          For example, when the user clicks 'File' in the menubar and hovers over 'New', the
          statusbar tooltip should read 'Create a new project...'.
      
          Args:
              app (MainApp): (fixture) Qt main application
              qtbot (QtBot): (fixture) Bot that imitates user interaction
          """
          # Arrange
          window = app.view
      
          statusbar = window.statusbar
          toolbar = window.toolbar
          new_action = window.new_action
      
          new_rect = toolbar.actionGeometry(new_action)
          tooltip = QtWidgets.QToolTip
      
          # Assert - Precondition
          assert statusbar.currentMessage() == ''
          assert tooltip.text() == ''
      
          # Act
          qtbot.mouseMove(toolbar, new_rect.center())
      
          # Assert - Postcondition
          def check_status():
              assert statusbar.currentMessage() == 'Create a new project...'
      
          def check_tooltip():
              assert tooltip.text() == 'New Project'
      
          qtbot.waitUntil(check_status)
          qtbot.waitUntil(check_tooltip)
      

      Is there a way to test this in headless mode?

      1 Reply Last reply Reply Quote 0
      • First post
        Last post