
    ~@;j                   *   d dl mZ d dlmZ d dlmZ d dlmZ d dlmZ d dl	m
Z
 d dlZd dlmZmZmZmZmZmZ d d	lmZ d d
lmZmZmZmZ d dlmZmZ d dlmZ d dlm Z  d dl!m"Z"m#Z# d dl$m%Z% d dl&m'Z' d dl(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/  G d de0          Z1dS )    )annotations)time)Logger)Role)States)
TextReaderN)ArraybyrefCDLLc_charc_longcreate_string_buffer)HWND)Any	GeneratorOptionalUnion)Image	ImageGrab)By)JABException)jint	JOBJECT64)
Win32Utils)XpathParser)AccessibleActionsAccessibleActionsToDoAccessibleContextInfoAccessibleTableCellInfoAccessibleTableInfoAccessibleTextInfoVisibleChildrenInfoc                  (   e Zd ZdZ e            Z e            Z	 	 	 	 dddZe	dd            Z
e
j        dd            Z
e	dd            Zej        dd            Ze	dd            Zej        dd            Ze	dd            Zej        dd            Ze	dd            Ze	dd            Ze	dd            Ze	dd            Ze	dd            Ze	dd            Ze	dd            Ze	dd            Ze	dd             Ze	dd"            Ze	dd$            Ze	dd%            Ze	dd&            Ze	dd'            Ze	dd(            Ze	dd)            Ze	dd*            Z	 ddd/Z 	 ddd0Z!ddd1Z"ddd2Z#	 ddd3Z$	 ddd5Z%dd6Z&dd9Z'ddd:Z(	 ddd;Z)	 ddd=Z*ddd>Z+	 ddd@Z,	 dddFZ-	 dddHZ.	 dddIZ/	 dddJZ0	 dddKZ1	 dddLZ2	 dddPZ3dddQZ4	 dddSZ5dddUZ6dddWZ7dddZZ8ddd^Z9ddd`Z:dddcZ;dddZ<ddfZ=dddgZ>dddhZ?dddiZ@dddjZAdddkZB	 dddmZCdddnZDdddqZEddrZFddsZGddtZHdduZIddvZJddwZKdddxZL	 dddyZMdddzZNddd|ZO	 ddd}ZP	 ddd~ZQ	 dddZReSdd            ZTeSdd            ZUeSdd            ZVeSdd            ZWeSdd            ZXeSdd            ZYeSdd            ZZddZ[dddZ\	 	 	 dddZ]dddZ^e_j`        dd+fddZa	 dddZb	 dddZc	 dddZd	 dddZe	 dddZf	 dddZg	 dddZh	 	 	 dddZidddZj	 dddZk	 dddZle_j`        dd+fddZmeSdd            Zne	dd            Zoe	dd            ZpddZqddZre	d             ZsdddZtddZueS	 	 ddd            ZveS	 	 ddd            ZwdS )
JABElementz"Java Access Bridge func '{}' errorNbridger   hwndr   vmidr   accessible_contextr   returnNonec                ~    t          d          | _        || _        || _        || _        || _        | j        | _        d S )Npyjab)r   logger_bridge_hwnd_vmid_accessible_context_get_accessible_context_info	_acc_info)selfr%   r&   r'   r(   s        ^C:\Users\Administrator\AppData\Local\Temp\2\pip-target-b0z114gj\lib\python\pyjab/jabelement.py__init__zJABElement.__init__#   s<     Woo

#5 :    c                    | j         S Nr.   r4   s    r5   r%   zJABElement.bridge2   s
    |r7   c                    || _         d S r9   r:   )r4   r%   s     r5   r%   zJABElement.bridge6   s    r7   c                    | j         S r9   r/   r;   s    r5   r&   zJABElement.hwnd:   
    zr7   c                    || _         d S r9   r>   )r4   r&   s     r5   r&   zJABElement.hwnd>       


r7   c                    | j         S r9   r0   r;   s    r5   r'   zJABElement.vmidB   r?   r7   c                    || _         d S r9   rC   )r4   r'   s     r5   r'   zJABElement.vmidF   rA   r7   c                    | j         S r9   r1   r;   s    r5   r(   zJABElement.accessible_contextJ   s    ''r7   c                    || _         d S r9   rF   r4   r(   s     r5   r(   zJABElement.accessible_contextN   s    #5   r7   strc                4    |                                  j        S r9   )r3   namer;   s    r5   rK   zJABElement.nameR       ~~$$r7   c                4    |                                  j        S r9   )r3   descriptionr;   s    r5   rN   zJABElement.descriptionV   s    ~~++r7   c                4    |                                  j        S r9   )r3   roler;   s    r5   rP   zJABElement.roleZ   rL   r7   c                4    |                                  j        S r9   )r3   
role_en_USr;   s    r5   
role_en_uszJABElement.role_en_us^   s    ~~**r7   c                Z    |                                  j                            d          S N,)r3   statessplitr;   s    r5   rW   zJABElement.statesb   s#    ~~&,,S111r7   c                Z    |                                  j                            d          S rU   )r3   states_en_USrX   r;   s    r5   states_en_uszJABElement.states_en_usf   s#    ~~,223777r7   intc                *    |                                  S r9   )_get_object_depthr;   s    r5   object_depthzJABElement.object_depthj   s    %%'''r7   c                4    |                                  j        S r9   )r3   indexInParentr;   s    r5   index_in_parentzJABElement.index_in_parentn       ~~--r7   c                4    |                                  j        S r9   )r3   childrenCountr;   s    r5   children_countzJABElement.children_countr   rc   r7   dictc                    |                                  j        |                                  j        |                                  j        |                                  j        dS )N)xyheightwidth)r3   ri   rj   rk   rl   r;   s    r5   boundszJABElement.boundsv   sS     !!#!!#nn&&-^^%%+	
 
 	
r7   boolc                N    t          |                                 j                  S r9   )rn   r3   accessibleComponentr;   s    r5   accessible_componentzJABElement.accessible_component       DNN$$8999r7   c                N    t          |                                 j                  S r9   )rn   r3   accessibleActionr;   s    r5   accessible_actionzJABElement.accessible_action   s    DNN$$5666r7   c                N    t          |                                 j                  S r9   )rn   r3   accessibleSelectionr;   s    r5   accessible_selectionzJABElement.accessible_selection   rr   r7   c                N    t          |                                 j                  S r9   )rn   r3   accessibleTextr;   s    r5   accessible_textzJABElement.accessible_text   s    DNN$$3444r7   c                    dS NF r;   s    r5   accessible_interfacesz JABElement.accessible_interfaces   s	     ur7   c                :   | j         ry|                                 }d}|j        dz
  }|dz   |z
  }t          |dz   dz            }|                     ||||           t                                          ||d          S | j                            d           d S )Nr         utf_16)buffer	chars_lenencodingz3current JABElement does not support Accessible Text)	r{   _get_accessible_text_info	charCountr   _get_accessible_text_ranger   get_text_from_raw_bytesr-   warning)r4   txt_infochars_start	chars_endr   r   s         r5   textzJABElement.text   s     	W5577HK *Q.I!A3I)9q=A*=>>F++KFIVVV<<77X 8    K UVVVVVr7   c                   | j         t          j        k    r|                                 }|j        |j        d}|                                 }|j        |j        d|d<   |                                 }|j        |j        d|d<   |                                 }| 	                                }||d|d<   |S | j
                            d           d S )N)	row_countcolumn_countrow_headerscolumn_headersselectedz,current JABElement does not Accessible Table)rS   r   TABLE_get_accessible_table_inforowCountcolumnCount _get_accessible_table_row_header#_get_accessible_table_column_header)_get_accessible_table_row_selection_count,_get_accessible_table_column_selection_countr-   r   )r4   infotbr   r   s        r5   tablezJABElement.table   s    ?dj((2244D!] $ 0 B 88::D!] $ 0! !B} ;;==D!] $ 0$ $B  FFHHILLNNL& , BzN IK NOOOOOr7   F
