Trying to run a Robot Framework Test Case against a Windows app with Appium Server - possible? - appium

I am using Robot Framework with the RIDE IDE. I have an Appium Server session running. As a first try, I want to write a Robot Framework test case to open an instance of the Windows notepad. Firstly, is this even possible, or am I misguided?
Appium
The following are the settings used:
Remote Host: 127.0.0.1
Remote Port: 4723
Remote Path: /
SSL: disabled
The "Desired Capabilities" are set as represented by the following JSON:
{
"app": "C:\\Windows\\system32\\notepad.exe"
}
WinAppDriver
It is running on port 4723.
RIDE IDE
The following test case is being executed:
*** Settings ***
Library AppiumLibrary
*** Test Cases ***
TC0
Open Application http://localhost:4723/wd/hub app=C:\Windows\System32\notepad.exe
This yields the following error:
[ WARN ] Keyword 'Capture Page Screenshot' could not be run on failure: No application is open
What might be the cause of this?
Edit: Additional information - when executing the above test case, the following appears in the WinAppDriver console:

Per default AppiumLibrary will run Capture Page Screenshot on failure.
AppiumLibrary Documentation
Most likely sequence is as follow.
Test case try open notepad but fail.
Open Application http://localhost:4723/wd/hub app=C:\Windows\System32\notepad.exe
On this failure AppiumLibrary try Capture Page Screenshot but fails due to there is no open application since step 1 failed.
I believe you need to focus on troubleshooting why the app do not open properly.
If you like to suppress this failure you can you can set AppiumLibrary to not capture screen on failure in the import with run_on_failure=No Operation, see the linked documentation above.
Library AppiumLibrary run_on_failure=No Operation

Slightly unrelated but I just wanted to give a few tips with using winappdriver and robotframework as there isn't a lot of concise information out there.
I personally have found that running the winappdriver through appium has been slower than running the winappdriver standalone.
localhost is also slower than using 127.0.0.1 as your system has to resolve that address each time: https://github.com/microsoft/WinAppDriver/issues/1269
AppiumLibrary is still very tailored to Mobile automation so it is missing some of the usual things you would want in desktop automation such as 'drag and drop', 'mouse over element', keywords for controlling the driver setup/teardown, etc. RobotFramework-Zoomba's DesktopLibrary extends AppiumLibrary and adds a lot of these keywords if you would be willing to try that out. Keyword docs can be found here: https://accruent.github.io/robotframework-zoomba/DesktopLibraryDocumentation.html

Related

Error Could not connect to server; are you sure it's running? In appium

I am getting this error. How to solve this.
Just tick the below checkbox "Allow Unauthorized Certificates" for appium versions 1.6.*
and make sure you are under "Automatic Server" tab
Go to automatic server option and start session . and give the right path of apk file. it is work for me
(appium server 1.7)
After searching and applying lots of solutions finally i did following settings for Successful Android appium app testing on windows machine.
Software:
As of now they have released appium-server and appium-inspector as two seperate softwares. I'm using latest version of repositories.
Appium server 1.22.0
Appium Inspector 2021.9.2
Appium Server Settings
Make sure you have the same settings shown in the images below.
Appium Inspector settings
Steps to start appium:
Start appium server first
Then Start appium Inspector (make sure you add desired capabilities manually otherwise below error msg will arrive if you pasted Json representation manually)
Failed to create session. An unknown server-side error occurred while
processing the command. Original error: You must include a
platformName capability.
After adding Representation it will look like below
{
"platformName": "android",
"deviceName": "emulator-5554",
"appPackage": "com.coswarden",
"appActivity": "ActivityHome"
}
Hope this will solve your error.
You can use UI AutomatorViewer to find the element in the application.
just install jdk8 because appium and uiautomator are compatible with java8 only problem will be solved. And follow below steps:
Right Click on the My Computer and Select the properties
Click on advanced system settings
Click on Environment Variables
Click on new Button of User variables
Type PATH in the Variable name.
Copy the path of bin folder which is installed in JDK folder.
Paste Path of bin folder in Variable value and click on OK Button.
You can follow a similar process to set CLASSPATH.
and restart your PC
Go to command prompt and type javac command and check java8 is installed properly or not.
And see whether android sdk has tools folder in it, In which uiautomator is present
For those who are still struggling to get started, I will add several screenshots to show the complete setup I have for Appium Server GUI, and Appium Inspector.

