UISpec4J File Chooser Testing - java

I'm trying to use UISpec4J to test a file chooser.
A button is supposed to make the file chooser pop up. I found an example for a file chooser that pops up from a menu option:
WindowInterceptor
.run(openMenu.triggerClick())
.process(FileChooserHandler.init()
.titleEquals("Select a template file")
.assertAcceptsFilesOnly()
.select("/home/bond/file.txt"))
.run();
But I can't seem to get it to work with a simple button click instead - I know this is probably a really simple question but I can't seem to find other documentation to get this to work and I am pretty stuck... Can someone explain how to test this? Thanks!

I've also tried example from documentation and failed. Little change could help:
WindowInterceptor
.init(openMenu.triggerClick())
.process(FileChooserHandler.init()
.titleEquals("Select a template file")
.assertAcceptsFilesOnly()
.select("/home/bond/file.txt"))
.run();
I've replaced first instance of run to init.
Probably, it's a typo in docs.

Related

How to create a Lottie Alert Dialog in Java

I've tried searching for the Java tutorial regarding creating my LottieAlertDialog, but I can't find any. Everywhere it's in Kotlin, but I need the Java code as my project is in Java.
I've tried creating my LottieAlertDialog in this way:
LottieAlertDialog.Builder alert=new LottieAlertDialog.Builder(context,DialogTypes.TYPE_CUSTOM,
"social.json") //Here social.json is inside assets folder
.setTitle("Social")
.setDescription("social");
alert.build();
But the dialogbox doesn't show, when I run the app. To check whether my alert dialogbox was being created or not I tried testing it by printing the description set in the dialog in a Toast:
Toast.makeText(context,alert.getDescription(),Toast.LENGTH_SHORT).show();
The toast works and its showing "social"! That means the dialog is being created. But unfortunately it doesn't show in my app. What do I do? I've implemented all the dependencies as shown in the below link:
lottiealertdialog
Ok, after much hankering, I finally came to the solution. It's
alert.build().show();
The thing is not related to Kotlin or Java as such, you need to show the dialog once you have built it. So far your code is correct. You just need to show it further like this
LottieAlertDialog.Builder alert = new LottieAlertDialog.Builder(context, DialogTypes.TYPE_CUSTOM,
"social.json")
.setTitle("Social")
.setDescription("Social")
.build()
.show();

ImageJ classes used to analyze

I'm developing a ImageJ plugin that It works in my desktop pc but in my laptop it doesn't.
For this reason, now I'm trying to improve and I want to modify the next steps but i can't get it. This is the code:
IJ.selectWindow("example");
IJ.run("Convert to Mask");
IJ.run("Fill Holes");
IJ.run("Set Scale...", "distance=1 known="+pixelSize+" pixel=1 unit=um");
IJ.run("Analyze Particles...", "size=0-Infinity circularity=0.00-1.00 show=Masks display clear record");
I known that "Analyze Particles" I must to use the ParticleAnalyzer class (I dont sure how to do but... I'm researching the class) but for the other steps I can not find solution.
I hope that someone can help, thank you.
Best Regards.
I didn't get what I wanted it but I left to use the windows and now I am using ImagePus variables and It works better. I put the code:
IJ.run(this.cMask, "Convert to Mask", "");
IJ.run(this.cMask, "Fill Holes","");
IJ.run(this.cMask, "Set Scale...", "distance=1 known="+pixelSize+" pixel=1 unit=um");
IJ.run(this.cMask, "Analyze Particles...", "size=0-Infinity circularity=0.00-1.00 display clear record");

Console. Write text with "link" to class/line

Whenever you display a stack trace, you can get a "url-like" text which if you click it opens the appropriate class at the appropriate line.
Is there a possibility to output a text in a way that the console recognizes it and make it clickable like that?
But how would you format the output so it would recognize it as a "link" ?
You can't and you don't.
AndroidStudio supports that feature. You just need to call
exception.printStackTrace() and you should be able to click it in the console tab of IDE.
You will see something like
java.lang.Exception
at whatever.Test.main(Test.java:22)
The text inside the bracket will be highlighted and you can click it.
Based on #JEeemy's answer I managed to do this
public static void printLinkToThisLine() {
System.out.println(Thread.currentThread().getStackTrace()[3]);
}
I works for me ...
I don't know if you're using Eclipse, but the Eclipse console parses based on a pattern: FileName.java:lineNumber.
MyFile.java:3
Would link you to the 3rd line of whatever class you specified as MyFile.
You could use:
.getClass().getName()
to the the name of the file programmatically.

How to link the URL in Robo Help using Java?

I have an application which has lots of UI screens.Each screen will have 'help' button.
When I press help button ,It should link with corresponding help file(Created hel file by robohelp).
for example:
I have created robo help file..in tat, the file will have the user manual for whole related application with different topic.So when I click help button,It should link to corressponding topic in tat file.how to link the same file but diiferent topics for the corresponding screens.
Plz anyone knws the idea,help me?
Please note that RoboHelp creates many different output formats that may be used as the help system. If you are creating WebHelp, take a look at the link below:
http://wvanweelden.eu/robohelp/context_sensitivity_in_webhelp
If you are creating CHM, the process will be similar.
Cheers... Rick :)