jabelementvisibleGenerator[JABElement]c              #     K   |p%t          | j        | j        | j        | j                  }|                     ||          D ]*}|j        r|                     ||          E d{V  |V  +dS )a  generate all child jab elements from a jab element.

        Args:
            jabelement (JABElement, optional): The parent jab element to generate child jab elements.
            Defaults to None use current element.
            visible (bool, optional): The switch for find only visible child jab elements or not.
            Defaults to False to find all child elements.

        Yields:
            Generator: Generator of all child jab elements from this parent jab element.
        r   r   N)r$   r%   r&   r'   r(   _generate_childs_from_elementrf   _generate_all_childs)r4   r   r   _jabelements       r5   r   zJABElement._generate_all_childs   s         
:KDIt/F$
 $

  ==%w > 
 
 	 	K ) 44*G 5          	 	r7   c              #  
  K   |p%t          | j        | j        | j        | j                  }|rv|                     |j                  }|                     |j                  }t          |          D ]0}t          |j        |j        |j        |j        |                   V  1dS t          |j	                  D ]K}|j        
                    |j        |j        |          }t          |j        |j        |j        |          V  LdS )a  generate child jab elements from a jab element.

        Args:
            jabelement (JABElement, optional): The parent jab element to generate child jab elements.
            Defaults to None use current element.
            visible (bool, optional): The switch for find only visible child jab elements or not.
            Defaults to False to find all child elements.

        Yields:
            Generator: Generator of child jab elements from this parent jab element.
        N)r$   r%   r&   r'   r(   _get_visible_children_count_get_visible_childrenrangechildrenrf   getAccessibleChildFromContext)r4   r   r   rf   r   index	child_accs          r5   r   z(JABElement._generate_childs_from_element   sF        
:KDIt/F$
 $

  	!==- N --j.KLLD~..   %OOM%(	       z899  &-KKOZ%BE 	 !%z
     	 r7   c                f    |r|j         n| j         }| j                            | j        |           dS )ac  Release the memory used by the Java object object,
        where object is an object returned to you by Java Access Bridge.
        Java Access Bridge automatically maintains a reference
        to all Java objects that it returns to you in the JVM
        so they are not garbage collected. To prevent memory leaks,
        you must call ReleaseJavaObject on all Java objects returned
        to you by Java Access Bridge once you are finished with them.
        See JavaFerret.c for an illustration of how to do this.

        Args:
            jabelement (JABElement): The JABElement need to release
        N)r(   r%   releaseJavaObjectr'   )r4   r   r(   s      r5   release_jabelementzJABElement.release_jabelement  s?     .8TJ))T=T 	 	%%di1CDDDDDr7   c                X    |p| j         }| j                            | j        |           dS )z:Request focus for a component. Returns whether successful.N)r(   r%   requestFocusr'   rH   s     r5   _request_focuszJABElement._request_focus  s1    /J43J  ,>?????r7   c                V    |p| j         }| j                            | j        |d          S )Nr   )r(   r%   !getAccessibleSelectionFromContextr'   rH   s     r5   &_get_accessible_selection_from_contextz1JABElement._get_accessible_selection_from_context  s6     0J43J{<<I)1
 
 	
r7   r   c                Z    |p| j         }| j                            | j        ||           d S r9   )r(   r%   !addAccessibleSelectionFromContextr'   )r4   r   r(   s      r5   &_add_accessible_selection_from_contextz1JABElement._add_accessible_selection_from_context"  s@     0J43J55I)5	
 	
 	
 	
 	
r7   c                X    |p| j         }| j                            | j        |           d S r9   )r(   r%   #clearAccessibleSelectionFromContextr'   rH   s     r5   (_clear_accessible_selection_from_contextz3JABElement._clear_accessible_selection_from_context*  s3     0J43J77	CUVVVVVr7   obj1obj2c                ^    t          | j                            | j        ||                    S )zReturns whether two object references are for the same object.

        Args:
            obj1 (JOBJECT64): Object 1.
            obj2 (JOBJECT64): Object 2.

        Returns:
            bool: Rerturns whether two object is same or not.
        )rn   r%   isSameObjectr'   )r4   r   r   s      r5   _is_same_objectzJABElement._is_same_object0  s(     DK,,TYdCCDDDr7   c                    |p| j         }| j                            | j        |          }|dk    r't	          | j                            d                    |S )a  Returns the AccessibleContext for the top level object in a Java window.
        This is same AccessibleContext that is obtained from GetAccessibleContextFromHWND for that window.
        Returns (AccessibleContext)0 on error.

        Args:
            accessible_context (JOBJECT64, optional): Accessible Context. Defaults to None.

        Raises:
            JABException: Get top level object error.

        Returns:
            JOBJECT64: Top level object.
        r   getTopLevelObject)r(   r%   r   r'   r   int_func_err_msgformat)r4   r(   
top_objects      r5   _get_top_level_objectz JABElement._get_top_level_object<  s[     0J43J[2249>PQQ
??t4;;<OPPQQQr7   c                T    |p| j         }| j                            | j        |          S )a  Returns an AccessibleContext object that represents the parent of object ac.

        Args:
            accessible_context (JOBJECT64, optional): Accessible Context. Defaults to None.

        Returns:
            JOBJECT64: Parent Accessible Context.
        )r(   r%   getAccessibleParentFromContextr'   rH   s     r5   #_get_accessible_parent_from_contextz.JABElement._get_accessible_parent_from_contextP  s-     0J43J{99$)EWXXXr7   r   c                    t                      }|p| j        }| j                            | j        |t          |                    }|dk    r't          | j                            d                    |S )a]  Retrieves an AccessibleContextInfo object of the AccessibleContext object ac.

        Args:
            accessible_context (JOBJECT64, optional): Accessible Context. Defaults to None.

        Raises:
            JABException: Get Accessible Context Info error.

        Returns:
            AccessibleContextInfo: Accessible Context Info.
        r   GetAccessibleContextInfo)	r   r(   r%   getAccessibleContextInfor'   r
   r   r   r   r4   r(   r   results       r5   r2   z'JABElement._get_accessible_context_info^  st     %&&/J43J55I)5;;
 
 Q;;t4;;<VWWXXXr7   c                    |p| j         }| j                            | j        |          }|dk    r't	          | j                            d                    |S )a  Returns how deep in the object hierarchy a given object is.
        The top most object in the object hierarchy has an object depth of 0.
        Returns -1 on error.

        Args:
            accessible_context (JOBJECT64, optional): Accessible Context. Defaults to None.

        Raises:
            JABException: Get Object Depth error.

        Returns:
            int: Object depth.
        getObjectDepth)r(   r%   r   r'   r   r   r   )r4   r(   r_   s      r5   r^   zJABElement._get_object_depthu  s]     0J43J{11$)=OPP2t4;;<LMMNNNr7   r!   c                    t                      }|p| j        }| j                            | j        |t          |          dd          }|s't          | j                            d                    |S )Nr   getAccessibleTextInfo)	r!   r(   r%   r   r'   r
   r   r   r   r   s       r5   r   z$JABElement._get_accessible_text_info  sx     "##/J43J22I)5;;1
 
  	Vt4;;<STTUUUr7   startendr   Array[c_char]lengthc                    |p| j         }| j                            | j        |||||          }|s't	          | j                            d                    d S )NgetAccessibleTextRange)r(   r%   r   r'   r   r   r   )r4   r   r   r   r   r(   r   s          r5   r   z%JABElement._get_accessible_text_range  sp     0J43J33I)5#tV
 
  	Wt4;;<TUUVVV	W 	Wr7   r    c                    t                      }|p| j        }| j                            | j        |t          |                    }|dk    r't          | j                            d                    |S )a  Returns information about the table, for example, caption, summary,
        row and column count, and the AccessibleTable.

        Args:
            accessible_context (JOBJECT64, optional): Accessible Context. Defaults to None.

        Raises:
            JABException: Get Accessible Table Info error.

        Returns:
            AccessibleTableInfo: Accessible Table Info.
        r   getAccessibleTableInfo)	r    r(   r%   r   r'   r
   r   r   r   r   s       r5   r   z%JABElement._get_accessible_table_info  st     #$$/J43J33I)5;;
 
 Q;;t4;;<TUUVVVr7   c                    t                      }|p| j        }| j                            | j        |t          |                    }|dk    r't          | j                            d                    |S )aJ  Returns the table row headers of the specified table as a table.

        Args:
            accessible_context (JOBJECT64, optional): Accessible Context. Defaults to None.

        Raises:
            JABException: Get Accessible Table Info error.

        Returns:
            AccessibleTableInfo: Accessible Table Info.
        r   getAccessibleTableRowHeader)	r    r(   r%   r   r'   r
   r   r   r   r   s       r5   r   z+JABElement._get_accessible_table_row_header  s}     #$$/J43J88I)5;;
 
 Q;;%,,-JKK   r7   c                    t                      }|p| j        }| j                            | j        |t          |                    }|dk    r't          | j                            d                    |S )aM  Returns the table column headers of the specified table as a table.

        Args:
            accessible_context (JOBJECT64, optional): Accessible Context. Defaults to None.

        Raises:
            JABException: Get Accessible Table Info error.

        Returns:
            AccessibleTableInfo: Accessible Table Info.
        r   getAccessibleTableColumnHeader)	r    r(   r%   r   r'   r
   r   r   r   r   s       r5   r   z.JABElement._get_accessible_table_column_header  s}     #$$/J43J;;I)5;;
 
 Q;;%,,-MNN   r7   c                T    |p| j         }| j                            | j        |          S )zReturns how many rows in the table are selected.

        Args:
            accessible_context (JOBJECT64, optional): Accessible Context. Defaults to None.

        Returns:
            int: Accessible table row selection count.
        )r(   r%   #getAccessibleTableRowSelectionCountr'   rH   s     r5   r   z4JABElement._get_accessible_table_row_selection_count  s4     0J43J{>>I)
 
 	
r7   c                T    |p| j         }| j                            | j        |          S )zReturns how many columns in the table are selected.

        Args:
            accessible_context (JOBJECT64, optional): Accessible Context. Defaults to None.

        Returns:
            int: Accessible table column selection count.
        )r(   r%   &getAccessibleTableColumnSelectionCountr'   rH   s     r5   r   z7JABElement._get_accessible_table_column_selection_count  s4     0J43J{AAI)
 
 	
r7   rowcolumnr   c           	         t                      }|p| j        }| j                            | j        |||t          |                    }|s't          | j                            d                    |S )a  Returns information about the specified table cell. The row and column specifiers are zero-based.

        Args:
            row (int): Row index in table.
            column (int): Column index in table.
            accessible_context (JOBJECT64, optional): Accessible Context. Defaults to None.

        Raises:
            JABException: Get Accesible Table Cell Info error.

        Returns:
            AccessibleTableCellInfo: Accessible Table Cell Info.
        getAccessibleTableCellInfo)	r   r(   r%   r   r'   r
   r   r   r   )r4   r   r   r(   r   r   s         r5   _get_accessible_table_cell_infoz*JABElement._get_accessible_table_cell_info  s      '((/J43J77I)3d
 
  	%,,-IJJ   r7   c                    |p| j         }| j                            | j        |          }|dk    r't	          | j                            d                    |S )zReturns the number of visible children of a component. Returns -1 on error.

        Args:
            accessible_context (JOBJECT64, optional): Accessible Context. Defaults to None.

        Returns:
            int: [description]
        r   getVisibleChildrenCount)r(   r%   r   r'   r   r   r   )r4   r(   r   s      r5   r   z&JABElement._get_visible_children_count)  sZ     0J43J44TY@RSSR<<t4;;<UVVWWWr7   r"   c                    t                      }|p| j        }| j                            | j        |dt          |                    }|s't          | j                            d                    |S )Nr   getVisibleChildren)	r"   r(   r%   r   r'   r
   r   r   r   r   s       r5   r   z JABElement._get_visible_children8  sv     #$$/J43J//I)1eDkk
 
  	St4;;<PQQRRRr7   actionc                   t                      }| j                            | j        | j        t          |                     |j        }|j        }t                      }|dk     rt          d          |dk    rm|t          d          ||j
        d         _        t          |          D ]'}||         j                                        |k    r n(t          d| d          |dk    r|d         j        |j
        d         _        d|_        | j                            | j        | j        t          |          t                                 dS )zDo Accessible Action with current JABElement.

        Args:
            action (str): Accessible Action name.

        Raises:
            JABException: Raise JABException if current JABElement does not support this action.
        r   z-JABElement does not support Accessible ActionNz=JABElement support multiple Accessible Action, please specifcr   z$JABElement does not support action '')r   r%   getAccessibleActionsr'   r(   r
   actionsCount