Appium - AWS device farm

I get an error as below when I try to run my tests on device farm.
testAppiumMethod failed: Invalid server instance exception has occured:
There is no installed nodes! Please install node via NPM
(https://www.npmjs.com/package/appium#using-node-js) or download and
install Appium app (http://appium.io/downloads.html)
I have installed Appium globally on local machine and the tests run fine. But they fail on device farm(have included all the dependencies). Can somebody help me out?
I believe you are trying to invoke the Appium server through your code, which is not required in Device Farm. Device farm has a Test Spec file (which is a yaml file) which does it for you, so all yo need to do is connect your driver to the invoked Appium server.
When you get the chance would you be able to provide this info:
appium verion being used
Specific method that the this failed on/code
snippet
Programming language Java/python
How exactly are the test being packaged and uploaded? Are we using the web console or the SDK/CLI?
Is this a web app tests or native app tests?
Also, to rule out an issue with a specific device would we be able to run the AWS Sample app/test on the same device?
Assuming this is an android test execute these commands to build the sample app:
git clone https://github.com/awslabs/aws-device-farm-sample-app-for-android.git
cd aws-device-farm-sample-app-for-android/
./gradlew cC
The app-debug.apk should be located in ./app/build/outputs/apk/
Then clone the sample appium testng tests:
git clone https://github.com/awslabs/aws-device-farm-appium-tests-for-sample-app.git
cd aws-device-farm-appium-tests-for-sample-app/
mvn clean package -DskipTests=true
The test pacakge "zip-with-dependencies.zip" should be located in the ./target directory
My apologies for adding all these questions as an answer. I look forward to your response.
HTH James
Seems to me that you need to install node on your AWS instance.
See below:
https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/setting-up-node-on-ec2-instance.html

TFS build partially succeeded when calling a batch file, but no error in log

I’m building a solution which requires a batch file to be run after the build (there's a sequence in the workflow for this). TFS flags the build as partially succeeded, but there’s no error in the log even in full verbose mode ("diagnostic"). I’m checking the errorlevel after each line in the batch file and it’s always 0. I’ve also tested redirecting stdout and stderr in a file after each line and there’s no clue there.
It’s got nothing to do with unit tests because I’m skipping them for the time being.
I’ve noticed that usually when an error occurs in a batch file (e.g. file not found) there’s a visual cue to indicate the error and this matches the partially succeeded status. But I don’t see any visual cue.
So how can TFS decide that the build is only partially succeeded?
Thank you,
Solved.
It turns out the GetImpactedTests activity is throwing an exception (I can see it in the event viewer of the TFS machine), but it doesn't show at all in the build log.
I'm guessing that this exception makes the build partially succeeded (because the compilation part succeeded) but I couldn't see the assignment explicitly in the buid log. When I bypass the impact analysis (either by setting Analyze Test Impact to False or by removing the GetImpactedTests activity altogether), the error does not occur.
We experiment something similar here using the Lab Workflow (to kick our CodedUI tests). Different build template, same symptoms.
I have noticed that the build process reports that it partially succeeded, highlighting what seems to be a successful step in the deploy script (batch file).
The command is question is a command to install our mobile app on a mobile device (in order to test it at night):
adb install -d -r test.apk
I thought about looking the errorlevel right after running the adb command but the errorlevel was 0.
Then I thought that maybe the command is sending its output to stderr and found out this article on the android open source project, which confirms my hypothesis.
Following is my fix:
adb install -r -d test.apk 2>&1
Appending 2>&1 simply redirects stderr to stdout and now my deploy script does not report an error anymore and the build now succeeds (when all tests pass!).
Conclusion: When a script writes anything to stderr, the build workflow will report it as an error (partial success since it does not prevent execution of the workflow).
I know this is not your particular issue but since we had the same symptoms, I thought the stderr information could help somebody else find out the reason why their build process is reporting a partial success even though everything seems to work.

How can I get more information about a py2app error?

I am trying to package up a mixed Python/C++ application using py2app. My setup.py is
from setuptools import setup
setup(app=['voxpopuli.py'],data_files=[],options=
{'py2app'{'argv_emulation':True}},setup_requires=['py2app'])
and I invoke py2app via
python setup.py py2app --no-strip --iconfile /Users/irving/otherlab/other/bin/OLicon.icns --resources /opt/local/lib/Resources/qt_menu.nib
This completes without warnings or errors, but when I try to run the resuling app a window pops up that simply says "voxpopuli Error". It has an "Open Console" button, but the only console messages are
9/21/12 11:43:14.691 AM voxpopuli[52765]: voxpopuli Error
9/21/12 11:43:15.926 AM com.apple.launchd.peruser.501[158]: ([0x0-0x177d77c].org.pythonmac.unspecified.voxpopuli[52765]) Exited with code: 255
Are there standard ways to get more information out of py2app to help diagnosing this error?
I believe this is a problem with the app rather than the py2app.
If the app hits an unhandled exception it will exit out like this. Which version of osx are you using? In 10.8 they stopped automatically forwarding stderr to the console, so might be an idea to pipe the applications stdout and stderr to a file to see if you have a stack trace.
Although if it's an error in the C++ part I'm guessing you wouldn't see a stack trace, but the error could be in that part of the application.
If you really can't find the issue, try stripping large parts out the app until it runs then add bits back in until it doesn't run, then strip etc. (like a binary search) to try and find the offending part.
With the package built you can still run the 'application' from the command line.
For example for your project in ~/Projects/MyApp built into folder ~/Projects/MyApp/dist you should find you can run the following from commandline: ~/Projects/MyApp/dist/MyApp.app/Contents/MacOS/MyApp
This will output all the normal stderr messages to the console so you can see what is going wrong.

unable to run scripts from jenkins

We are using sikuli tool for mobile automation on our MAC OSX 10.7.3 I have written a shell script to open simulator and to run scripts on simulator:
SikuliScript.sh
/Users/ezprintsqa/Downloads/FoneMonkey/bin/iphonesim launch /Users/ezprintsqa/Documents/Xcode/DerivedData/SnapCards-btmjdowsgmixpvdyfxfvhxtoihab/Build/Products/Debug-iphonesimulator/SnapCardsFoneMonkey.app&
/Users/ezprintsqa/Downloads/Sikuli-IDE.app/sikuli-ide.sh -r /Users/ezprintsqa/Downloads/SikuliWorkSpace/SnapcardsTestSuite1.sikuli
When I execute from command line I can see simulator opening and scripts getting executed on simulator.
But when I run from Jenkins I am getting the following error:
[JavaAppLauncher Error] CFBundleCopyResourceURL() failed loading MRJApp.properties file
[DEBUG] Could not start simulator session: Error Domain=DTiPhoneSimulatorErrorDomain Code=5 "Operation failed with underlying error 4294956486." UserInfo=0x100305c70 {NSLocalizedDescription=Operation failed with underlying error 4294956486., NSUnderlyingError=0x100300610 "The operation couldn’t be completed. (OSStatus error -10810.)"}
[LaunchRunner Error] No main class specified
[JavaAppLauncher Error] CallStaticVoidMethod() threw an exception
Exception in thread "main" java.lang.NullPointerException
at apple.launcher.LaunchRunner.run(LaunchRunner.java:113)
at apple.launcher.LaunchRunner.callMain(LaunchRunner.java:51)
at apple.launcher.JavaApplicationLauncher.main(JavaApplicationLauncher.java:61)
Any suggestions will be very helpful
It definitely looks like a permission issue. The official Jenkins installer for Mac sets up Jenkins to run either as user "daemon" or user "jenkins". You need to make tools needed by Jenkins readable and executable by that user. Also, they need to be in a directory which is readable and executable by that user.
However, even if you get the permissions fixed, you will probably have further problems with your test run. The official Jenkins installer for Mac sets up Jenkins to run as a launch daemon. These run in the system context and they have no access to any desktop or GUI session, which means it is not possible to draw windows on the screen => Any tool that displays windows, like iPhone Simulator or Sikuli is going to fail.
You could try my unofficial Jenkins.app instead, which should solve your problem. It is available at https://github.com/stisti/jenkins-app (download it under the Downloads tab.)

Resources