Is it possible to name a screenshot taken with robotium? - java

I'm using android to do some testing, and would like to give the screen shots a name other than the time they were taken. Looking at the code, there is a method that can be used to do this by passing a String name into the method, but when I try to do this, I get an error. Does anyone know why this might be?
This is the method I use:
solo.takeScreenshot("FileName");
or:
String fileName = "FileName";
solo.takeScreenshot(filename);
Neither work. Any ideas why?
Thanks!

From looking at the javadocs here: http://code.google.com/p/robotium/downloads/detail?name=robotium-solo-3.3-javadoc.jar
I do not see any takeScreenshot() methods that take arguments. So, without knowing more about what version you are using and what error you are running into, I am not sure I can help.
However, if you want to extend the Solo class to add the method you want, try looking at this question: Android, Robotium - Issue taking screenshot

Related

The constructor refers to the missing type

I have been trying to solve this particular error in my Java project since many days. I have a hard luck solving this.
I have a class in which one of the methods call another class's method using the constructor. Seems everything is correct but this error is not getting solved. I have tried to clean up the project too. But no luck. Please see the screenshots. First image is the class's method that is calling another class's method.

The type JoinMessages must implement the inherited abstract method CommandExecutor.onCommand(CommandSender, Command, String, String[])

So I'm trying to make a Minecraft Plugin at the moment, and I have made my code, most of it is perfect, however for some reason I'm getting the error message (the title) from Eclipse once it's written.
Code found here: https://paste.helpch.at/ucadukekew.java
I'm also getting an error in my Main.java file. "Cannot instantiate the type JoinMessages" next to the code:
this.getCommand("joinmessages").setExecutor(new JoinMessages(this));
Is anyone able to help me get this fixed please? Feel free to let me know if you have any questions
You're using the wrong Command. You're using com.mojang.brigadier.Command (because of your import), but you should be using org.bukkit.command.Command.

How to get method name in Android?

I've been using this instruction to get the name of a method which is currently being used.
currentThread().getStackTrace()[1].getMethodName()
It works fine when I developed Spring Framework or other simple programmings.
However, It seems it works differently in Android Studio. I get time instead of the name of a method.
The reason why I try to use this instruction is for debugging. I used to use
Log.d(TAG, "Method()");
However, The problem when I use this... I should type its method name each. So, To implement this instruction in all the different methods with the same instruction. I found out using currentTrace(). But when I use this on Android Studio. I just get 'geStackTrace' instead of the current method name.
Is there any way to implement it correctly or better way for debugging?
Try this
StackTraceElement[] stacktraceObj = Thread.currentThread().getStackTrace();
stacktraceObj[1].getMethodName();
For further reference, checkout the links
https://www.badprog.com/android-api-getting-the-current-method-name-with-stacktraceelement
https://developer.android.com/reference/java/lang/Throwable.html#getStackTrace()
If typing it out every-time is the issue use the default live templates for log statements.
Use cmd+j(ctrl + j in windows) and look for logd, logi, logw or loge.
By default it prints the method and a colon. You can customize it in preferences.
There's logt for creating a TAG too.

List of functions that were executed during a program in java (using eclipse)

I am currently working on an open source project. I am new in this field. My work is adding a new feature to the currently existing codebase.
However, I do not know where to add my code in the project. The projects contains hundreds of files, classes, and thousands of methods. It is not literally possible to go through each and every line of code.
Eg: Suppose I am working on a project called Calculator. I have the whole source code. Now I type 2 + 3 and hit enter. I get the result 5 which is displayed. But, I need to find where this exact calculation takes place in the source code. For instance, if a method is defined as :
public int add(int a, int b) {
return (a+b);
}
So I need to find this method, whose name is not known to me.
I am currently using the Eclipse IDE.
Can you help me? Or am I approaching this completely the wrong way? If so, how should I go about contributing to open source projects?
I'm not sure if this is exactly what you are looking for but you can access a thread's stackTrace that contains the information about the currently called methods. Therefore you could watch this for getting to know which methods are called.
See this question for how to access the stackTrace.
To access the running code to implement some sort of log mechanism you could use instrumentation to get your code into the running program if you don't have direct access to the code.
This logging method might also be worth a look

How to compare two identical methods in eclipse?

I'm doing android app from a book, for some reason the exact method source code I wrote myself does not work as expected and I am trying to debug it.
I have two exact chunks of code, my method and the sample method.
How to compare them in eclipse?
Select both files by clicking the first, then while holding CTRL click on the second.
Now both of them got selected.
Now click one of them (doesn't matter which one) with the right mouse button.
From the appearing context menu choose:
Compare
Each other
Now you can do a text compare.
Did I get right that neither of the sample method nor your method do what they should?
Then there are two possibilities why the code won't do what it should:
The book is obsolet
You made something wrong
either way, google for your specific problem, maybe someone else has encountered it as well and already solved it.
for your Question: already answered in another comment
use beyond compare, it's a great tool for comparing classes, and methods! download beyond compare

Categories