[APPIUM LOGGING] I wanted to track if which particular element has been clicked while testing App.

715 views
Skip to first unread message

Krishnamachari Shrikanth

unread,
Feb 26, 2014, 9:58:24 PM2/26/14
to appium-...@googlegroups.com
Hi All,

We are using Appium in our Master project for Android testing. I wanted to track which element is clicked on the device during testing.

I understand, since I am tester I would not be able to access the .apk code. I learnt that in AndroidManifest XML I can set WRITE_PERMISSION
but this can be done when you develop the App. I do not have access to that app source code.

I went through the entire Appium Source code for understanding the flow when AppiumBootstrap sends certain action commands on the device. I saw that
the git hub clone that I did had customized Logger implementation which says it send the log to Appium server. I tried insert some of my logger statements
using normal logger (log4j) and also using FileWriter but it gave the ENOENT error for fileNotFound. I wonder why because I am not inserting any logging activity on the apk code.

Any help would be nice to have on this. Attached file is my understanding of the flow from the source code. Let me know if I am doing something wrong. Till then I am looking at another option of inserting my test code at the Appium Server level.

Regards,
Krish
FlowForTestCaseEvents.doc

Krishnamachari Shrikanth

unread,
Feb 26, 2014, 10:23:32 PM2/26/14
to appium-...@googlegroups.com
This is the full stack trace of exception:

[UIAUTOMATOR STDOUT] java.io.IOException: open failed: ENOENT (No such file or directory)
info: [UIAUTOMATOR STDOUT] at
info: [UIAUTOMATOR STDOUT] java.io.File.createNewFile(File.java:946)
info: [UIAUTOMATOR STDOUT] at io.appium.android.bootstrap.utils.OperationalTrace.writeTraceToFile(OperationalTrace.java:31)
info: [UIAUTOMATOR STDOUT] at io.appium.android.bootstrap.handler.Click.execute(Click.java:44)
info: [UIAUTOMATOR STDOUT] at io.appium.android.bootstrap.AndroidCommandExecutor.execute(AndroidCommandExecutor.java:87)
info: [UIAUTOMATOR STDOUT] at
info: [UIAUTOMATOR STDOUT] io.appium.android.bootstrap.SocketServer.runCommand(SocketServer.java:195)
info: [UIAUTOMATOR STDOUT] at io.appium.android.bootstrap.SocketServer.handleClientData(SocketServer.java:93)
info: [UIAUTOMATOR STDOUT] at io.appium.android.bootstrap.SocketServer.listenForever(SocketServer.java:137)
info: [UIAUTOMATOR STDOUT] at
info: [UIAUTOMATOR STDOUT] io.appium.android.bootstrap.Bootstrap.testRunServer(Bootstrap.java:17)
info: [UIAUTOMATOR STDOUT] at java.lang.reflect.Method.invokeNative(Native Method)
info: [UIAUTOMATOR STDOUT] at java.lang.reflect.Method.invoke(Method.java:515)
info: [UIAUTOMATOR STDOUT] at junit.framework.TestCase.runTest(TestCase.java:168)
info: [UIAUTOMATOR STDOUT] at
info: [UIAUTOMATOR STDOUT] junit.framework.TestCase.runBare(TestCase.java:134)
info: [UIAUTOMATOR STDOUT] at junit.framework.TestResult$1.protect(TestResult.java:115)
info: [UIAUTOMATOR STDOUT] at junit.framework.TestResult.runProtected(TestResult.java:133)
info: [UIAUTOMATOR STDOUT] at
info: [UIAUTOMATOR STDOUT] junit.framework.TestResult.run(TestResult.java:118)
info: [UIAUTOMATOR STDOUT] at junit.framework.TestCase.run(TestCase.java:124)
info: [UIAUTOMATOR STDOUT] at com.android.uiautomator.testrunner.UiAutomatorTestRunner.start(UiAutomatorTestRunner.java:160)
info: [UIAUTOMATOR STDOUT] at com.android.uiautomator.testrunner.UiAutomatorTestRunner.run(UiAutomatorTestRunner.java:96)
info: [UIAUTOMATOR STDOUT] at com.android.commands.uiautomator.RunTestCommand.run(RunTestCommand.java:91)
info: [UIAUTOMATOR STDOUT] at com.android.commands.uiautomator.Launcher.main(Launcher.java:83)
info: [UIAUTOMATOR STDOUT] at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
info: [UIAUTOMATOR STDOUT] at
info: [UIAUTOMATOR STDOUT] com.android.internal.os.RuntimeInit.main(RuntimeInit.java:243)
info: [UIAUTOMATOR STDOUT] at dalvik.system.NativeStart.main(Native Method)
info: [UIAUTOMATOR STDOUT] Caused by: libcore.io.ErrnoException: open failed: ENOENT (No such file or directory)
info: [UIAUTOMATOR STDOUT] at libcore.io.Posix.open(Native Method)
info: [UIAUTOMATOR STDOUT] at libcore.io.BlockGuardOs.open(BlockGuardOs.java:110)
info: [UIAUTOMATOR STDOUT] at java.io.File.createNewFile(File.java:939)
info: [UIAUTOMATOR STDOUT] ... 22 more

