windowsshellautomationadbeggplant

How do I execute shell commands through eggPlant on Windows?


I am working on test automation for an Android app. I am currently using eggPlant for Android. Summary of my present situation:

Documentation on eggPlant websites (1 and 2) talks about the ability in eggPlant to run commands on the local shell. The examples (at the time of writing) are for Mac. I tried various modifications to these examples to make them run on Windows, such as:

e.g. 1

put shell("dir")

e.g. 2

set the shellCommand to "ShellExecute"
shell "example.bat" //where example.bat contains "dir"

e.g. 3

shell "C:\Windows\system32\cmd.exe /c dir" 

My ultimate objective is to run adb commands off the Windows shell. But the problems I am facing are:

How do I proceed?


Solution

  • I was able to get this working in conjunction with TestPlant Support.

    In this example I want to run adb shell "df | grep data | awk '{print $4}'" which will basically print out the free space in the /data folder of my Android Device.

    Since my code has quotes, I have to enclose the code within <<>> .

    to adb
        set command to <<shell "df | grep data  | awk '{print $4}'">>
        put "D:\adt-bundle\sdk\platform-tools" into sdkPath 
        set cmd to " /c " && sdkPath & "\adb.exe" && command && " > C:\adbOutput.txt"
        put cmd
        shell "C:\Windows\system32\cmd.exe", cmd
    end adb
    

    The value of the variable cmd expands to /c D:\adt-bundle\sdk\platform-tools\adb.exe shell "df | grep data | awk '{print $4}'" > C:\adbOutput.txt.

    Ultimately what gets executed is equivalent to

    cmd /c D:\adt-bundle\sdk\platform-tools\adb.exe shell "df | grep data  | awk '{print $4}'"  > C:\adbOutput.txt
    

    If I want to make the adb handler accept parameters, I'd add a Params cmd line to the adb handler, obviously.