simulate key press in JUnit tests - java

I am completely stuck in a java test; it's about sending by the test method the character 'a' to the JTextField of a JFrame component.
The JFrame class implements the KeyListener interface, and as such overrides KeyPressed, KeyTyped, and KeyReleased. Along with this, I transfer all the keypressed of the JTextField to the JFrame; inside the JFrame constructor I have :
JTextField txf_version = new JTextField();
txf_version.addKeyListener(this);
I would like to test this behavior and then to simulate the action of type a character in the JTextField.
all my attempts failed; I tried with the java.awt.Robot class, like this : hava a look at this other post in stack overflow, but I get a strange behavior : calling
robot.keyPress(KeyEvent.VK_A);
displays the character in my IDE directly, not in the virtual JFrame! try to play with requestFocus() or requestFocusInWindow() is ineffective.
I also tried with KeyEvents:
KeyEvent key = new KeyEvent(bookWindow.txf_version, KeyEvent.KEY_PRESSED, System
.currentTimeMillis(), 0, KeyEvent.VK_UNDEFINED, 'a');
bookWindow.txf_version.dispatchEvent(key);
but again the textfield's text property is not changed...
here is the method I have for now:
#Test
void testBtnSaveChangesBecomesRedWhenVersionChanged() throws AWTException,
InterruptedException, NoSuchFieldException, IllegalAccessException {
initTest();
KeyEvent key = new KeyEvent(bookWindow.txf_version, KeyEvent.KEY_PRESSED, System
.currentTimeMillis(), 0, KeyEvent.VK_UNDEFINED, 'a');
bookWindow.txf_version.dispatchEvent(key);
System.out.println("dans txf_version : " + bookWindow.txf_version.getText
());
assertEquals(Color.RED, bookWindow.getBtnSaveChangesForegroundColor());
}
I can have a look at the actual behavior by writing a main() method in the JFrame's child class, but I think it is useful to know how to simulate keys for swing components testing.
thank you
EDIT:
I changed the code of my test according to AJNeufeld's answer, but it still doesn't work. Here is my test code :
#Test
void testBtnSaveChangesBecomesRedWhenVersionChanged() throws AWTException,
InterruptedException, NoSuchFieldException, IllegalAccessException,
InvocationTargetException {
//bookEditor2 & bookWindow
SwingUtilities.invokeAndWait(() -> {
bookWindow = new BookWindow();
VectorPerso two = new VectorPerso();
two.add(le_livre_de_la_jungle);
two.add(elogeMaths);
bookWindow.setTableDatas(two);
bookWindow.table.setRowSelectionInterval(1, 1);
bookWindow.txf_version.requestFocusInWindow();
KeyEvent key = new KeyEvent(bookWindow.txf_version, KeyEvent.KEY_TYPED, System
.currentTimeMillis(), 0, KeyEvent.VK_UNDEFINED, 'a');
bookWindow.txf_version.dispatchEvent(key);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println("dans txf_version : " + bookWindow.txf_version.getText
());
assertEquals(Color.RED, bookWindow.getBtnSaveChangesForegroundColor());
});
}
the plintln line produces a text in the console : "dans txf_version : 0", which indicates the key isn't send to the txf_version.
EDIT 2:
new try:
#Test
void testBtnSaveChangesBecomesRedWhenVersionChanged() throws AWTException,
InterruptedException, NoSuchFieldException, IllegalAccessException,
InvocationTargetException {
//bookEditor2 & bookWindow
SwingUtilities.invokeAndWait(() -> {
bookWindow = new BookWindow();
VectorPerso two = new VectorPerso();
two.add(le_livre_de_la_jungle);
two.add(elogeMaths);
bookWindow.setTableDatas(two);
bookWindow.table.setRowSelectionInterval(1, 1);
bookWindow.txf_version.requestFocusInWindow();
KeyEvent key = new KeyEvent(bookWindow.txf_version, KeyEvent.KEY_TYPED, System
.currentTimeMillis(), 0, KeyEvent.VK_UNDEFINED, 'a');
bookWindow.txf_version.dispatchEvent(key);
});
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
SwingUtilities.invokeAndWait(() -> {
System.out.println("dans txf_version : " + bookWindow.txf_version.getText
());
assertEquals(Color.RED, bookWindow.getBtnSaveChangesForegroundColor());
});
}

