Java Code Examples for org.netbeans.jemmy.operators.JTextFieldOperator#typeText()

The following examples show how to use org.netbeans.jemmy.operators.JTextFieldOperator#typeText() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PropertyGeneration.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testTypeBrowse() {
    try {
        operator = openEditor("Beans");
        operator.setCaretPosition(4, 1);
        openDialog(operator);
        AddProperty addProperty = new AddProperty();
        addProperty.browse();
        NbDialogOperator ndo = new NbDialogOperator("Find Type");
        JTextFieldOperator jtfo = new JTextFieldOperator(ndo);
        jtfo.typeText("LinkedList");
        ndo.ok();
        assertEquals("java.util.LinkedList", addProperty.cboType().getTextField().getText());
        addProperty.cancel();            
    } finally {
        if (operator != null) {
            operator.closeDiscard();
        }
    }
}
 
Example 2
Source File: NewFileWizardsTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void puTest(String prjRoot, String name) throws Exception {
    Project p = J2eeProjectSupport.getProject(new File(projectLocation), prjRoot);
    NewFileWizardOperator nfwo = WizardUtils.createNewFile(p,
            "Persistence", "Persistence Unit");
    JTextFieldOperator jtfo = new JTextFieldOperator(nfwo, 0);
    jtfo.clearText();
    jtfo.typeText(name);
    JComboBoxOperator jcbo = new JComboBoxOperator(nfwo, 1);
    jcbo.selectItem("jdbc/sample");
    nfwo.finish();
    nfwo.waitClosed();
    List<File> files = new ArrayList<File>();
    File prjDir = new File(new File(projectLocation), prjRoot).getCanonicalFile();
    files.add(new File(prjDir, "src/conf/persistence.xml"));
    checkFiles(files);
}
 
Example 3
Source File: Utilities.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/** 
 * This method create new Java Application project
 */

public static String createNewProject(String projectName, String dataProjectName, String workdirpath){
    NewProjectWizardOperator nfwo = NewProjectWizardOperator.invoke();
    nfwo.selectCategory(projectName);
    nfwo.selectProject("Java Application");
    nfwo.next();
    
    JTextFieldOperator tfo_name = new JTextFieldOperator(nfwo, 0);
    tfo_name.clearText();
    tfo_name.typeText(dataProjectName);
    
    JTextFieldOperator tfo1_location = new JTextFieldOperator(nfwo, 1);
    
    tfo1_location.clearText();
    tfo1_location.typeText(workdirpath);
    
    JButtonOperator bo = new JButtonOperator(nfwo, "Finish");
    //bo.getSource().requestFocus();
    bo.push();
    return dataProjectName;
}
 
Example 4
Source File: TestUtils.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Use New Project wizard to generate FX project of given type and name.
 * 
 * @param projectType
 * @param projectName
 * @param workDirPath 
 */
public static void createJavaFX2Project(String projectType, String projectName, String workDirPath) {
    NewProjectWizardOperator npwop = NewProjectWizardOperator.invoke();
    npwop.selectCategory(JAVAFX_PROJECT_CATEGORY);
    npwop.selectProject(projectType);
    npwop.next();

    new EventTool().waitNoEvent(2000);

    JTextFieldOperator projectNameField = new JTextFieldOperator(npwop, 0);
    projectNameField.clearText();
    projectNameField.typeText(projectName);

    JTextFieldOperator projectLocation = new JTextFieldOperator(npwop, 1);
    projectLocation.clearText();
    projectLocation.typeText(workDirPath + File.separator
            + Calendar.getInstance().getTimeInMillis());

    new EventTool().waitNoEvent(2000);

    npwop.finish();

    new EventTool().waitNoEvent(5000); //wait for complete project creation, nodes it Projects View must be populated
}
 
