How to run Airtest Automation project (.air) using python? - python

I am using Airtest IDE for android application automation. For it I prepared a Airtest project(.air) with automation steps.
The problem is I want to run this project on two Android devices but in airtest we can only run on one device at a time.
So, I tried opening it in two different Airtest IDE windows and manually running it on one device in one window and on other device in other window.
I want to automate these step using Python. I want to open both the windows using python and running in one device with one window and other device with other one.

Use this in your python code and in airtestide.
connect_device("Android:///device name")
adb device will give you device name
by using this connect_device = script will only run in that particular device only
and add another device for your ide.

Related

How to run graphical automation in Azure VM (or similar)

I made a python script that runs a graphical automation using pyautogui (mouse movements) over a huge number of PDFs.
The automation appears to need an active display, for the mouse movements and the PDF to be opened.
If I connect to the Azure VM (with Windows OS) with SSH and start the python script, I get an error from pyautogui as below:
pyautogui.FailSafeException:
PyAutoGUI fail-safe triggered from mouse moving to a corner of the screen.
To disable this fail-safe, set pyautogui.FAILSAFE to False.
DISABLING FAIL-SAFE IS NOT RECOMMENDED.
I have tried with the failsafe disable and still it doesn't work.
As I have read, this happens because there is no active display opened.
If I connect to the VM using RDP, the automation starts and works as expect until I minimize or close the window. When I do that I get the same failsafe error from pyautogui.
But I cannot keep the window open, because I would need to start the same automation on 16 more VMs.
Is there a way to run such graphical automations in Azure VMs or any other similar solution? Docker maybe?
Is there any solution to run or host VM machines with permanent active display opened? Is something like this possible?
I ended up using Virtual Box.
I first created one VM with the needed software and files.
You can start the VM in headless mode. Then show the VM in order to log in to Windows and start the automation script. Then you can close the VM window and let it run in the background. The graphical automation will still run ok in that case. PyAutoGUI won't crash as if there were no active display.
I cloned the original VM 16 times and split the work evenly between the VMs.
Using ssh I am able to connect to each VM and monitor the status of the automations.
It would be great if there were a solution similar to kubernetes that could help with the deployment of such automations and with the monitoring of the status, but until then this is ok.

opening an application using ssh

I'm having a pc that i have a python script on it that uses Gui (moves the mouse while searching some opjects). - PC #1
I need to operate this script from another pc (PC #2) in an automation script (that process is just one of the steps, which repeats a lot, but the only one i have issue with).
both are operating with windows.
PC1 can get connection from SSH. and i need to open this script using the PC2. But this script doesn't operate due to gui i think. it's similar to why for example i can't open Matlab or any othe app in PC1 using SSH.
Any way to do it?
Wasn't able to find an answer online. at the moment i use SSH from PC2 (connected using python) to be used with PC1 to run a specific gui locally.

How do built in macros on Emulators work?

I'm building a script to automate some stuff on my Android emulator I'm currently using pyautogui to do it tho it would be nice if there was some sort of way I can directly interact with the emulator without it relying on my mouse
I know there's an option using ADB but that requires the android to be rooted
a lot of android emulators like Nox, Bluestacks, LDplayer have built-in macros that don't require the device to be rooted.
How do these emulators send commands to the emulator is that something I can tap into and send commands through that instead?
Answer: These emulator run on virtual machines their macro is sending input command from the virtual machine input API

How to Receive Events from an Application running on a Remote Desktop using pywinauto

The automation using pywinauto is working fine in the Remote Desktop Applications with mouse/keyboard and send_keys events.
But I need to track the events generated from the application running on remote desktop to build conditional use case.
For Example, Let's say, I have an excel file opened in the remote desktop and using the pywinauto and send_keys function I can able to write some text in some predefined cell (using mouse co-ordinates) of that file.
But when I'm clicking the exit button in excel it will pop up an window asking if I want to save the excel before closing. I need to catch that event in pywinauto.
pywinauto is running on my local and all the tasks are going to happen on remote desktop (win32).
Note: I don't want to tackle this situation with mouse click on predefined co-ordinates because in-real, based the popup window of my application, I need to do some other tasks.
Remote desktop doesn't pass any GUI elements info to local machine. So you have to run pywinauto script on a remote machine. All necessary recipes are here: Remote Execution Guide.

Control rs232 windows terminal program from python

I am testing a piece of hardware which hosts an ftp server. I connect to the server in order to configure the hardware in question.
My test environment is written in Python 3.
To start the ftp server, I need to launch a special proprietary terminal application on my pc. I must use this software as far as I know and I have no help files for it. I do however know how to use it to launch the ftp server and that's all I need it for.
When I start this app, I go to the menu and open a dialog where I select the com port/speed the hardware is connected to. I then enter the command to launch the ftp server in a console like window within the application. I am then prompted for the admin code for the hardware, which I enter. When I'm finished configuring the device, I issue a command to restart the hardware's software.
In order for me to fully automate my tests, I need to remove the manual starting of this ftp server for each test.
As far as I know, I have two options:
Windows GUI automation
Save the stream of data sent on the com port when using this application.
I've tried to find an GUI automater but pywinauto isn't supporting Python 3. Any other options here which I should look at?
Any suggestions on how I can monitor the com port in question and save the traffic on it?
Thanks,
Barry
Have you looked at pySerial? It's been a few years since I've used it but it was quite good at handling RS-232 communications and it looks like it's compatible with Python 3.x.
Sikuli might provide the kind of GUI automation you need.
I was also able to solve this using WScript, but pySerial was the preferred solution.

Categories