I think you're doing a couple of things wrong, but without a complete example, it is hard to tell.
First, the JTextField is not really concerned with KEY_PRESSED events. It is concerned with the KEY_TYPED events.
Second, Swing processes events on the Event Dispatching Thread (EDT), which is not necessarily the thread that JUnit is going to be running on. You really shouldn't be changing things when you're not on the EDT. I'm not certain eventDispatch() does the switch to the EDT or not. It might. But it might also do it using invokeLater(), in which case the execution immediately passes to the assertEquals(), which fails, because the event processing hasn't happened yet.
Here is minimal, complete, verifiable example, which shows a keypress sent, which changes the button colour, and a JUnit test case which checks it and passes:
First, the code under test:
public class SwingUnitTesting extends JFrame {
public static void main(String[] args) {
SwingUtilities.invokeLater(SwingUnitTesting::new);
}
JTextField tf = new JTextField();
JButton btn = new JButton("Test Button");
SwingUnitTesting() {
add(tf, BorderLayout.PAGE_END);
add(btn, BorderLayout.PAGE_START);
tf.addKeyListener(new KeyAdapter() {
#Override
public void keyTyped(KeyEvent e) {
btn.setForeground(Color.RED);
}
});
setSize(200, 80);
setLocationByPlatform(true);
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
setVisible(true);
}
}
And the unit test:
public class SwingUnitTestingTest {
SwingUnitTesting sut;
#Before
public void setUp() throws Exception {
SwingUtilities.invokeAndWait(() -> {
sut = new SwingUnitTesting();
});
}
#Test
public void btnNotRedBeforeKeypress() throws InvocationTargetException, InterruptedException {
SwingUtilities.invokeAndWait(() -> {
assertNotEquals(Color.RED, sut.btn.getForeground());
});
}
#Test
public void btnRedAfterKeypress() throws InvocationTargetException, InterruptedException {
SwingUtilities.invokeAndWait(() -> {
sut.tf.requestFocusInWindow();
sut.tf.dispatchEvent(new KeyEvent(sut.tf,
KeyEvent.KEY_TYPED, System.currentTimeMillis(), 0,
KeyEvent.VK_UNDEFINED, 'A'));
assertEquals(Color.RED, sut.btn.getForeground());
});
}
}
You can probably use some JUnit #Rule trickery or a custom runner to automatically change to the EDT when running swing tests.
Update:
I got curious, and tried to find an existing #Rule which puts the #Before, #Test, and #After code on to the EDT, but my Google-fu failed me;
I know I've seen it before, but I couldn't find it.
In the end, I created my own:
public class EDTRule implements TestRule {
#Override
public Statement apply(Statement stmt, Description dscr) {
return new Statement() {
private Throwable ex;
#Override
public void evaluate() throws Throwable {
SwingUtilities.invokeAndWait(() -> {
try {
stmt.evaluate();
} catch (Throwable t) {
ex = t;
}
});
if (ex != null) {
throw ex;
}
}
};
}
}
Using this rule, the JUnit test becomes a little simpler:
public class SwingUnitTestingTest {
#Rule
public TestRule edt = new EDTRule();
SwingUnitTesting sut;
#Before
public void setUp() throws Exception {
sut = new SwingUnitTesting();
}
#Test
public void btnNotRedBeforeKeypress() {
assertNotEquals(Color.RED, sut.btn.getForeground());
}
#Test
public void btnRedAfterKeypress() {
sut.tf.requestFocusInWindow();
sut.tf.dispatchEvent(
new KeyEvent(sut.tf, KeyEvent.KEY_TYPED, System.currentTimeMillis(), 0, KeyEvent.VK_UNDEFINED, 'A'));
assertEquals(Color.RED, sut.btn.getForeground());
}
}
Tested on MacOS, with jdk1.8.0_121

Yo, I guess you have two choices
1) It's still to find a solution using SWING (but in this case, I have no experience and any idead how to help you).
2) It's to use Sikulli java framework for testing desktop app. You can add the dependency then
make screenshot of your UI elements, and put them into test data folder of your app
Using sikuli + JUnit
write simple test where you set a path for your pic of button (for example)
and write action, move, click or what actually you need.
in very simple that will be looks like
Button button = new Button("test-folder/pic1.jpg");
button.click();
After run, you will see that, your cursor was move on button, and click by it.
For more details, find examples in web about Sikulli + Java.