Example 5
Source File: TestUtils.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public static void createJavaFX2FXMLFile(String fileType, String projectName, String fileName) {
    NewFileWizardOperator nfwo = newJavaFX2FileTemplateSelection(fileType, projectName);
    //fxml name
    JTextFieldOperator fxmlName = new JTextFieldOperator(nfwo, 0);
    fxmlName.clearText();
    fxmlName.typeText(fileName);
    nfwo.next();
    //fxml controller        
    JCheckBoxOperator useCtrlr = new JCheckBoxOperator(nfwo, 0);
    useCtrlr.clickMouse();
    nfwo.next();
    //fxml css
    JCheckBoxOperator useCSS = new JCheckBoxOperator(nfwo, 0);
    useCSS.clickMouse();
    nfwo.finish();

    new EventTool().waitNoEvent(2000);
}
 
Example 6
Source File: SetUpDerbyDatabaseTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** Sets db server path and database folder path */
public void testSetupDbPaths() {
    String derbyHomeDirPath = null;
    String dbDirPath = null;
    
    try {
        derbyHomeDirPath = getDerbyHomeDir();
        dbDirPath = getTempDerbyDbDir();
    } catch (Exception e){
        fail(e.getMessage());
    }
    
    if (derbyHomeDirPath != null && dbDirPath != null) {
        // invoke and catch db settings dialog
        new ActionNoBlock(DB_SETTINGS_MENU, null).perform(); // NOI18N
        DialogOperator op = new DialogOperator(DB_SETTINGS_DIALOG_TITLE);
        
        // setup derby db home 
        JTextFieldOperator derbyHomeOp = new JTextFieldOperator(op,1);
        derbyHomeOp.clearText();
        derbyHomeOp.typeText(derbyHomeDirPath);
        
        // setup database folder
        JTextFieldOperator dbPathOp = new JTextFieldOperator(op,0);
        dbPathOp.clearText();
        dbPathOp.typeText(dbDirPath);
        
        // close settings dialog
        new JButtonOperator(op,"OK").clickMouse(); // NOI18N
    }
}
 
Example 7
Source File: OptionPaneDemoTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private void useInputDialog(JFrameOperator jfo, String textToType, String buttonToPush) {
    new JButtonOperator(jfo, INPUT_BUTTON).pushNoBlock();
    JDialogOperator jdo = new JDialogOperator(INPUT);
    if(textToType != null) {
        JTextFieldOperator jto = new JTextFieldOperator(jdo);
        jto.typeText(textToType);
        jto.waitText(textToType);
    }
    new JButtonOperator(jdo, buttonToPush).push();
    jdo.waitClosed();
}
 
Example 8
Source File: TextFieldDemoTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private void historyTextField(JFrameOperator jfo) throws Exception {
    JTextFieldOperator jtfo = new JTextFieldOperator(jfo, new ByClassChooser(JHistoryTextField.class));
    jtfo.typeText("cat");

    jtfo.pressKey(KeyEvent.VK_DOWN);
    jtfo.pressKey(KeyEvent.VK_DOWN);
    jtfo.pressKey(KeyEvent.VK_ENTER);

    final String expectedValue = "category";
    jtfo.waitText(expectedValue);
    assertEquals("Select History Item", expectedValue, jtfo.getText());
}
 
