
    ev                         d dl Z d dlmZ d dlmZmZ d dlZ ej        d           d dlm	Z	 ej
        j        ej
        j        gZ ej                    d             Zd ZdS )    N)HTTPConnection)PIPEPopen
playwright)expectc               #     K   t          g dt                    } d}|dk    rmt          d          }	 |                    dd           |                                }|n0n)# t
          $ r t          j        d           |dz  }Y nw xY w|dk    m|st          d	          	 d V  | 	                                 | 
                                 d S # | 	                                 | 
                                 w xY w)
N)pythonz-mzhttp.server8123z--directoryz
lite/dist/)stdout   r   zlocalhost:8123HEADz
index.html   zFailed to start http server)r   r   r   requestgetresponseConnectionRefusedErrortimesleepRuntimeError	terminatewait)processretriesconnresponses       Blib/python3.11/site-packages/panel/tests/ui/io/test_jupyterlite.pylaunch_jupyterliter      s-     LLLUY  G G
A++.//	LL...''))H# $% 	 	 	JqMMMqLGGG	 A++  :8999 	s   ,A! !#BB"C *C:c                 z   |                     d           |                    d          j                                         |                    d                                          dk    rb|                    d                              d           |                    d                              d                                           t          d          D ]>}|                    d	                                           |	                    d
           ?|                    d                              d           |j
                            d           t          |                    d                              d                              d                                        d           d S )Nz http://localhost:8123/index.htmlztext="Getting_Started.ipynb"z
.jp-Dialogr   z.jp-select-wrapper > selectzPython (Pyodide)z.jp-Dialog-footer > button   z8button[data-command="notebook:run-cell-and-select-next"]i  z.noUi-handlei )timeout
ArrowRightz.bk-panel-models-markup-HTMLdivprez0.1)gotolocatorfirstdblclickcountselect_optionnthclickrangewait_for_timeoutkeyboardpressr   to_have_text)r   page_s      r   test_jupyterlite_executionr2   *   s{   II0111LL/006??AAA ||L!!''))Q..233AABTUUU12266q99??AAA1XX # #OPPVVXXXc""""LL  &&z&:::M%%%
4<<677??FFNNuUUVVccdijjjjj    )r   http.clientr   
subprocessr   r   pytestimportorskipplaywright.sync_apir   markjupyterui
pytestmarkfixturer   r2    r3   r   <module>r?      s     & & & & & & " " " " " " " "   L ! ! ! & & & & & &k!6;>2
   4k k k k kr3   