【问题标题】:How to write java program in Sikuli?如何在Sikuli编写java程序?
【发布时间】:2011-07-25 07:31:19
【问题描述】:

我使用SIKULI录制了GUI桌面应用程序如下:

App.open ("C:\\Program Files\\acd\\bin\\VPNClient.exe")
sleep(1)

type ("mganda1")
sleep(1)
click( ) //click OK

我想将此脚本转换为 Java。所以我尝试如下:

package com.arcot.test.vpn;
import org.sikuli.script.*;

  public class AuthLogin {
public static void main(String[] args) {
    Screen s = new Screen();

    App myApp = new App("application-identifier") ;

    myApp.open ("C:\\Program Files\\acd\\bin\\VPNClient.exe");

//这里如何模拟type、sleep和click函数?

我正在搜索 java 示例以了解对象关系以及如何使用它来模拟录制的脚本。如果有人知道对我有帮助的链接,请提供。

最好的问候, 马杜

【问题讨论】:

    标签: java user-interface automation sikuli


    【解决方案1】:

    马杜,

    我不确定你为什么要录制脚本来与 sikuli 共进午餐。 yu 使用的所有命令都不会调用任何图像,并且都可以在没有 sikuli ide 的情况下编写。

    我将对您原来的 sikuli/jython 脚本进行以下更改

    App.open ("C:\\Program Files\\acd\\bin\\VPNClient.exe")
    
    sleep(1)
    
    //change to  
    wait(path to image, FOREVER)
    //By changing to a wait there is an implicit find as defined by the path to the image
    
    type ("mganda1")
    //if there are issues verifying focus invoke type with the img option
    
    sleep(1)
    //use wait instead of sleep
    click( ) //click OK
    //What are you clicking on?
    

    Regarding Java, here's the link to Sikuli javadocs

    【讨论】:

      【解决方案2】:

      在你的程序之后,按照以下方式进行:

      package com.arcot.test.vpn;
      import org.sikuli.script.*;
      
        public class AuthLogin {
      public static void main(String[] args) {
          Screen s = new Screen();
      
      App myApp = new App("application-identifier") ;    
      
      myApp.open ("C:\\Program Files\\acd\\bin\\VPNClient.exe");
      

      请以这种方式进行, - 在你的包“img”中创建一个图像文件夹 - 复制 img 文件夹中的所有相应图像 - 将文件夹中的图像名称分配给不同的变量

      要进行操作,请使用以下命令:

      s.type("mganda1");   
      s.sleep(time);    
      s.click("ok.png"); 
      

      问候, 恩佩西克

      【讨论】:

        猜你喜欢
        • 2017-09-23
        • 1970-01-01
        • 2015-08-10
        • 2010-09-08
        • 2019-09-18
        • 2010-10-19
        • 2012-07-23
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多