Example 9
Source File: CreateNewIndexedProperty.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** testType method */
public void testType() {
    RepositoryTabOperator explorerOperator = new RepositoryTabOperator();
    
    Node repositoryRootNode = explorerOperator.getRootNode();
    Node patternsNode = new Node(repositoryRootNode, sampleDir+"|"+NAME_TEST_FILE+"|"+"class "+NAME_TEST_FILE+"|"+Bundle.getString("org.netbeans.modules.beans.Bundle", "Patterns"));
    patternsNode.select();
    patternsNode.performPopupActionNoBlock(Bundle.getString("org.openide.src.nodes.Bundle", "LAB_Add")+"|"+Bundle.getString("org.netbeans.modules.beans.Bundle", "MENU_CREATE_IDXPROPERTY"));
    String dialogTitle = Bundle.getString("org.netbeans.modules.beans.Bundle", "CTL_TITLE_NewIdxProperty");
    NbDialogOperator nbDialogOperator = new NbDialogOperator(dialogTitle);

    JTextFieldOperator jTextFieldOperator = new JTextFieldOperator(nbDialogOperator, 0);       
    jTextFieldOperator.typeText(NAME_INDEX_PROPERTY);        
    
    JComboBoxOperator jComboBoxOperator = new JComboBoxOperator(nbDialogOperator, 0);
    jComboBoxOperator.typeText(TYPE_WRONG);
    
    nbDialogOperator.ok();

    new EventTool().waitNoEvent(3000);

    new NbDialogOperator("Error").ok();
                          
    jTextFieldOperator.clearText();
    jTextFieldOperator.typeText(NAME_INDEX_PROPERTY);
    jComboBoxOperator.clearText();
    jComboBoxOperator.setSelectedItem("Double");
                   
    nbDialogOperator.ok();

    new JavaNode(repositoryRootNode, sampleDir + "|" + NAME_TEST_FILE).open();

    EditorOperator eo = new EditorOperator(NAME_TEST_FILE);
    ref(eo.getText());
    compareReferenceFiles();                       
}
 
Example 10
Source File: CreateNewNonIndexedProperty.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** testName method */
public void testName() {
    RepositoryTabOperator explorerOperator = new RepositoryTabOperator();
    
    Node repositoryRootNode = explorerOperator.getRootNode();
    Node patternsNode = new Node(repositoryRootNode, sampleDir+"|"+NAME_TEST_FILE+"|"+"class "+NAME_TEST_FILE+"|"+Bundle.getString("org.netbeans.modules.beans.Bundle", "Patterns"));
    patternsNode.select();
    patternsNode.performPopupActionNoBlock(Bundle.getString("org.openide.src.nodes.Bundle", "LAB_Add")+"|"+Bundle.getString("org.netbeans.modules.beans.Bundle", "MENU_CREATE_PROPERTY"));
    String dialogTitle = Bundle.getString("org.netbeans.modules.beans.Bundle", "CTL_TITLE_NewProperty");
    NbDialogOperator nbDialogOperator = new NbDialogOperator(dialogTitle);

    JTextFieldOperator jTextFieldOperator = new JTextFieldOperator(nbDialogOperator, 0);       
    jTextFieldOperator.typeText(NAME_WRONG);        

    JComboBoxOperator jComboBoxOperator = new JComboBoxOperator(nbDialogOperator, 0);
    jComboBoxOperator.setSelectedItem("String");
    
    nbDialogOperator.ok();

    new EventTool().waitNoEvent(3000);

    new NbDialogOperator("Error").ok();
                          
    jTextFieldOperator.clearText();
    jTextFieldOperator.typeText(NAME_NON_INDEX_PROPERTY);
    
    jComboBoxOperator.setSelectedItem("String");
                   
    nbDialogOperator.ok();

    new JavaNode(repositoryRootNode, sampleDir + "|" + NAME_TEST_FILE).open();

    EditorOperator eo = new EditorOperator(NAME_TEST_FILE);
    ref(eo.getText());
    compareReferenceFiles();                               
}
 