actionInfor   r   actionsrK   r   lowerdoAccessibleActionsr   )r4   r   acc_actsacc_acts_countacc_acts_infoact_todor   s          r5   _do_accessible_actionz JABElement._do_accessible_actionD  sn    %&&((It.h	
 	
 	
 ". +(**ANOOOA~"S   (.HQ$~.. U U ',2244>>E ? ##S&#S#S#STTTQ'4Q'7'<HQ$ !''It.h	
 	
 	
 	
 	
r7   simulatec                   |r| j                             | j                   | j                            d          }| j                            d          }| j                            d          }| j                            d          }|dk    s|dk    rt          d          t          ||dz  z             }t          ||dz  z             }| j                             ||	           dS |                     d
           dS )aP  Simulates clicking to JABElement.

        Default will use JAB Accessible Action.
        Set parameter 'simulate' to True if internal action does not work.

        Args:
            simulate (bool, optional): Simulate user click action by mouse event. Defaults to False.

        Raises:
            ValueError: Raise ValueError when JABElement width or height is 0.

        Use this to send simple mouse events or to click form fields::

            form_button = driver.find_element_by_name('button')
            form_button.click()
            form_button.click(simulate=True)
        r&   ri   rj   rl   rk   r   zelement width or height is 0r   ri   rj   clickr   N)	win32_utils_set_window_foregroundr&   rm   get
ValueErrorround_click_mouser   )r4   r   ri   rj   rl   rk   
position_x
position_ys           r5   r  zJABElement.clickh  s    $  	7333CCC$$A$$AKOOG,,E[__X..FzzVq[[ !?@@@q519}--Jq6A:~..J))J*)EEEEE&&g&66666r7   Twait_for_text_updatec                   |r| j                             | j                   |                                  | j        rE| j        r>| j                             d           | j        D ]}| j                             d           n|                     dd           |r| j        t          j
        k    rdS |                     d| j        d	           dS )
au  Clear existing text from JABElement.

        Default will use JAB Accessible Action.
        Set parameter 'simulate' to True if internal action does not work.

        Args:
            simulate (bool, optional): Simulate user input action by keyboard event. Defaults to False.
            wait_for_text_update (bool, optional): Waits for the text attribute to be empty. Defaults to True.

        Use this to send simple key events or to fill out form fields::

            form_textfield = driver.find_element_by_name('username')
            form_textfield.clear()
            from_textfield.send_text(simulate=True)
        r  r   	backspace Fvaluer   Nz
clear texterror_msg_function)r  r  r&   r   r{   r   
_press_key	send_textrP   r   TEXT_wait_for_value_to_be)r4   r   r  _s       r5   clearzJABElement.clear  s       	5333CCC!!!# =	 = ++E222 = =A$//<<<<NNeN444# 	tyDI'='=F""4|"TTTTTr7   r   	to_bottomholdc                   | j         t          j        k    rt          d          d| j        v }| j        d         }| j        d         }| j        d         }| j        d         }| j                            | j                   |r|r||z   |z
  dz
  }||d	z  z   }n9|r||d	z  z   }||z   |z
  dz
  }n#|r||z   dz   }||d	z  z   }n||d	z  z   }||z   dz   }| j        	                    t          |          t          |          |
           dS )a  Scroll a scoll bar to top or to bottom.

        Need improvement for scroll to specific position.

        Args:
            to_bottom (bool, optional): Scroll to bottom or not, otherwise scroll to top. Defaults to True.
            hold (int, optional): Mouse hold time to scroll to bar. Default to 2.

        Raises:
            JABException: Raise a JABException when JABElement role is not a scroll bar.
        zJABElement is not 'scroll bar'