Jonathan Lipps

unread,
Feb 27, 2014, 4:13:26 PM2/27/14
to appium-...@googlegroups.com
I don't understand what you're doing. You want to add more logging to the AndroidBootstrap? Then just use the provided Logger class...

Or are you trying to do something else?

Krishnamachari Shrikanth

unread,
Feb 27, 2014, 4:23:49 PM2/27/14
to Jonathan Lipps, appium-...@googlegroups.com

Yes.... I tried to use the existing logger class.... But my requirement is to track which action took place into a file.... But when I try doing that I the above exception....

--
http://appium.io
---
You received this message because you are subscribed to a topic in the Google Groups "Appium-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/appium-discuss/xNlRMvTjZL8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to appium-discus...@googlegroups.com.
Visit this group at http://groups.google.com/group/appium-discuss.
For more options, visit https://groups.google.com/groups/opt_out.

bootstrap online

unread,
Feb 27, 2014, 4:25:53 PM2/27/14
to Krishnamachari Shrikanth, Jonathan Lipps, appium-...@googlegroups.com
The uiautomator event stream can be dumped to a file using the adb
command I posted previously.
> You received this message because you are subscribed to the Google Groups
> "Appium-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an

Jonathan Lipps

unread,
Feb 27, 2014, 4:27:49 PM2/27/14
to bootstrap online, Krishnamachari Shrikanth, appium-...@googlegroups.com
Yeah, the purpose of Logger is to write logs to stdout so that the Appium server can collect them and display them in its own log output. If you're trying to write to a file you'll need to include all the appropriate classes etc. And bootstrap's suggestion is the way to go in the first place.

Krishnamachari Shrikanth

unread,
Feb 27, 2014, 4:33:27 PM2/27/14
to Jonathan Lipps, appium-...@googlegroups.com, bootstrap online

Thanks.... Will try that....

Satyajit Malugu

unread,
Feb 27, 2014, 6:43:27 PM2/27/14
to Krishnamachari Shrikanth, Jonathan Lipps, appium-...@googlegroups.com, bootstrap online
I have to question your requirement though. You want to verify that a particular happened, after you have triggered that click from your test code?
The best source of that information is your test code, it knows everything it tries to do. If something doesn't happen - tests fail, appium reports that.

If you are bent on getting that information, I would suggest something like this, ( I did this in past)

Log("Trying to click button"+ button)
try{
button.click()
Log(button + "has been clicked");
}
catch
{
Log("failed to click " + button);
}
February 27, 2014 at 1:33 PM

Thanks.... Will try that....

--
http://appium.io
---
You received this message because you are subscribed to the Google Groups "Appium-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to appium-discus...@googlegroups.com.
Visit this group at http://groups.google.com/group/appium-discuss.
For more options, visit https://groups.google.com/groups/opt_out.
February 27, 2014 at 1:27 PM
Yeah, the purpose of Logger is to write logs to stdout so that the Appium server can collect them and display them in its own log output. If you're trying to write to a file you'll need to include all the appropriate classes etc. And bootstrap's suggestion is the way to go in the first place.


February 27, 2014 at 1:25 PM
The uiautomator event stream can be dumped to a file using the adb
command I posted previously.

On Thu, Feb 27, 2014 at 4:23 PM, Krishnamachari Shrikanth

February 27, 2014 at 1:23 PM

Yes.... I tried to use the existing logger class.... But my requirement is to track which action took place into a file.... But when I try doing that I the above exception....

--
http://appium.io
---
You received this message because you are subscribed to the Google Groups "Appium-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to appium-discus...@googlegroups.com.
Visit this group at http://groups.google.com/group/appium-discuss.
For more options, visit https://groups.google.com/groups/opt_out.
February 27, 2014 at 1:13 PM

Krishnamachari Shrikanth

unread,
Feb 27, 2014, 6:48:38 PM2/27/14
to Satyajit Malugu, bootstrap online, appium-...@googlegroups.com, Jonathan Lipps

The thing is we are building a platform where we recieve the test case or suite from client.... And run it using appium.... Then we need to trace which scenario ran....

Something like we wanted to provide... Configuration tracing. . operational tracing...and coverage report ..

So since this case would not be mine how can I add those code lines in the case.... Hope you got what I wanted to convey....

Reply all
Reply to author
Forward
0 new messages