Frame

class pyjt.FillMode(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)
class pyjt.Frame(control)

Bases: Fixture

Wrapper for controlling a frame.

click()

Move the mouse over this control and execute a click.

close()

Close this frame by sending a close message.

components()

Returns: Fixture[]:

An array of Fixture references of all child components of this component.

property control

Returns: Proxy: A reference to the control managed by this fixture.

dispose()

Dispose this frame.

dump(encoding='utf-8')
Returns:

A xml-representation of the component tree of this component.

Return type:

string

Parameters:

encoding (string) – The encoding to use to convert the component to xml

etree()
fill(text, mode=FillMode.TYPE, clear=True)

Fill this control with the given text.

Parameters:
  • text – Text to fill this control with.

  • mode – FillMode - Choose the mode to fill the control with the given text. See the table below.

  • clear – If set to True, select all text in the given control before typing.

FillMode:

FillMode.TYPE:
  • Fill the control by emulating keystrokes.

  • Only supports US keyboard layout at this time.

FillMode.SET:
  • Just set the text of the component using the component.setText() function.

  • The existing text is always overwritten ignoring the clear argument

FillMode.PASTE:
  • Fill the control by pasting the text from the clipboard

  • Not implemented yet

find(role, **kwargs)

Search a control of type role as a sub-control of this control.

Parameters:
  • role (Class) – The class type of the component to look for, e.g. javax.swing.JTextField

  • **kwargs – Search criteria for the component.

Returns:

A fixture pointing to the first component matching the search criteria.

Return type:

Fixture

Raises:

ElementNotFoundError – No element was found matching the search criteria

find_by_xpath(xpath)

Locate a component by xpath.

This function searches the component tree using an xpath-expression to locate an element.

Parameters:

xpath (string) – The xpath used for searching

Returns:

A fixture reference to the first component matching the given xpath expression.

Return type:

Fixture

Raises:

ElementNotFoundError – If no element was found matching the given xpath

Example:

# search for a JTextField inside a Container which also contains
# a label with the text "Name"
textfield = frame.find_by_xpath('//Container[//JLabel[@text="Name"]]/JTextField')
locate(locator=None, **kwargs)

Search a control as a sub-element of the control managed by this fixture.

Parameters:
  • locator (Locator) – A locator object to find the sub-control

  • **kwargs – Additional search parameters.

Returns:

A fixture pointing to the first component matching the search criteria.

Return type:

Fixture

Raises:

ElementNotFoundError – No element was found matching the search criteria

property type

Returns: ClassType: The type of class of this component