horizontalri   rj   rk   rl   r     r   ri   rj   r  N)rS   r   
SCROLL_BARr   r[   rm   r  r  r&   r
  r\   r4   r  r  is_horizontalri   rj   rk   rl   s           r5   scrollzJABElement.scroll  sD    ?do--?@@@$(99KKX&G$//TY/??? 	 	E	F"Q&AFQJAA 	EAIAF
U"Q&AA 	F
QAFQJAAEAIAE	AA%%A#a&&t%DDDDDr7   r  c                   | j         dk    rt          d          d| j        v }| j        d         }| j        d         }| j        d         }| j        d         }| j                            | j                   |r|r||z   d	z
  }||d
z  z   }n&|r||d
z  z   }||z   d	z
  }n|r	||d
z  z   }n||d
z  z   }| j                            t          |          t          |          |           dS )a  Slide a slider to top or to bottom.

        Need improvement for slide to specific position.

        Args:
            to_bottom (bool, optional): Slide to bottom or not, otherwise slide to top. Defaults to True.
            hold (int, optional): Mouse hold time to slide. Default to 2.

        Raises:
            JABException: Raise a JABException when JABElement role is not a slider.
        sliderzJABElement is not 'slider'r  ri   rj   rk   rl   r  r  r   r   N)	rS   r   r[   rm   r  r  r&   r
  r\   r"  s           r5   slidezJABElement.slide  s    ?h&&;<<<$(99KKX&G$//TY/??? 		 		E	AAFQJAA 	EAIAF
QAA 	FQJAAEAIA%%A#a&&t%DDDDDr7   optionwait_for_selectionc                     | j         | j        | j        | j        d| j                 ||          }|rF|                     t          j        t          j        g| 	                    |          j
                   dS dS )a  Select an item from JABElement selector.
        Support select action from combo box, page tab list, list and menu.

        Args:
            option (str): Item selection from selector.
            simulate (bool, optional): Simulate user input action by mouse event. Defaults to False.
            wait_for_selection (bool, optional): Waits for selection equal to the option value. Defaults to True.
        )	combo boxpage tab listlistmenu)r(  r   N)_select_from_combobox_select_from_page_tab_list_select_from_list_select_from_menurS   _wait_for_value_to_containr   SELECTEDCHECKEDfind_element_by_namer[   )r4   r(  r   r)  r  s        r5   selectzJABElement.select  s    3!<**	
 

 /
 #)8= = =  	\++V_fn,M,0,E,Ef,M,M,Z\ \ \ \ \	\ 	\r7   c                z    |                      | j                  }t          | j        | j        | j        |          S )zGet selected JABElement from selection.
        Support get selection from combo box, list and page tab list.

        Returns:
            JABElement: The selected JABElement
        r%   r&   r'   r(   )r   r(   r$   r%   r&   r'   )r4   selected_accs     r5   get_selected_elementzJABElement.get_selected_element  sJ     BB#
 
 ;+	
 
 
 	
r7   parentc                    	 |                     |          }n-# t          $ r }t          |j         d| d          |d }~ww xY w|                     |j        |j                   d S )Nr  z	 option 'z' not found)r6  r   rS   r   rb   r(   )r4   r<  r(  itemes        r5   &_add_selection_from_accessible_contextz1JABElement._add_selection_from_accessible_context  s    	..V.<<DD 	 	 	$BBvBBB 	
 	33 &";	
 	
 	
 	
 	
s    
A>Ac                    | j         dk    rt          d          |                                  |r | j                            | j                   |                     |           d S )Nz	check boxzJABElement is not 'check box'r  r   )rS   r   r   r  r  r&   r  r4   r   s     r5   _select_from_checkboxz JABElement._select_from_checkbox  so    ?k))>??? 	D333CCC

H
%%%%%r7   c                   | j         dk    rt          d          |                                  |r|| j                            | j                   |                     d           |                     |                     d          |           | j        	                    d           d S | 
                    | j                   |                     | |           d S )	Nr+  zJABElement is not 'combo box'r  togglepopupr  r-  )r<  r(  enter)rS   r   r   r  r  r&   r   rA  find_element_by_roler  r   r(   r4   r(  r   s      r5   r/  z JABElement._select_from_combobox#  s    ?k))>??? 	333CCC&&m&<<<770088 8    ''000F55d6MNNN3343OOOOOr7   c                   | j         dk    rt          d          |rK| j                            | j                   |                     |                              d           d S |                     | |           d S )Nr,  z!JABElement is not 'page tab list'r  TrC  )r(  )rS   r   r  r  r&   r6  r  rA  rJ  s      r5   r0  z%JABElement._select_from_page_tab_list2  s    ?o--BCCC 	333CCC%%f--33T3BBBF33D3HHHHHr7   c                    | j         t          j        k    rt          d          |r | j                            | j                   |                     |                              |           d S )NzJABElement is not 'list'r  r>  rC  )	rS   r   LISTr   r  r  r&   r6  r  rJ  s      r5   r1  zJABElement._select_from_list;  ss    ?di''9::: 	D333CCC!!!//55x5HHHHHr7   c                   | j         dk    rt          d          |r| j                            | j                   |                     d           |                     | j        dz             D ]L}|j        s
| j        	                    d           |j
        |k    r| j        	                    d            d S Md S |                     |	                              d
           d S )Nr.  zJABElement is not 'menu'r  TrC  r   
down_arrowrH  r>  F)rS   r   r  r  r&   r  find_elements_by_object_depthr_   ru   r  rK   r6  )r4   r(  r   r?  s       r5   r2  zJABElement._select_from_menuB  s   ?f$$9::: 	J333CCCJJJ%%%::4;Lq;PQQ  -  ++L9999&&$//888EE '	  %%F%339959IIIIIr7   increasec                f   | j         dk    rt          d          |rR	 |                     d          }n"# t          $ r}t          d          |d }~ww xY w|                    ||           d S |rd}d}nd}d	}|r| j        d
         }| j        d         }	| j        d         }
| j        d         }| j                            | j                   ||z   d	z
  }|	|
