airtest.core.linux.linux module

class Linux(pid=None, **kwargs)[source]

Bases: airtest.core.device.Device

Linux desktop.

shell(cmd)[source]

Run shell command in subprocess

Parameters:cmd – command to be run
Raises:subprocess.CalledProcessError – when command returns non-zero exit status
Returns:command output as a byte string
snapshot(filename='tmp.png', quality=None)[source]

Take a screenshot and save it to tmp.png filename by default

Parameters:
  • filename – name of file where to store the screenshot
  • quality – ignored
Returns:

display the screenshot

keyevent(keyname, **kwargs)[source]

Perform a key event

References

https://pywinauto.readthedocs.io/en/latest/code/pywinauto.keyboard.html

Parameters:
  • keyname – key event
  • **kwargs – optional arguments
Returns:

None

text(text, **kwargs)[source]

Input text

Parameters:
  • text – text to input
  • **kwargs – optional arguments
Returns:

None

touch(pos, **kwargs)[source]

Perform mouse click action

References

https://pywinauto.readthedocs.io/en/latest/code/pywinauto.mouse.html

Parameters:
  • pos – coordinates where to click
  • **kwargs – optional arguments
Returns:

None

double_click(pos)[source]
swipe(p1, p2, duration=0.8, steps=5)[source]

Perform swipe (mouse press and mouse release) :param p1: start point :param p2: end point :param duration: time interval to perform the swipe action :param steps: size of the swipe step

Returns:None
start_app(path)[source]

Start the application

Parameters:path – full path to the application
Returns:None
stop_app(pid)[source]

Stop the application

Parameters:pid – process ID of the application to be stopped
Returns:None
get_current_resolution()[source]
get_ip_address()[source]

Return default external ip address of the linux os.

Returns:ip address
Return type:str