Hi,
Anybody knew how to resolve this error using Fest
Unable to find component using matcher org.fest.swing.core.NameMatcher[name='txtGet', type=javax.swing.text.JTextComponent, requireShowing=true].
NewJFrame.java
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package abbot;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
/**
*
* @author sn0018997
*/
public class NewJFrame extends JFrame implements ActionListener {
JButton btnClick;
JLabel lblGet;
JTextField txtGet,txtSet;
NewJFrame() {
btnClick =new JButton("Click");
lblGet =new JLabel("Enter The Text");
txtSet =new JTextField(10);
txtGet=new JTextField(30);
JPanel pnlNew=new JPanel();
pnlNew.setLayout(new BoxLayout(pnlNew,BoxLayout.Y_AXIS));
pnlNew.add(lblGet);
pnlNew.add(txtGet);
pnlNew.add(btnClick);
pnlNew.add(txtSet);
btnClick.addActionListener(this);
Container c=getContentPane();
c.add(pnlNew);
setSize(1000,1400);
setVisible(true);
show();
}
public void actionPerformed(ActionEvent ae){
if (ae.getSource()==btnClick) {
txtSet.setText(txtGet.getText());
}
}
public static void main(String args[]) {
new NewJFrame();
}
}
Newfest.java
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package abbot;
//Requires Fest library:
import org.fest.swing.fixture.FrameFixture;
import abbot.NewJFrame.*;
//Requires JUnit 4.1 library:
import org.junit.Test;
import org.junit.After;
import org.junit.Before;
/**
*
* @author sn0018997
*/
public class Newfest {
private FrameFixture window;
@Before
public void setUp() {
//Assumes the main class is named "NewJFrame" and extends JFrame:
window = new FrameFixture(new NewJFrame());
window.show();
}
@Test
public void NewJFrame() {
//Assumes a JTextField named "txtGet":
window.textBox("txtGet").enterText("Senthil");
//Assumes a JButton named "btnClick":
window.button("btnClick").click();
//Assumes a JTextField named "txtSet":
window.textBox("txtSet").setText("hi");
}
@After
public void tearDown() {
window.cleanUp();
}
}