dz  z   |z   }	| j                            t          |          t          |	                     d S | 
                    |           d S )NspinboxzJABElement is not 'spinbox'r   zBCurrent spinbox does not support set 'option', try with 'increase'r  	increment	decrementr  ri   rj   rk   rl   r  r   r  r  )rS   r   rI  r  rm   r  r  r&   r
  r\   r   )r4   r(  rQ  r   r   r@  r   offset_y_positionri   rj   rk   rl   s               r5   spinzJABElement.spinR  su    ?i''<=== 	0088   "X  NN(N;;;F 	" F " F ! 		C AC A[*FK(E333CCCE	AAFQJ!22A))CFFc!ff)===F""&"11111s   4 
AAAc                    d| j         vrt          d          |r.|                     d           |                     d           d S |                     d           d S )N
expandablez$JABElement does not support 'expand'TrC  toggleexpand)r[   r   r  r   rD  s     r5   expandzJABElement.expandt  sn    t000EFFF 	JJJ%%%JJJ%%%F"">22222r7   r  Union[str, int]c                   t          |          }|r1|                     d|           | j                            |           nV| j                            | j        | j        |          }|dk    r*t          | j	        
                    d          dz             |r| j        t          j        k    rdS |                     || j        d| d           dS )	a  Type into the JABElement.

        Default will use JAB Accessible Action.
        Set parameter 'simulate' to True if internal action does not work.

        :Args:
            value (str, int): A string for typing.
            simulate (bool, optional): Simulate user input action by keyboard event. Defaults to False.
            wait_for_text_update (bool, optional): Waits for the text attribute to be equal to the input value. Defaults to True.

        Use this to send simple key events or to fill out form fields::

            form_textfield = driver.find_element_by_name('username')
            form_textfield.send_text("admin")
            from_textfield.send_text("admin", simulate=True)
        Tr   setTextContentsz(, try set parameter 'simulate' with TrueNzupdate text attribute to 'r   r  )rI   r  r  
_send_keysr%   r_  r'   r(   r   r   r   rP   r   r  r  r   )r4   r  r   r  r   s        r5   r  zJABElement.send_text}  s    " E

 	JJt1222''....[00	42E F {{")001BCC@A   $ 	tyDI'='=F""5$)HmejHmHmHm"nnnnnr7   c                (    t           j        | j        v S )z{Returns whether the JABElement is checked.

        Can be used to check if a checkbox or radio button is checked.
        )r   r5  r[   r;   s    r5   
is_checkedzJABElement.is_checked  s    
 ~!222r7   c                (    t           j        | j        v S )z*Returns whether the JABElement is enabled.)r   ENABLEDr[   r;   s    r5   
is_enabledzJABElement.is_enabled      ~!222r7   c                (    t           j        | j        v S )z*Returns whether the JABElement is visible.)r   VISIBLEr[   r;   s    r5   
is_visiblezJABElement.is_visible  rf  r7   c                (    t           j        | j        v S )z*Returns whether the JABElement is showing.)r   SHOWINGr[   r;   s    r5   
is_showingzJABElement.is_showing  rf  r7   c                (    t           j        | j        v S )z+Returns whether the JABElement is selected.)r   r4  r[   r;   s    r5   is_selectedzJABElement.is_selected      $"333r7   c                (    t           j        | j        v S )z+Returns whether the JABElement is editable.)r   EDITABLEr[   r;   s    r5   is_editablezJABElement.is_editable  ro  r7   c                F    |                      t          j        ||          S )a[  find child JABElement by name

        Args:
            value (str): Locator of JABElement need to find.
            visible (bool, optional): The switch for find only visible child jab element or not.
            Defaults to False to find available child element.

        Returns:
            JABElement: The JABElement find by locator
        byr  r   )find_elementr   NAMEr4   r  r   s      r5   r6  zJABElement.find_element_by_name  !       BG5' JJJr7   c                F    |                      t          j        ||          S )ab  find child JABElement by description

        Args:
            value (str): Locator of JABElement need to find.
            visible (bool, optional): The switch for find only visible child jab element or not.
            Defaults to False to find available child element.

        Returns:
            JABElement: The JABElement find by locator
        rt  )rv  r   DESCRIPTIONrx  s      r5   find_element_by_descriptionz&JABElement.find_element_by_description  s!       BN% QQQr7   c                F    |                      t          j        ||          S )a[  find child JABElement by role

        Args:
            value (str): Locator of JABElement need to find.
            visible (bool, optional): The switch for find only visible child jab element or not.
            Defaults to False to find available child element.

        Returns:
            JABElement: The JABElement find by locator
        rt  )rv  r   ROLErx  s      r5   rI  zJABElement.find_element_by_role  ry  r7   Union[list, str]c                F    |                      t          j        ||          S )a^  find child JABElement by states

        Args:
            value (list): Locator of JABElement need to find.
            visible (bool, optional): The switch for find only visible child jab element or not.
            Defaults to False to find available child element.

        Returns:
            JABElement: The JABElement find by locator
        rt  )rv  r   STATESrx  s      r5   find_element_by_statesz!JABElement.find_element_by_states  s!       BIUG LLLr7   c                F    |                      t          j        ||          S )ac  find child JABElement by object depth

        Args:
            value (int): Locator of JABElement need to find.
            visible (bool, optional): The switch for find only visible child jab element or not.
            Defaults to False to find available child element.

        Returns:
            JABElement: The JABElement find by locator
        rt  )rv  r   OBJECT_DEPTHrx  s      r5   find_element_by_object_depthz'JABElement.find_element_by_object_depth  s!       BO5' RRRr7   c                F    |                      t          j        ||          S )ae  find child JABElement by children count

        Args:
            value (int): Locator of JABElement need to find.
            visible (bool, optional): The switch for find only visible child jab element or not.
            Defaults to False to find available child element.

        Returns:
            JABElement: The JABElement find by locator
        rt  )rv  r   CHILDREN_COUNTrx  s      r5   find_element_by_children_countz)JABElement.find_element_by_children_count  s"       B$5UG TTTr7   c                F    |                      t          j        ||          S )af  find child JABElement by index in parent

        Args:
            value (int): Locator of JABElement need to find.
            visible (bool, optional): The switch for find only visible child jab element or not.
            Defaults to False to find available child element.

        Returns:
            JABElement: The JABElement find by locator
        rt  )rv  r   INDEX_IN_PARENTrx  s      r5   find_element_by_index_in_parentz*JABElement.find_element_by_index_in_parent  s"       B$6eW UUUr7   attr_valc                    | d         dv r| d         dv r
| dd         } t          j        d          }|                    |           x}r|d         |j        v S | |j        k    S )zReturn the attribute value is matched or not by name.

        Args:
            attr_val (str): Attribute name value
            jabelement (JABElement): The JABElement

        Returns:
            bool: True for attribute matched False for not
        r   r   "r   r   ^contains\(["'](.*?)["']\))recompilefindallrK   r  r   patterncontents       r5   _is_match_attr_namezJABElement._is_match_attr_name  u     A;*$$")C)C"~H*;<<ooh///7 	/1:00z..r7   c                    | d         dv r| d         dv r
| dd         } t          j        d          }|                    |           x}r|d         |j        v S | |j        k    S )a  Return the attribute value is matched or not by description.

        Args:
            attr_val (str): Attribute description value
            jabelement (JABElement): The JABElement

        Returns:
            bool: True for attribute matched False for not
        r   r  r   r   r  )r  r  r  rN   r  s       r5   _is_match_attr_descriptionz%JABElement._is_match_attr_description0  sw     A;*$$")C)C"~H*;<<ooh///7 	61:!777z555r7   c                    | d         dv r| d         dv r
| dd         } t          j        d          }|                    |           x}r|d         |j        v S | |j        k    S )a  Return the attribute value is matched or not by role.

        Args:
            attr_val (str): Attribute description value
            jabelement (JABElement): The JABElement

        Returns:
            bool: True for attribute matched False for not
        r   r  r   r   r  )r  r  r  rP   r  s       r5   _is_match_attr_rolezJABElement._is_match_attr_roleC  r  r7   c                n   | d         dv r| d         dv r