recently I had to test a customized KeyAdapter and I created a customized JTextField to dispatch key events. A piece of the code I used is bellow:
public class ProcessKeyOnTextFieldTest {
#Test
public void pressKeyTest() throws Exception {
JTextFieldWithTypedKeySupport textField = new JTextFieldWithTypedKeySupport();
textField.pressKey('a');
textField.pressKey('b');
assertEquals("ab", textField.getText());
}
class JTextFieldWithTypedKeySupport extends JTextField {
int timestamp;
void pressKey(char key) throws InvocationTargetException, InterruptedException {
SwingUtilities.invokeAndWait(() -> super.processKeyEvent(createEvent(key)));
}
KeyEvent createEvent(char keyChar) {
return new KeyEvent(this, KeyEvent.KEY_TYPED, timestamp++, 0, KeyEvent.VK_UNDEFINED, keyChar);
}
}
}

Related

Java Robot doesnt Press Enter Key how it should

Im trying to program a litte Robot, that should just write for some hours the same phrase with a delay.
But somehow, if i have mor than 1 Letter at the same time before the Enter Key, it rather types a Pyramide.
For Example, if i wanna print "ted", it prints the following:
ted
tedted
tedtedted
tedtedtedted
[...]
(There is no empty line between the Pyramide-Lines)
It gets really frustrating.
I Tried many solutions, but none worked. Making a Delay for the robot, an extra Robot for the Enter Key, put it in an extra Thread or creating new Robots every time before a new Typing. It just doesnt work. What am i doing wrong?
Here is a SSCCE with some trys i did:
#SuppressWarnings("CallToPrintStackTrace")
public class RobotTest {
private static Robot robo;
private static Robot okRobo;
static {
createRobos();
}
private static void createRobos(){
try {
robo = new Robot();
okRobo = new Robot();
} catch (AWTException ex) {
ex.printStackTrace();
}
}
#SuppressWarnings({"CallToPrintStackTrace", "SleepWhileInLoop"})
public static void main(String[] args) throws InterruptedException {
Thread.sleep(5000);
for (int i = 0; i < 16; i++) {
createRobos();
perform();
// Thread.sleep(500);
performOk();
}
}
private static void perform() {
robo.keyPress(KeyEvent.VK_SHIFT);
robo.keyPress(KeyEvent.VK_1);
robo.keyRelease(KeyEvent.VK_SHIFT);
robo.keyRelease(KeyEvent.VK_1);
robo.keyPress(KeyEvent.VK_B);
robo.keyRelease(KeyEvent.VK_B);
robo.keyPress(KeyEvent.VK_O);
robo.keyRelease(KeyEvent.VK_O);
robo.keyPress(KeyEvent.VK_O);
robo.keyRelease(KeyEvent.VK_O);
robo.keyPress(KeyEvent.VK_S);
robo.keyRelease(KeyEvent.VK_S);
robo.keyPress(KeyEvent.VK_T);
robo.keyRelease(KeyEvent.VK_T);
robo.keyPress(KeyEvent.VK_E);
robo.keyRelease(KeyEvent.VK_E);
robo.keyPress(KeyEvent.VK_D);
robo.keyRelease(KeyEvent.VK_D);
// robo.waitForIdle();
}
private static void performOk() {
okRobo.keyPress(KeyEvent.VK_ENTER);
okRobo.keyRelease(KeyEvent.VK_ENTER);
// okRobo.waitForIdle();
}
}
And here is my first try, that should work in my opinion too, but it doesnt:
public class RobotTest {
private static Robot robo;
#SuppressWarnings("CallToPrintStackTrace")
static {
try {
robo = new Robot();
} catch (AWTException ex) {
ex.printStackTrace();
}
}
public static void main(String[] args) throws InterruptedException {
Thread.sleep(5000);
for (int i = 0; i < 16; i++) {
perform();
}
}
private static void perform() {
robo.keyPress(KeyEvent.VK_SHIFT);
robo.keyPress(KeyEvent.VK_1);
robo.keyRelease(KeyEvent.VK_SHIFT);
robo.keyRelease(KeyEvent.VK_1);
robo.keyPress(KeyEvent.VK_B);
robo.keyRelease(KeyEvent.VK_B);
robo.keyPress(KeyEvent.VK_O);
robo.keyRelease(KeyEvent.VK_O);
robo.keyPress(KeyEvent.VK_O);
robo.keyRelease(KeyEvent.VK_O);
robo.keyPress(KeyEvent.VK_S);
robo.keyRelease(KeyEvent.VK_S);
robo.keyPress(KeyEvent.VK_T);
robo.keyRelease(KeyEvent.VK_T);
robo.keyPress(KeyEvent.VK_E);
robo.keyRelease(KeyEvent.VK_E);
robo.keyPress(KeyEvent.VK_D);
robo.keyRelease(KeyEvent.VK_D);
robo.keyPress(KeyEvent.VK_ENTER);
robo.keyRelease(KeyEvent.VK_ENTER);
robo.delay(500);
}
Try not to initialize your Robot at each iteration of the loop. Call createRobos() outside of the loop. That is unless you have a specific reason that you're doing it that way.
I don't think you need two separate instances of Robot to get this to work.
Instead of using Thread.sleep(), you can use the delay() method within the Robot class. This is if you want to add a delay between Robot method calls.
You may want to try to add a delay between when you're typing out the letter keys and when you're pressing the enter key and after you press the enter key. A 50 - 100 ms delay will usually do the trick. Sometimes, things get a little messed up, especially when you throw Thread.sleep() into the mix.
I ran your code with these small changes and it seemed to work fine.

How do i screenshot chrome browser when my tests fail and before the chrome browser closes (#After)

I have ran this code and the screenshot gets captured after the chrome browser closes (#After)
If i comment out CloseBrowser(); the screenshot gets captured but the chromebrowser stay open.
I want the screenshot to capture on a failed test then close the browser.
in summary
The screenshot currently captures after the browser closes, which is just a blank .png
I want the screenshot to capture when a test fails just before the browser closes
Thanks
public class TestClass extends classHelper//has BrowserSetup(); and CloseBrowser(); {
#Rule
public ScreenshotTestRule my = new ScreenshotTestRule();
#Before
public void BeforeTest()
{
BrowserSetup();// launches chromedriver browser
}
#Test
public void ViewAssetPage()
{
//My test code here//And want to take screenshot on failure
}
#After
public void AfterTest() throws InterruptedException
{
CloseBrowser();//closes the browser after test passes or fails
}
}
class ScreenshotTestRule implements MethodRule {
public Statement apply(final Statement statement, final FrameworkMethod frameworkMethod, final Object o) {
return new Statement() {
#Override
public void evaluate() throws Throwable {
try {
statement.evaluate();
} catch (Throwable t) {
captureScreenshot(frameworkMethod.getName());
throw t; // rethrow to allow the failure to be reported to JUnit
}
}
public void captureScreenshot(String fileName) {
try {
new File("target/surefire-reports/").mkdirs(); // Insure directory is there
FileOutputStream out = new FileOutputStream("target/surefire-reports/screenshot-" + fileName + ".png");
out.write(((TakesScreenshot) driver).getScreenshotAs(OutputType.BYTES));
out.close();
} catch (Exception e) {
// No need to crash the tests if the screenshot fails
}
}
};
}
}
You can implement TestNG Listeners to execute code before a test or after a test
Or when a test fails or succeeded etc.
Implement it like below and put your screenshot in the method i showed
public class Listeners implements ITestListener {
Methods…
And put the screenshot code inside the method below:
#Override
public void onTestFailure(ITestResult result) {
code for screenshot
}
}
So i have found a way to implement the screenshots. I have created a method that will take a screenshot. I have put a try and catch around my test code and catch an exception and calling the method to take a screenshot.
public class TestClass extends classHelper//has BrowserSetup(); and CloseBrowser(); {`
#Rule
public ScreenshotTestRule my = new ScreenshotTestRule();
#Before
public void BeforeTest()
{
BrowserSetup();// launches chromedriver browser
}
#Test
public void ViewAssetPage()
{
try
{
//My test code here//And want to take screenshot on failure
}
catch(Exception e)
{
//print e
takeScreenShot();
}
}
#After
public void AfterTest() throws InterruptedException
{
CloseBrowser();//closes the browser after test passes or fails
}
}
///////////////////////////////////////////
void takeScreenShot()
{
try
{
int num = 0;
String fileName = "SS"+NAME.getMethodName()+".png";//name of file/s you wish to create
String dir = "src/test/screenshot";//directory where screenshots live
new File(dir).mkdirs();//makes new directory if does not exist
File myFile = new File(dir,fileName);//creates file in a directory n specified name
while (myFile.exists())//if file name exists increment name with +1
{
fileName = "SS"+NAME.getMethodName()+(num++)+".png";
myFile = new File(dir,fileName);
}
FileOutputStream out = new FileOutputStream(myFile);//creates an output for the created file
out.write(((TakesScreenshot) driver).getScreenshotAs(OutputType.BYTES));//Takes screenshot and writes the screenshot data to the created file
//FileOutputStream out = new FileOutputStream("target/surefire-reports/" + fileName);
out.close();//closes the outputstream for the file
}
catch (Exception e)
{
// No need to crash the tests if the screenshot fails
}
This might help:
https://github.com/junit-team/junit4/issues/383
The ordering for rule execution has changed with new 'TestRule'

How to write a junit test script?

I wrote a java code which is working but I have to write a Junit Test Script for it, but I do not have the experience yet. I tried several hours, but I can not understand how it works. So your help is very welcomed. Thanks in advance :) Do you have any tipps for me? :)
import java.awt.*;
import java.awt.event.*;
class MailBox extends Frame {
private boolean request;
private String message;
TextField tf1;
public MailBox() {
Dimension screenDim = getToolkit().getScreenSize();
Dimension frameDim = getPreferredSize();
setLocation((screenDim.width-frameDim.width)/2, (screenDim.heightframeDim.height)/2); addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
dispose();
System.exit(0);
}
}
Panel myPanel = new Panel();
myPanel.setLayout(new FlowLayout());
Label label1 = new Label("Message: ");
Button button1 = new Button("Send");
button1.addActionListener(new button1AL());
tf1 = new TextField("", 20);
myPanel.add(label1);
myPanel.add(tf1);
myPanel.add(button1);
add(myPanel, BorderLayout.CENTER);
setTitle("Mailbox");
pack();
show();
}
public synchronized void storeMessage(String message){
while(request==true){
try{
wait();
}
catch(InterruptedException e){
}
}
request = true;
this.message = message;
notify();
}
public synchronized String retrieveMessage(){
while(request==false){
try{
wait();
}
catch(InterruptedException e){
}
}
request=false;
notify();
return message;
}
public static void main(String args[]) {
System.out.println("Starting Mailbox...");
MailBox MyMailBox = new MailBox();
Consumer c1 = new Consumer(MyMailBox);
Thread t1 = new Thread(c1);
t1.start();
}
class button1AL implements ActionListener{
public void actionPerformed(ActionEvent ae){
storeMessage(tf1.getText());
tf1.setText("");
}
}
}
I would say that in your case the program did not reach yet the level when it should be Unit tested. I don't see any reason why you need to test that some constructor works when it just initializes the fields of the class and also that the program prints something. I would not check that.
In the case when you get some error and this error might contain different error messages, it is a good idea to verify that the message is the same, but this is not your case. So, the main point is that your unit test should test business logic.
Consider this template:
#Test
public void testGoUntilTankIsEmpty() throws Exception {
// SETUP SUT
Car car = new Car();
car.fillFullTank();
car.setSpeed(80);
// EXERCISE
int distanceInKm = car.goUntilTankIsEmpty();
// VERIFY
Assert.assertEquals(800, distanceInKm);
}
In this case we exercise (test) specified method and expect that the result will be 800 based on our preliminary setup. If it is true your unit test will pass otherwise it will fail.
And remember that unit test should test only some unit, so some small piece of code, but actual functionality.
JUnit's work by testing the code you have written with either the expected output, or incorrect output if you want to test whether your error handling works.
In your case you'd just test against the expected string it outputs.
So a basic test for what you have would look something along the lines of...
import org.junit.Test;
import org.junit.Assert.assertEquals
public class BasicTest{
#Test
public void describeAnimalTest(){
AnimalNew animal = new AnimalNew("Dog", 10, "x");
assertEquals("Dog is on level 10 und is a type of x", animal.describeAnimal();
}
}

How to handle frame in page object model

Can you please tell me how to handle frames in page object model??
While trying with linear script the same works but when i moved the same to page object model then the script fails.
Currently in my framework below is the process i followed:
Made switchTo() as a generic function and placed in the generic library.
In pages where there needs a control to be moved to the required frame I've called switchTo() method of the generic library.
Next after passing the control to frame I've performed action in the required web element.(The thing is it is unable to find the particular object)
Can anyone tell me the possible issue ?
Common Library:
public void switchToFrame(int frame)
{
try
{
Driver.driver.switchTo().frame(frame);
System.out.println("Navigated to frame with name " + frame);
}
catch (NoSuchFrameException e)
{
System.out.println("Unable to locate frame with id " + frame + e.getStackTrace());
}
}
pages :
public void createticket(String interactionTitle,String interactionDesc,String category,String originText,String priorityText,String impactText) throws InterruptedException
{
switchToFrame(1);
System.out.println("Navigated to Frame");
waitForIdPresent("X49");
titleEdt.sendKeys(interactionTitle);//unable to enter here
descEdt.sendKeys(interactionDesc);
dropDown(origipublic void createInteraction(String interactionTitle,String interactionDesc,String category,String originText,String priorityText,String impactText) throws InterruptedException
{
switchToFrame(1);
System.out.println("Navigated to Frame");
waitForIdPresent("X49");
Driver.driver.findElement(By.id("X49")).sendKeys(interactionTitle);
descEdt.sendKeys(interactionDesc);
dropDown(originDropDown, originText);
}
Test script :
#Test
public void createTestTicket() throws EncryptedDocumentException, InvalidFormatException, IOException, InterruptedException{
homePage.getBtn().click();
homePage.getLnk().click();
interactionDetails.createTicket("test ticket","test ticket","incident","CALL","P1 / <1hour","1 - Enterprise");
}
I think, waitForIdPresent("id") is throwing the error in your case.
In the comment you have provided, you
public void waitForIdPresent(String wbId)
{
WebDriverWait wait = new WebDriverWait(Driver.driver,20);
wait.until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.name(wbId))); ‌
}
Change By.name to By.id in this.

jemmy fx testing fx ui gives me an IllegalStateException when clicking a button

I want to test my javafx UI. I have an Application.class that has the main function and loads a scene (a login screen). My testing code
#Before
public void startApp() throws InterruptedException {
startApp(Application.class);
scene = new SceneDock();
this.username = new TextInputControlDock(scene.asParent(), "txtFieldUsername");
this.password = new TextInputControlDock(scene.asParent(), "txtFieldPassword");
this.btnLogin = new LabeledDock(scene.asParent(), "Login", StringComparePolicy.EXACT);
this.btnCancel = new LabeledDock(scene.asParent(), "Cancel", StringComparePolicy.EXACT);
}
#Test
public void loginScreenMustContainTwoButtonsCancelAndLogin() throws Exception {
assertEquals(Button.class, new LabeledDock(scene.asParent(), "Cancel",
StringComparePolicy.EXACT).wrap().getControl().getClass());
assertEquals(Button.class, new LabeledDock(scene.asParent(), "Login",
StringComparePolicy.EXACT).wrap().getControl().getClass());
}
#Test
public void loginScreenMustContainTwoTextFieldsUsernameAndPassword() throws Exception {
TextInputControlDock username = new TextInputControlDock(scene.asParent(), "txtFieldUsername");
TextInputControlDock password = new TextInputControlDock(scene.asParent(), "txtFieldPassword");
assertTrue(username.wrap().getControl() instanceof TextField);
assertTrue(password.wrap().getControl() instanceof PasswordField);
}
#Ignore
#Test(expected=TimeoutExpiredException.class)
public void loginWindowHasAnErrorLabel() throws Exception {
NodeDock errorLabel = new NodeDock(scene.asParent(), Label.class, "lblErrorMessage");
assertTrue(errorLabel.wrap().getControl() instanceof Label);
}
#Test
public void loginButtonWithNoInputShowsErrorText() throws Exception {
log.debug("Clicking login button");
btnLogin.wrap().mouse().click(1);
log.debug(scene);
}
private void startApp(Class<AvalancheClient> app) {
// TODO Auto-generated method stub
AppExecutor.executeNoBlock(app);
}
After I added this text loginButtonWithNoInputShowsErrorText I always get the following error
Exception in thread "Thread-7" java.lang.IllegalStateException: Application launch must not be called more than once
Why is it happening. I am basing my code at the samples of openjfx I found on the internet, because I haven't found an analytic documentation and reference on jemmyfx yet. Could you help me a bit?
Well I found what was wrong...The AppExecutor must be called in #BeforeClass annotated method(static) and not in #Before method. It works now.

Categories

Resources