Example 11
Source File: CreateNewNonIndexedProperty.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** testType method */ 
public void testType() {

    RepositoryTabOperator explorerOperator = new RepositoryTabOperator();
    
    
    Node repositoryRootNode = explorerOperator.getRootNode();
    Node patternsNode = new Node(repositoryRootNode, sampleDir+"|"+NAME_TEST_FILE+"|"+"class "+NAME_TEST_FILE+"|"+Bundle.getString("org.netbeans.modules.beans.Bundle", "Patterns"));
    patternsNode.select();
    patternsNode.performPopupActionNoBlock(Bundle.getString("org.openide.src.nodes.Bundle", "LAB_Add")+"|"+Bundle.getString("org.netbeans.modules.beans.Bundle", "MENU_CREATE_PROPERTY"));
    String dialogTitle = Bundle.getString("org.netbeans.modules.beans.Bundle", "CTL_TITLE_NewProperty");
    NbDialogOperator nbDialogOperator = new NbDialogOperator(dialogTitle);

    JTextFieldOperator jTextFieldOperator = new JTextFieldOperator(nbDialogOperator, 0);       
    jTextFieldOperator.typeText(NAME_NON_INDEX_PROPERTY);
    
    JComboBoxOperator jComboBoxOperator = new JComboBoxOperator(nbDialogOperator, 0);
    jComboBoxOperator.typeText(TYPE_WRONG);
    nbDialogOperator.ok();

    new EventTool().waitNoEvent(3000);
    new NbDialogOperator("Error").ok();

    jTextFieldOperator.clearText();
    jTextFieldOperator.typeText(NAME_NON_INDEX_PROPERTY);
    jComboBoxOperator.clearText();
    jComboBoxOperator.setSelectedItem("Double");
                   
    nbDialogOperator.ok();
    new JavaNode(repositoryRootNode, sampleDir + "|" + NAME_TEST_FILE).open();

    EditorOperator eo = new EditorOperator(NAME_TEST_FILE);
    ref(eo.getText());
    compareReferenceFiles();                               
                                   
}
 
Example 12
Source File: WizardsTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** Test new project wizard using generic WizardOperator. */
public void testGenericWizards() {
    // open new project wizard
    NewProjectWizardOperator npwo = NewProjectWizardOperator.invoke();
    npwo.selectCategory("Java Web");
    npwo.selectProject("Web Application");
    npwo.next();
    // create operator for next page
    WizardOperator wo = new WizardOperator("Web Application");
    JTextFieldOperator txtName = new JTextFieldOperator((JTextField) new JLabelOperator(wo, "Project Name:").getLabelFor());
    txtName.clearText();
    txtName.typeText("MyApp");
    wo.cancel();
}
 
Example 13
Source File: CodeTemplatesOperator.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public CodeTemplatesOperator addNewTemplate(String abbrev) {
    getNewBt().pushNoBlock();        
    new EventTool().waitNoEvent(250);
    JDialogOperator newDialog = new JDialogOperator("New Code Template");        
    JTextFieldOperator textField = new JTextFieldOperator(newDialog);
    textField.typeText(abbrev);
    new EventTool().waitNoEvent(250);
    JButtonOperator jbo = new JButtonOperator(newDialog, "OK");
    jbo.pushNoBlock();
    new EventTool().waitNoEvent(500);
    return this;
}
 
Example 14
Source File: TestUtils.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public static void createJavaFX2File(String fileType, String projectName, String fileName) {
    NewFileWizardOperator nfwo = newJavaFX2FileTemplateSelection(fileType, projectName);

    JTextFieldOperator fileNameField = new JTextFieldOperator(nfwo, 0);
    fileNameField.clearText();
    fileNameField.typeText(fileName);

    nfwo.finish();

    new EventTool().waitNoEvent(2000);        
}
 