| dd         } t          j        d          }|                    |           x}r4t          fd|d                             d          D                       S t          |                     d                    t          j                  k    S )a  Return the attribute value is matched or not by states.

        Args:
            attr_val (str): Attribute states value
            jabelement (JABElement): The JABElement

        Returns:
            bool: True for attribute matched False for not
        r   r  r   r   r  c              3  *   K   | ]}|j         v V  d S r9   )r[   ).0statr   s     r5   	<genexpr>z3JABElement._is_match_attr_states.<locals>.<genexpr>e  s+      YY4tz66YYYYYYr7   rV   )r  r  r  allrX   setr[   r  s    `  r5   _is_match_attr_statesz JABElement._is_match_attr_statesV  s     A;*$$")C)C"~H*;<<ooh///7 	LYYYY71:CSCSTWCXCXYYYYYYx~~c**++s:3J/K/KKKr7   c                2    t          |           |j        k    S )a  Return the attribute value is matched or not by object depth.

        Args:
            attr_val (str): Attribute object depth value
            jabelement (JABElement): The JABElement

        Returns:
            bool: True for attribute matched False for not
        )r\   r_   r  r   s     r5   _is_match_attr_objectdepthz%JABElement._is_match_attr_objectdepthi  s     8}}
 777r7   c                2    t          |           |j        k    S )a  Return the attribute value is matched or not by children count.

        Args:
            attr_val (str): Attribute children count value
            jabelement (JABElement): The JABElement

        Returns:
            bool: True for attribute matched False for not
        )r\   rf   r  s     r5   _is_match_attr_childrencountz'JABElement._is_match_attr_childrencountv  s     8}}
 999r7   c                2    t          |           |j        k    S )a  Return the attribute value is matched or not by index in parent.

        Args:
            attr_val (str): Attribute index in parent value
            jabelement (JABElement): The JABElement

        Returns:
            bool: True for attribute matched False for not
        )r\   rb   r  s     r5   _is_match_attr_indexinparentz'JABElement._is_match_attr_indexinparent  s     8}}
 :::r7   
attributes
list[dict]c                   t           j        | j        t           j        | j        t           j        | j        t           j        | j        t           j	        | j
        t           j        | j        t           j        | j        i}|D ]j}|                    d          }|                    d          }||                                vrt#          d| d           ||         ||          s dS kdS )a  Return the node attributes is matched or not with specific JABElement.


        Args:
            attributes (list[dict]): List of attribute contains
            "name" of attribute and "value" of attribute conditions
            jabelement (JABElement): The JABElement

        Raises:
            JABException: Incorrect attribute name found

        Returns:
            bool: True for attributes matched False for not
        rK   r  zincorrect attribute name 'r   FT)r   rw  r  r~  r  r{  r  r  r  r  r  r  r  r  r  r  keysr   )r4   r  r   dict_attribute	attributerK   r  s          r5   _is_match_attributeszJABElement._is_match_attributes  s    $ GT-GT-ND;It1OT<t@ A
 $ 	 	I==((DMM'**E>..0000"#G#G#G#GHHH'>$'z:: uutr7   c                   |p%t          | j        | j        | j        | j                  }|                     | j        |j                  }|s|S |                     | j                  }|                     | j        |          }|r|n| j        S )zGet node JABElement.

        Args:
            jabelement (JABElement, optional): The JABElement. Defaults to None.

        Returns:
            JABElement: Node JABElement
        )r$   r%   r&   r'   r(   r   r   r<  )r4   r   is_samer   is_top_levels        r5   _get_node_elementzJABElement._get_node_element  s      i:dk49diQUQh#i#i
&&#Z%B
 
  	//0GHH
++D,CZPP):zzt{:r7   rootnodelevelc                   |                      ||          \  }} |                     |          ||          D ]x}|                    d          d|j        fvr|                     |           6|                     |                    d          |          r|c S |                     |           yt          d| d| d          )a  Get child JABElement by specific node.

        Args:
            node (str): Node content for every single content in xpath.

            level (str, optional): Level for node, two options: "root" and "child". Defaults to "root".

            jabelement (JABElement, optional): The parent JABElement. Defaults to None.

            visible (bool, optional): The switch for find only visible child jab element or not.
            Defaults to False to find available child element.

        Raises:
            ValueError: Incorrect level set
            JABException: No JABElement found with specific node

        Returns:
            JABElement: The child JABElement
        r   rP   *r  zno JABElement found in level z with node 'r   )_get_node_info_get_children_by_levelr  rS   r   r  r   )r4   r  r  r   r   node_element	node_infor   s           r5   _get_element_by_nodezJABElement._get_element_by_node  s    4 #'"5"5dJ"G"Gi=466u==_fggg 	1 	1K}}V$$S+2H,III''444((|)D)DkRR #""""##K0000FEFFtFFF
 
 	
r7   c                    | j                             |          }d}|D ]8}|                    |          dk    rdnd}|                     ||||          }9|S )as  Find child JABElement by xpath

        Args:
            value (str): Locator of JABElement need to find.
            visible (bool, optional): The switch for find only visible child jab element or not.
            Defaults to False to find available child element.

        Example:
            find_element_by_xpath("//internal frame/panel")

            find_element_by_xpath("//*/panel")

            find_element_by_xpath("//internal frame[@name='FRM-999']")

            find_element_by_xpath("//internal frame[@name=contains('FRM-999')]")

            find_element_by_xpath("//internal frame[@states='enable,focusable,visible,showing']")

            find_element_by_xpath("//internal frame[@states=contains('enable,focusable')]")

            find_element_by_xpath("//internal frame[@objectdepth=7]")

            find_element_by_xpath("//internal frame[@childrencount=2]")

            find_element_by_xpath("//internal frame[@indexinparent=3]")

            find_element_by_xpath("//internal frame[@name=contains('FRM-999') and @objectdepth=7]")


        Returns:
            JABElement: The JABElement find by locator
        Nr   r  childr  r  r   r   )xpath_parsersplit_nodesr   r  )r4   r  r   nodesr   r  r  s          r5   find_element_by_xpathz JABElement.find_element_by_xpath  sz    . !--e44
 	 	D#kk$//144FF'E22:w 3  JJ r7   ru  r   c           	        |t           j        t           j        t           j        t           j        t           j        t           j        t           j        t           j        fvrt          d| d          |t           j        k    r| 
                    ||          S |                     |          D ]3}|                     |||          r|c S |                     |           4t          d| d| d          )a  Find a jab element given a By strategy and locator.

        Args:
            by (str, optional): By strategy of element need to find. Defaults to By.NAME.
            value (Any, optional): Locator of element need to find.
            Defaults to None will select the first child jab element.
            visible (bool, optional): The switch for find only visible child jab element or not.
            Defaults to False to find available child element.

        Returns:
            JABElement: The element find by locator
        incorrect by strategy 'r   r  r   r   ru  r  r   zjab element not found by '' with locator ')r   rw  r{  r~  r  r  r  r  XPATHr   r  r   _is_element_matchedr   )r4   ru  r  r   r   s        r5   rv  zJABElement.find_element  s    GNGIOH	
 	
 	
 >>>>???>>--E7-KKK33G3DD 	0 	0J''2Uz'RR "!!!!##J////EEEUEEE
 
 	
r7   list[JABElement]c                F    |                      t          j        ||          S )an  Find list of child JABElement by name

        Args:
            value (str): Locator of list JABElement need to find.
            visible (bool, optional): The switch for find only visible child jab elements or not.
            Defaults to False to find all child elements.

        Returns:
            list[JABElement]: List of JABElement find by locator
        rt  )find_elementsr   rw  rx  s      r5   find_elements_by_namez JABElement.find_elements_by_name4  !     !!RWE7!KKKr7   c                F    |                      t          j        ||          S )au  Find list of child JABElement by description

        Args:
            value (str): Locator of list JABElement need to find.
            visible (bool, optional): The switch for find only visible child jab elements or not.
            Defaults to False to find all child elements.

        Returns:
            list[JABElement]: List of JABElement find by locator
        rt  )r  r   r{  rx  s      r5   find_elements_by_descriptionz'JABElement.find_elements_by_descriptionC  s!     !!R^5'!RRRr7   c                F    |                      t          j        ||          S )an  Find list of child JABElement by role

        Args:
            value (str): Locator of list JABElement need to find.
            visible (bool, optional): The switch for find only visible child jab elements or not.
            Defaults to False to find all child elements.

        Returns:
            list[JABElement]: List of JABElement find by locator
        rt  )r  r   r~  rx  s      r5   find_elements_by_rolez JABElement.find_elements_by_roleR  r  r7   c                F    |                      t          j        ||          S )ap  Find list of child JABElement by states

        Args:
            value (str): Locator of list JABElement need to find.
            visible (bool, optional): The switch for find only visible child jab elements or not.
            Defaults to False to find all child elements.

        Returns:
            list[JABElement]: List of JABElement find by locator
        rt  )r  r   r  rx  s      r5   find_elements_by_statesz"JABElement.find_elements_by_statesa  s!     !!RYeW!MMMr7   c                F    |                      t          j        ||          S )av  Find list of child JABElement by object depth

        Args:
            value (str): Locator of list JABElement need to find.
            visible (bool, optional): The switch for find only visible child jab elements or not.
            Defaults to False to find all child elements.

        Returns:
            list[JABElement]: List of JABElement find by locator
        rt  )r  r   r  rx  s      r5   rP  z(JABElement.find_elements_by_object_depthp  s!     !!R_E7!SSSr7   c                F    |                      t          j        ||          S )ax  Find list of child JABElement by children count

        Args:
            value (str): Locator of list JABElement need to find.
            visible (bool, optional): The switch for find only visible child jab elements or not.
            Defaults to False to find all child elements.

        Returns:
            list[JABElement]: List of JABElement find by locator
        rt  )r  r   r  rx  s      r5   find_elements_by_children_countz*JABElement.find_elements_by_children_count  s"     !!R%6eW!UUUr7   c                F    |                      t          j        ||          S )ax  Find list of child JABElement by index inparent

        Args:
            value (str): Locator of list JABElement need to find.
            visible (bool, optional): The switch for find only visible child jab elements or not.
            Defaults to False to find all child elements.

        Returns:
            list[JABElement]: List of JABElement find by locator
        rt  )r  r   r  rx  s      r5    find_elements_by_index_in_parentz+JABElement.find_elements_by_index_in_parent  s"     !!R%7ug!VVVr7   c                   |                      ||          \  }}g } |                     |          ||          D ]}|                    d          d|j        fvr|                     |           6|                     |                    d          |          r|                    |           u|                     |           |S )ap  Get list of child JABElement by specific node

        Args:
            node (str): Node content for every single content in xpath.

            level (str, optional): Level for node, two options: "root" and "child". Defaults to "root".

            jabelement (JABElement, optional): The parent JABElement. Defaults to None.

            visible (bool, optional): The switch for find only visible child jab elements or not.
            Defaults to False to find all child elements.

        Raises:
            ValueError: Incorrect level set

        Returns:
            list[JABElement]: list of the JABElement
        r   rP   r  r  )r  r  r  rS   r   r  append)	r4   r  r  r   r   r  r  jabelementsr   s	            r5   _get_elements_by_nodez JABElement._get_elements_by_node  s    2 #'"5"5dJ"G"Gi=466u==_fggg 	1 	1K}}V$$S+2H,III''444((|)D)DkRR "";///##K0000r7   c                P    |dv r|dk    r| j         n| j        S t          d          )N>   r  r  r  z$level should be in 'root' or 'child')r   r   r  )r4   r  s     r5   r  z!JABElement._get_children_by_level  s6    %%%054,,TEggCDDDr7   c                h    | j                             |          }|                     |          }||fS r9   )r  get_node_informationr  )r4   r  r   r  r  s        r5   r  zJABElement._get_node_info  s8     %::4@@	--j99Y&&r7   c                    dd}	 dd fd} j                             |          }t           j         j         j         j                  g} ||          D ]%\  }}|st          d           |||||          }&|S )aj  Find list of child JABElement by xpath

        Args:
            value (str): Locator of JABElement need to find.
            visible (bool, optional): The switch for find only visible child jab elements or not.
            Defaults to False to find all child elements.

        Returns:
            list[JABElement]: List of JABElement find by locator
        _nodes	list[str]r)   r   c              3  T   K   t          |           D ]\  }}|dk    rdnd}||fV  d S )Nr   r  r  )	enumerate)r  r   _node_levels       r5   generate_nodez8JABElement.find_elements_by_xpath.<locals>.generate_node  sO       )& 1 1 $ $u#(A::7Vm####$ $r7   Fr  rI   r  _parent_jabelementsr  _visiblern   c           	     n    g }|D ].}|                                         | |||                     /|S )Nr  )extendr  )r  r  r  r  child_jabelements_parent_jabelementr4   s         r5   get_child_jabelementsz@JABElement.find_elements_by_xpath.<locals>.get_child_jabelements  sd     !#&9  "!((.."$#5 (	 /      %$r7   zno JABElement found)r  r  r  r  )r  r  r)   r   F)
r  rI   r  rI   r  r  r  rn   r)   r  )r  r  r$   r%   r&   r'   r(   r   )	r4   r  r   r  r  r  _jabelementsr  r  s	   `        r5   find_elements_by_xpathz!JABElement.find_elements_by_xpath  s    	$ 	$ 	$ 	$ "'		% 	% 	% 	% 	% 	% 	%$ !--e44t{DIty$:QRR
 )=// 	 	KD% :"#8999005lU\  LL r7   Union[list, str, int]c           	        |t           j        t           j        t           j        t           j        t           j        t           j        t           j        t           j        fvrt          d| d          |t           j        k    r| 
                    ||          S g }|                     |          D ]E}|                     |||          r|                    |           0|                     |           F|st          d| d| d          |S )a  Find list of JABElement given a By strategy and locator.

        Args:
            by (str, optional): By strategy of element need to find. Defaults to By.NAME.
            value (Any, optional): Locator of element need to find.
            Defaults to None will select the first child jab element.
            visible (bool, optional): The switch for find only visible child jab elements or not.
            Defaults to False to find all child elements.

        Returns:
            list: List of JABElement find by locator
        r  r   r  r  r  zno JABElement found by 'r  )r   rw  r{  r~  r  r  r  r  r  r   r  r   r  r  r   )r4   ru  r  r   r  r   s         r5   r  zJABElement.find_elements  s(    GNGIOH	
 	
 	
 >>>>???>>..UG.LLL33G3DD 	0 	0J''2Uz'RR "":...##J//// 	G2GGuGGG   r7   Optional[str]c                   t          |d u |t          j        k    o