Open and maximise a browser window in OATS Java (not javascript)

I am a tester and just installed oracle application test suite to use testing eBus apps
Anyway the only language it supports for coding test scripts (I don't want to use the recorder for a number of reasons). The problem I am having is that everything I search or google is javascript not java (even googling with -script I still ended up looking at javascript. This just gets rejected by the oats editor
The only other examples I have seen, appear to be defining a variable then setting the value of that variable as the window they want to maximize. Aside from the fact that my java skills are not up to doing that - I do not need to do this for a newly opened browser window do I? (The assumption is that this will be the only browser window open (ie test is executed with browser closed)
Is there any easy way to do this?
Below is the very simple initiate of the browser which is generated from a recording plus part of the first step which loads the url the test starts at: (I realize the first step is not complete below -I didn't paste it all, just enough to hopefully allow someone to show me what I need to edit to force the browser to load maximized, or maximize it immediately after loading?
public void initialize() throws Exception {
browser.launch();
}
/**
* Add code to be executed each iteration for this virtual user.
*/
public void run() throws Exception {
beginStep("[1] Login (/RF.jsp)", 0);
{
web
.window(2,
"/web:window[#index='0' or #title='about:blank']")
.navigate(
"http://somepageiwantolaunch");
web.window(4, "/web:window[#index='0' or #title='Login']")
.waitForPage(null);
I am not sure whether you already got the answer for this.. if not this code should help you
browser.launch();
DOMBrowser currentExecutionBrowser = web.window("/web:window[#index='0' or #index='1']");
currentExecutionBrowser.maximize();
Let me know if this helps!
There is a function in the Oracle Functional Tester API Reference which has a build in function called object.WindowState It says you can get or set using this function and it has values
0 - Normal, 1- minimized and 2-maximised.
Only issue is that these examples look more like VB than Javascript but presumably there is a similar function built into to the Oracle libraries for Java.
I did a quick search for Oracle Openscript API and came up with this link which asks for the same thing. They suggest using Help->Search from within the openscript application and then searching for "openscript API" which should provide a list of the functions available.
Hope that helps.
To Maximize browser in OATS, follow the below code
Open script ha in built methods which helps coding easy
browser.launch();
web.window(12, "/web:window[#index='0' or #title='about:blank']").navigate("http://www.google.com/");
web.window(12, "/web:window[#index='0' or #title='about:blank']").maximize();
for more OATS Tips/Tricks follow here
http://www.testinghive.com/category/oracle-application-testing-suite-tips
If it is the only browser window open, you can use the below code. It must be used with caution since the code maximizes any window that is open above the browser window.
try {
Robot a = new Robot();
a.keyPress(KeyEvent.VK_ALT);
a.keyPress(KeyEvent.VK_SPACE);
a.keyRelease(KeyEvent.VK_SPACE);
a.keyRelease(KeyEvent.VK_ALT);
a.keyPress(KeyEvent.VK_X);
a.keyRelease(KeyEvent.VK_X);
} catch (AWTException e) {
}

Categories