Example 15
Source File: OptionPaneDemoTest.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public void showComponentDialog(JFrameOperator jfo) throws Exception {
    // Case: Cancel
    callADialogAndClose(jfo, COMPONENT_BUTTON, COMPONENT_TITLE, COMPONENT_OP5);
    //TODO: wait for no dialog displayed

    // Case: Yes option selected
    {
        callADialogAndClose(jfo, COMPONENT_BUTTON, COMPONENT_TITLE, COMPONENT_OP1);
        checkMessage(COMPONENT_R1);
    }

    // Case: No option selected
    {
        callADialogAndClose(jfo, COMPONENT_BUTTON, COMPONENT_TITLE, COMPONENT_OP2);
        checkMessage(COMPONENT_R2);
    }

    // Case: Maybe option selected
    {
        callADialogAndClose(jfo, COMPONENT_BUTTON, COMPONENT_TITLE, COMPONENT_OP3);
        checkMessage(COMPONENT_R3);
    }

    // Case: Probably option selected
    {
        callADialogAndClose(jfo, COMPONENT_BUTTON, COMPONENT_TITLE, COMPONENT_OP4);
        checkMessage(COMPONENT_R4);
    }

    // Case TextField and ComboBox functional
    {
        new JButtonOperator(jfo, COMPONENT_BUTTON).push();

        JDialogOperator jdo = new JDialogOperator(COMPONENT_TITLE);

        JTextFieldOperator jto = new JTextFieldOperator(jdo);
        jto.clearText();
        jto.typeText(TEXT_TO_TYPE);
        jto.waitText(TEXT_TO_TYPE);

        JComboBoxOperator jcbo = new JComboBoxOperator(jdo);
        jcbo.selectItem(2);
        jcbo.waitItemSelected(2);

        new JButtonOperator(jdo, COMPONENT_OP5).push();
        jdo.waitClosed();
        //TODO: wait for no dialog displayed
    }
}
 
Example 16
Source File: WebProjectValidation.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/** Test new servlet wizard.
 * - open New File wizard from main menu (File|New File)
 * - select sample project as target
 * - select Web|Servlet file type
 * - in the next panel type name
 * - finish the wizard
 * - check file is open in editor and close it
 */
public void testNewServlet() throws IOException {
    // create a new package
    new ActionNoBlock("File|New File", null).perform();
    NewFileWizardOperator newFileWizard = new NewFileWizardOperator("New File");
    newFileWizard.selectProject(PROJECT_NAME);
    newFileWizard.selectCategory("Web");
    newFileWizard.selectFileType("Servlet");
    newFileWizard.next();
    JTextFieldOperator txtPackageName = new JTextFieldOperator(newFileWizard);
    // clear text field
    txtPackageName.setText("");
    txtPackageName.typeText("Servlet1");
    JComboBoxOperator txtPackage = new JComboBoxOperator(newFileWizard, 1);
    // clear text field
    txtPackage.clearText();
    txtPackage.typeText("test1");
    newFileWizard.next();
    new EventTool().waitNoEvent(300);
    if (JCheckBoxOperator.findJCheckBox((Container) newFileWizard.getSource(), "", false, false) != null) {
        // Add information to deployment descriptor (web.xml)
        new JCheckBoxOperator(newFileWizard).setSelected(true);
    }
    newFileWizard.finish();
    // check class is opened in Editor and close it
    new EditorOperator("Servlet1.java").close();
    // check the servlet is specified in web.xml
    if (J2EE_4.equals(getEEVersion()) && !PROJECT_NAME.equals("WebModuleNB36")) {
        WebPagesNode webPages = new WebPagesNode(PROJECT_NAME);
        webPages.setComparator(new Operator.DefaultStringComparator(true, true));
        Node webXml = new Node(webPages, "WEB-INF|web.xml");
        new EditAction().performPopup(webXml);
        String xmlText = new EditorOperator("web.xml").getText();
        new EditorOperator("web.xml").closeAllDocuments();
        String[] content = new String[]{
            "<servlet-name>Servlet1</servlet-name>",
            "<servlet-class>test1.Servlet1</servlet-class>",
            "<url-pattern>/Servlet1</url-pattern>"
        };
        for (int i = 0; i < content.length; i++) {
            assertTrue("Servlet is not correctly specifeid in web.xml."
                    + " Following line is missing in the web.xml:\n" + content[i],
                    xmlText.indexOf(content[i]) != -1);
        }
    }
}
 
Example 17
Source File: ManageInspectionsOperatot.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public void pushText(String s) {
    JTextFieldOperator field = new JTextFieldOperator(this);
    field.typeText(s);
}
 
