Trying to typed text in one image but it is typing in some different image.

Asked by Angel

I am using Sikuli 1.0.1

Same Sikuli version I am using in eclipse

Java version is 1.7.0_45

        [cid:image004.png@01CFB188.1DD8A680]

[cid:image005.jpg@01CFB188.1DD8A680]

I am trying to insert Qty as 1 in first row but sometimes it typed 1 in item box 1 st row or most of the time second row anywhere

PFB script which is in java
package com.intuit;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.sikuli.basics.SikuliScript;
import org.sikuli.script.App;
import org.sikuli.script.Button;
import org.sikuli.script.FindFailed;
import org.sikuli.script.Key;
import org.sikuli.script.KeyModifier;
import org.sikuli.script.Location;
import org.sikuli.script.Match;
import org.sikuli.script.Pattern;
import org.sikuli.script.Region;
import org.sikuli.script.Screen;
import org.sikuli.script.SikuliX;

import junit.framework.TestCase;

//SampleTestData_QBDTCA
public class SampleTestData_QBDTCA extends TestCase {

      private static final String x = null;

      private static final String y = null;

      //Sikuli script object
      private SikuliScript m_sikscr;

    //Computer screen object
    private Screen m_screen;
     Region reg;
      int Flag=0;
     // Map map;

    private Pattern m_dropdown;

    private Pattern m_companyname;

  private Pattern m_newTransaction;

  private Pattern e_Item;

  private Pattern e_Qty;

    //Constructor
    public SampleTestData_QBDTCA()
    {

      /////images///
      m_newTransaction = new Pattern("./img/NewTransaction.png");
      e_Item = new Pattern("./img/ItemN.png");
      e_Qty = new Pattern("./img/e_Qty.png");

        //Create Sikuli script and screen objects
        try
        {
            m_sikscr = new SikuliScript();
            m_screen = new Screen();

        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
    }

    //This method is invoked before JUnite test case executes
    @ Before
    public void setUp()
    {

    // App.open("D:\\Build_26_05_2014\\28-07-2014_SVN_3133\\QBOImportUtility_AWS.exe");

        //Wait a bit
       m_screen.wait((double) 3.0);

        try
        {
          /*****************Create a customer******************/
            m_screen.click("./img/QBDTCA_icon.png", 0); // click on next //
            m_screen.click("./img/Customers.png", 0); // click on next //NewCustandjob
            m_screen.click("./img/NewCustandjob.png", 0); // click on next //NewCustandjob
            m_screen.type("N");
            m_screen.type("Customer1");//CustOK
            m_screen.click("./img/CustOK.png", 0); // click on next //NewCustandjob*/

            /*****************Create a Supplier******************/
            m_screen.click("./img/Vendor.png", 0); // click on next //NewCustandjob
            m_screen.click("./img/NewVendor.png", 0); // click on next //NewCustandjob
            m_screen.type("N");
            m_screen.type("Vendor1");//CustOK
            m_screen.click("./img/CustOK.png", 0); // click on next //NewCustandjob

            /*****************Create a inventory item******************/
          /* m_screen.click("./img/Home.png", 0); // click on next //NewCustandjob
            m_screen.click("./img/Item&Serv.png", 0); // click on next //Item

            m_screen.click("./img/Item.png", 0); // click on next //Item
            m_screen.type("N");

            m_screen.click("./img/idropdown.png", 0); // click on next //NewCustandjob
             /* m_screen.wait((double) 3.0);
            m_screen.click("./img/idropdown.png", 0); // click on next //NewCustandjob
            m_screen.wait((double) 3.0);
            m_screen.click("./img/inv.png", 0); // click on next //NewCustandjob
            // m_screen.type("Inventory Part"+Key.ENTER);//inv
            m_screen.wait((double) 3.0); //ItemName
            m_screen.click("./img/ItemName.png", 0); // click on next //NewCustandjob
            m_screen.type("Item1");

            if(m_screen.find("./img/SerRate.png") != null){
                  m_screen.click("./img/Vrate.png", 0); // click on next //NewCustandjob
                  m_screen.type("10");
            }

            if(m_screen.find("./img/Account.png") != null){
                  m_screen.click("./img/VAccount.png", 0); // click on next //NewCustandjob
                  m_screen.type("Owners Draw");
            }

            m_screen.click("./img/CustOK.png", 0); // click on next //NewCustandjob

            m_screen.click("./img/Iclose.png", 0); // click on next //NewCustandjob //NewTransaction

            */

              /****************************************Transaction*****************************************/
            m_screen.click("./img/Customers.png", 0); // click on next //NewCustandjob
            //int i = 0;
            //for(i=0; i<=3; i++){
                  m_screen.click("./img/NewTransaction.png", 0); // click on next //NewCustandjob
                  m_screen.type("E");//
                  m_screen.wait((double) 3.0); //ItemName
                  /*if(m_screen.find("./img/ItemN.png") != null){
                        System.out.println("1");
                        m_screen.click("./img/ItemN.png", 0); // click on next //NewCustandjob
                        m_screen.type("Item1");//
                        System.out.println("2");
                        m_screen.click("./img/Idd.png", 0);

                  }
                  m_screen.wait((double) 3.0); //ItemName
                  if(m_screen.find("./img/Qty.png") != null){
                        System.out.println("3");
                        m_screen.click("./img/VQty.png", 0); // click on next //NewCustandjob
                        m_screen.type("1");//Save&Close
                        System.out.println("4");
                  }
                  m_screen.wait((double) 3.0); //ItemName

                  m_screen.click("./img/Save&Close.png", 0); // click on next //NewCustandjob //NewTransaction*/
                  System.out.println("1");
                  m_screen.type(e_Item, "Item1");
                  m_screen.click("./img/Idd.png", 0);
                  System.out.println("2");
                  m_screen.type(e_Qty, "1");

            System.out.println("3");
            //}

        }
        catch (FindFailed e)
        {
            e.printStackTrace();
        }
    }

    private Pattern Pattern(String string) {
            // TODO Auto-generated method stub
            return null;
      }

      //This method is invoked after JUnit test case is executed
    @ After
    public void tearDown()
    {
        //
      //App.close("ABC");
       //App.close(appName);
    }

    //Test case checks if Yahoo logo exists after login
    @Test
    public void testLogo() throws Exception
    {

        //Wait a bit
        m_screen.wait((double) 3.0);
    }

}

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Angel (sapna-kalokar) said :
#1

Hi Raiman,
atleast give some hints so i can proceed
I am waiting for your answer.

Revision history for this message
RaiMan (raimund-hocke) said :
#2

sorry, had a short break ;-)

--- filenames with a dot:
though it seems to work as image filenames, it might lead to strange behavior, since SikuliX still contains much "old" code.
So I recommend to not use dots in filenames.

in your case it is simply not necessary, since ./images/some.png is the same as images/some.png

--- if I understand you right:
before the type() is used, you are trying to give focus to a specific input field by clicking on some image.

If yes: your image is not unique enough, so there exist other possible matches on the screen.

Best practices:
- captured images should have as little as possible surrounding background
- use Pattern().similar() to raise the threshold for the needed similarity score
- restrict the region, where you expect the target image to appear and use region.function() instead of screen.function()

when programming in Java it is helpful, to have the SikuliIDE in parallel, to capture images and test them with the IDE's preview feature (until SikuliX ImageSupport is available as standalone feature).

Can you help with this problem?

Provide an answer of your own, or ask Angel for more information if necessary.

To post a message you must log in.