code: def test_handles_callback_on_change_correctly(app: Page):
      """Test that it correctly calls the callback on change."""
      # Check initial state:
      expect(app.get_by_test_id("stMarkdown").nth(7)).to_have_text(
          "value 8: female", use_inner_text=True
      )
      expect(app.get_by_test_id("stMarkdown").nth(8)).to_have_text(
          "selectbox changed: False", use_inner_text=True
      )
  
      app.get_by_test_id("stSelectbox").nth(7).locator("input").click()
  
      # Select last option:
      selection_dropdown = app.locator('[data-baseweb="popover"]').first
      selection_dropdown.locator("li").first.click()
  
      # Check that selection worked:
      expect(app.get_by_test_id("stMarkdown").nth(7)).to_have_text(
          "value 8: male", use_inner_text=True
      )
      expect(app.get_by_test_id("stMarkdown").nth(8)).to_have_text(
          "selectbox changed: True", use_inner_text=True
      )
  
      # Change different input to trigger delta path change
      empty_selectbox_input = (
          app.get_by_test_id("stSelectbox").locator("input").first
      )
  
      # Type an option:
      empty_selectbox_input.type("female")
      empty_selectbox_input.press("Enter")
  
      expect(app.get_by_test_id("stMarkdown").first).to_have_text(
          "value 1: female", use_inner_text=True
      )
      expect(app.get_by_test_id("stMarkdown").nth(7)).to_have_text(
          "value 8: male", use_inner_text=True
      )
      expect(app.get_by_test_id("stMarkdown").nth(8)).to_have_text(
          "selectbox changed: False", use_inner_text=True
      )
  
file_path: streamlit/e2e_playwright/st_selectbox_test.py
imports: from playwright.sync_api import Page, expect
  from e2e_playwright.conftest import ImageCompareFunction
label_desc: Use image node_id 8 for calling a global function with example usage: test_handles_callback_on_change_correctly(app) without return types