Example 18
Source File: RefactoringRename.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public ComponentOperator open(){
        String rename_to, rename_from = rename;
        
        // jEdit project
        log("Opening project jEdit");
        ProjectsTabOperator.invoke();
        CommonUtilities.waitProjectOpenedScanFinished(System.getProperty("xtest.tmpdir")+ java.io.File.separator +"jEdit41");
        CommonUtilities.waitForPendingBackgroundTasks();
        
        // find existing node
        Node packagenode = new Node(new SourcePackagesNode("jEdit"), "org.gjt.sp.jedit");
        String[] children = packagenode.getChildren();
        for(int i=0; i<children.length; i++) {
            if(children[i].startsWith(rename)){
                rename_from = children[i];
                break;
            }
        }
        
        log(" Trying to rename file "+rename_from);
        
        //generate name for new node
/*        String number = "1";
        if(rename_from.equalsIgnoreCase(rename+".java")) {
            rename_to = rename + number;
        } else {
            number = rename_from.substring(rename.length(),rename_from.indexOf('.'));
            rename_to = rename + (Integer.parseInt(number) + 1);
        }
*/
	rename_to=rename+CommonUtilities.getTimeIndex();
        
        // invoke Rename
        Node filenode = new Node(packagenode, rename_from);
        filenode.callPopup().pushMenuNoBlock("Refactor|Rename..."); // NOI18N
        NbDialogOperator renamedialog = new NbDialogOperator("Rename "); // NOI18N
        JTextFieldOperator txtfNewName = new JTextFieldOperator(renamedialog);
        JButtonOperator btnRefactor = new JButtonOperator(renamedialog,"Refactor"); // NOI18N
        
        // if the project exists, try to generate new name
        rename_to = rename_to+"1";
        log("    ... rename to  " + rename_to);
        txtfNewName.clearText();
        txtfNewName.typeText(rename_to);
        
        new JCheckBoxOperator(renamedialog,"Apply Rename on Comments").changeSelection(true); // NOI18N
        btnRefactor.push();
        
        MainWindowOperator.getDefault().waitStatusText("Save All finished"); // NOI18N
        
        rename_to = rename_from;
	return null;
    }
 
Example 19
Source File: CreateNewIndexedProperty.java    From netbeans with Apache License 2.0 3 votes vote down vote up
/** testName method */
public void testName() {
    RepositoryTabOperator explorerOperator = new RepositoryTabOperator();
    
    Node repositoryRootNode = explorerOperator.getRootNode();
    Node patternsNode = new Node(repositoryRootNode, sampleDir+"|"+NAME_TEST_FILE+"|"+"class "+NAME_TEST_FILE+"|"+Bundle.getString("org.netbeans.modules.beans.Bundle", "Patterns"));
    patternsNode.select();
    patternsNode.performPopupActionNoBlock(Bundle.getString("org.openide.src.nodes.Bundle", "LAB_Add")+"|"+Bundle.getString("org.netbeans.modules.beans.Bundle", "MENU_CREATE_IDXPROPERTY"));
    String dialogTitle = Bundle.getString("org.netbeans.modules.beans.Bundle", "CTL_TITLE_NewIdxProperty");
    NbDialogOperator nbDialogOperator = new NbDialogOperator(dialogTitle);
    JTextFieldOperator jTextFieldOperator = new JTextFieldOperator(nbDialogOperator, 0);

   
    jTextFieldOperator.typeText(NAME_WRONG);        
    
    JComboBoxOperator jComboBoxOperator = new JComboBoxOperator(nbDialogOperator, 0);
    jComboBoxOperator.setSelectedItem("String");
    
    nbDialogOperator.ok();

    new EventTool().waitNoEvent(3000);

    new NbDialogOperator("Error").ok();
                          
    jTextFieldOperator.clearText();
    jTextFieldOperator.typeText(NAME_INDEX_PROPERTY);
    
    jComboBoxOperator.setSelectedItem("String");
                   
    nbDialogOperator.ok();

    new JavaNode(repositoryRootNode, sampleDir + "|" + NAME_TEST_FILE).open();

    EditorOperator eo = new EditorOperator(NAME_TEST_FILE);
    ref(eo.getText());
    compareReferenceFiles();               
}