class_docstr: Subclasses ScriptRunner to provide some testing features.
class_docstr_tok: ["Subclasses","ScriptRunner","to","provide","some","testing","features","."]
docstr: Run the script, and parse the output messages for querying
  and interaction.
  
  Timeout is in seconds.
docstr_tok: ["Run","the","script",",","and","parse","the","output","messages","for","querying","and","interaction",".","Timeout","is","in","seconds","."]
code: def run(
      self,
      widget_state: WidgetStates | None = None,
      query_params=None,
      timeout: float = 3,
  ) -> ElementTree:
      """Run the script, and parse the output messages for querying
      and interaction.
  
      Timeout is in seconds.
      """
      # TODO: save the query strings from the script run
      query_string = ""
      if query_params:
          query_string = parse.urlencode(query_params, doseq=True)
  
      rerun_data = RerunData(
          widget_states=widget_state, query_string=query_string
      )
      self.request_rerun(rerun_data)
      if not self._script_thread:
          self.start()
      require_widgets_deltas(self, timeout)
  
      tree = parse_tree_from_messages(self.forward_msgs())
      return tree
  
imports: from __future__ import annotations
  import os
  import time
  from typing import Any
  from urllib import parse
  from streamlit import runtime
  from streamlit.proto.ForwardMsg_pb2 import ForwardMsg
  from streamlit.proto.WidgetStates_pb2 import WidgetStates
  from streamlit.runtime.forward_msg_queue import ForwardMsgQueue
  from streamlit.runtime.memory_uploaded_file_manager import MemoryUploadedFileManager
  from streamlit.runtime.scriptrunner import RerunData, ScriptRunner, ScriptRunnerEvent
  from streamlit.runtime.scriptrunner.script_cache import ScriptCache
  from streamlit.runtime.scriptrunner.script_run_context import ScriptRunContext
  from streamlit.runtime.state.safe_session_state import SafeSessionState
  from streamlit.testing.v1.element_tree import ElementTree, parse_tree_from_messages
label_desc: Use image node_id 4 for calling the LocalScriptRunner obj's underlying member method code with example usage: obj.run(widget_state, query_params, timeout) and returns: tree