| j        |k    |t          j        k    o
| j        |k    |t          j        k    o
| j        |k    |t          j        k    o$t          | j
                  t          |          k    |t          j        k    o| j        t          |          k    |t          j        k    o| j        t          |          k    |t          j        k    o| j        t          |          k    g          S r9   )anyr   rw  rK   r~  rP   r{  rN   r  r  r[   r  r_   r\   r  rf   r  rb   )r   ru  r  s      r5   r  zJABElement._is_element_matched)  s    bg:*/U":bg:*/U":bn$H)?5)HbiNC
(?$@$@CJJ$Nbo% :+s5zz9b'' <-U;b(( =.#e**<
 
 	
r7   c                    t          | j                            d          | j                            d                    S )zThe size of the element.rk   rl   )rk   rl   rg   rm   r  r;   s    r5   sizezJABElement.size;  s3     4;??844DKOOG<T<TUUUUr7   c                    t          | j                            d          | j                            d                    S )z5The location of the element in the renderable canvas.ri   rj   r  r  r;   s    r5   locationzJABElement.location@  s3     dkooc**dkooc.B.BCCCCr7   filenamec                X    |                                  }|                    |           dS )a  
        Saves a screenshot of the current element to a PNG image file. Returns
           False if there is any IOError, else returns True. Use full paths in
           your filename.

        :Args:
         - filename: The full path you wish to save your screenshot to. This
           should end with a `.png` extension.

        :Usage:
            element.screenshot('/Screenshots/foo.png')
        N)get_screenshotsave)r4   r  ims      r5   get_screenshot_as_filez!JABElement.get_screenshot_as_fileE  s-       ""
r7   r   c                T   | j                             | j                   | j                            d          }| j                            d          }| j                            d          }| j                            d          }t          j        ||||z   ||z   fdd          S )	z
        Gets the screenshot of the current element as pillow Image.

        :Usage:
            img = element.get_screenshot()
        r  ri   rj   rl   rk   FT)bboxinclude_layered_windowsall_screens)r  r  r&   rm   r  r   grab)r4   ri   rj   rl   rk   s        r5   r  zJABElement.get_screenshotU  s     	//TY/???KOOC  KOOC  ((**~E	F
	 %*	
 	
 	
 		
r7   c                n    |                                  }t          | j        | j        | j        |          S )zIInternal reference to the JabDriver instance this element was found from.r9  )r   r$   r%   r&   r'   )r4   
parent_accs     r5   r<  zJABElement.parentl  s>     ==??
;)	
 
 
 	
r7   c                   | j         dk    rt          d          |                     ||          }|j        }|j        }|r!|                                 }|j        |         }t          | j        | j	        | j
        |          S )a  Get cell JABElement from table

        Args:
            row (int): Row index of cell, start from 0.
            column (int): Column index of cell, start from 0.
            visible (bool, optional): The switch for find only visible cell element or not.
            Defaults to False to find available cell element.

        Raises:
            JABException: Raise JABException if JAB internal function error

        Returns:
            JABElement: Return specific cell JABElement
        r   z3JABElement is not table, does not support this func)rS   r   r   r   accessibleContextr   r   r$   r%   r&   r'   )r4   r   r   r   r   r   r(   s          r5   get_cellzJABElement.get_cellw  s     ?g%%TUUU33C@@
!3 	6--//D!%u!5$+ty$)=OPPPr7   c                   | j         | j        | j        | j        | j        | j        | j        | j        | j        | j	        | j
        | j        | j        | j        d}| j        r
| j        |d<   | j        t          j        k    r
| j        |d<   |S )zGet dict information of current JABElement.

        Notice:
            This dict of component value will NOT update after property changes.

        Returns:
            dict: Dict information of current JABElement
        )rK   rN   rP   rS   rW   r[   rm   r_   rb   rf   rq   ru   rx   r{   r   r   )rK   rN   rP   rS   rW   r[   rm   r_   rb   rf   rq   ru   rx   r{   r   r   r   r   )r4   r   s     r5   get_element_informationz"JABElement.get_element_information  s     I+I/k -k -#3"1$($=!%!7$($=#3
 
   	%9DL?dj(( JDMr7   expected_valuetimeoutr  c                    t                      }	 | r|| k    s| s|sd S t                      }t          ||z
            }||k    r$|r
d| d| d}n	d|  d| d}t          |          Y)NT
Failed to  in '	' secondsz#Failed to wait for expected value '' in ')r   r	  TimeoutError)r  actual_valuer  r  r   currentelapsed
_error_msgs           r5   r  z JABElement._wait_for_value_to_be  s     	/"$66) 7( 7 ffGGeO,,G'!!% p!Y.@!Y!Yw!Y!Y!YJJ!o~!o!o]d!o!o!oJ":...	/r7   expected_valuesUnion[str, list[str]]c                    t                      }	 t           fd|D                       rd S t                      }t          ||z
            }||k    r9|r
d| d| d}nd                               }d| d| d}t	          |          })	NTc              3      K   | ]}|v V  	d S r9   r~   )r  vr!  s     r5   r  z8JABElement._wait_for_value_to_contain.<locals>.<genexpr>  s(      ??A1'??????r7   r  r  r  z, z$Failed to wait for expected values 'r  )r   r  r	  joinr  )	r!  actual_valuesr  r  r   r  r  r   _expected_valuess	   `        r5   r3  z%JABElement._wait_for_value_to_contain  s     	/????????? ffGGeO,,G'!!% s!Y.@!Y!Yw!Y!Y!YJJ'+yy'A'A$!rHX!r!r`g!r!r!rJ":...	/r7   )NNNN)
r%   r   r&   r   r'   r   r(   r   r)   r*   )r)   r   )r%   r   r)   r*   )r)   r   )r&   r   r)   r*   )r)   r   )r'   r   r)   r*   )r)   r   )r(   r   r)   r*   )r)   rI   )r)   r\   )r)   rg   )r)   rn   r}   )r   r$   r   rn   r)   r   r9   )r   r$   r)   r*   )r(   r   r)   r   )r   r\   r(   r   r)   r*   )r   r   r   r   r)   rn   )r(   r   r)   r   )r(   r   r)   r\   )r(   r   r)   r!   )r   r\   r   r\   r   r   r   r\   r(   r   r)   r*   )r(   r   r)   r    )r   r\   r   r\   r(   r   r)   r   )r(   r   r)   r"   )r   rI   r)   r*   r  )r   rn   r)   r*   )FT)r   rn   r  rn   r)   r*   )Tr   )r  rn   r  r\   r)   r*   )Tr  )r(  rI   r   rn   r)  rn   r)   r*   )r)   r$   )r<  r$   r(  rI   r)   r*   )r(  rI   r   rn   r)   r*   )NTF)r(  rI   rQ  rn   r   rn   r)   r*   )r  r]  r   rn   r  rn   r)   r*   )r  rI   r   rn   r)   r$   )r  r  r   rn   r)   r$   )r  r\   r   rn   r)   r$   )r  rI   r   r$   r)   rn   )r  r  r   r$   r)   rn   )r   r$   r)   r$   )r  NF)
r  rI   r  rI   r   r$   r   rn   r)   r$   )ru  rI   r  r   r   rn   r)   r$   )r  rI   r   rn   r)   r  )r  r  r   rn   r)   r  )r  r\   r   rn   r)   r  )
r  rI   r  rI   r   r$   r   rn   r)   r  )r  )r  rI   )r  rI   r   r$   )ru  rI   r  r  r   rn   r)   r  )r   r$   ru  rI   r  r  )r  rI   r)   r*   )r)   r   )r   r\   r   r\   r   rn   r)   r$   )r  N)r  r  r  r\   r  rI   )r!  r"  r  r\   r  rI   )x__name__
__module____qualname__r   r   r  r   r  r6   propertyr%   setterr&   r'   r(   rK   rN   rP   rS   rW   r[   r_   rb   rf   rm   rq   ru   rx   r{   r   r   r   r   r   r   r   r   r   r   r   r   r   r2   r^   r   r   r   r   r   r   r   r   r   r   r   r  r  r$  r'  r7  r;  rA  rE  r/  r0  r1  r2  rX  r\  r  rb  re  ri  rl  rn  rr  r6  r|  rI  r  r  r  r  staticmethodr  r  r  r  r  r  r  r  r  r  r  r   rw  rv  r  r  r  r  rP  r  r  r  r  r  r  r  r  r   r  r  r  r<  r  r  r  r3  r~   r7   r5   r$   r$      sw       ;*,,K;==L  ,0; ; ; ; ;    X ]   ]    X 
[   [    X 
[   [ ( ( ( X( 6 6 6 6 % % % X% , , , X, % % % X% + + + X+ 2 2 2 X2 8 8 8 X8 ( ( ( X( . . . X. . . . X. 
 
 
 X
 : : : X: 7 7 7 X7 : : : X: 5 5 5 X5    X W W W XW P P P XP: BG    8 BG% % % % %PE E E E E$@ @ @ @ @ 37
 
 
 
 
 ?C
 
 
 
 
W W W W
E 
E 
E 
E    * 37Y Y Y Y Y 37    .    * 37
 
 
 
 
$ -1W W W W W  37    2 37    4 37    4 37
 
 
 
 
" 37
 
 
 
 
" JN    6      37
 
 
 
 
"
 "
 "
 "
 "
H7 7 7 7 7@U U U U U:!E !E !E !E !EFE E E E EB\ \ \ \ \&
 
 
 
"
 
 
 
& & & & &P P P P PI I I I II I I I IJ J J J J" OT 2  2  2  2  2D3 3 3 3 3 o  o  o  o  oD3 3 3 33 3 3 33 3 3 33 3 3 34 4 4 44 4 4 4K K K K K /4R R R R RK K K K KM M M M M /4S S S S S  /4U U U U U  /4V V V V V / / / \/$ 6 6 6 \6$ / / / \/$ L L L \L$ 
8 
8 
8 \
8 : : : \: ; ; ; \;! ! ! !F; ; ; ; ;,  %)!$
 $
 $
 $
 $
L    B G$"
 "
 "
 "
 "
J /4L L L L L  /4S S S S S  /4L L L L L  <AN N N N N  /4T T T T T  /4V V V V V  /4W W W W W$  %)!# # # # #JE E E E E 04' ' ' ' ' /4/ / / / /d GDZ_& & & & &P 
 
 
 \
" V V V XV D D D XD    
 
 
 
. 
 
 X
Q Q Q Q Q2   > Z[8</ / / / \/( ij=A/ / / / \/ / /r7   r$   )2
__future__r   r   pyjab.common.loggerr   pyjab.common.roler   pyjab.common.statesr   pyjab.common.textreaderr   r  ctypesr	   r
   r   r   r   r   ctypes.wintypesr   typingr   r   r   r   PILr   r   pyjab.common.byr   pyjab.common.exceptionsr   pyjab.common.typesr   r   pyjab.common.win32utilsr   pyjab.common.xpathparserr   pyjab.accessibleinfor   r   r   r   r    r!   r"   objectr$   r~   r7   r5   <module>r?     s   " " " " " "       & & & & & & " " " " " " & & & & & & . . . . . . 				 K K K K K K K K K K K K K K K K             2 2 2 2 2 2 2 2 2 2 2 2                       0 0 0 0 0 0 . . . . . . . . . . . . . . 0 0 0 0 0 0                 u/ u/ u/ u/ u/ u/ u/ u/ u/ u/r7   