【问题标题】:Sikuli integration with selenium error for wait conditionSikuli 与 selenium 集成错误等待条件
【发布时间】:2019-04-03 14:28:32
【问题描述】:

enter image description here

screen.wait(用户名, 10);

我在org.sikuli.script.Region.wait 处收到一条错误消息,我如何在 命令提示符 中运行与 selenium 项目 的 Sikuli 集成,即使我添加了所需的 Sikuli jar -在命令提示符下运行时,我得到了 Sikuli 包丢失。

Screen screen = new Screen();
Pattern fileUpload = new Pattern("a.PNG");
Pattern fileSelect = new Pattern("b.PNG");
Pattern AWBSelect = new Pattern("c.PNG");
Pattern AWBupload = new Pattern("d.PNG");
Pattern AWBSearch = new Pattern("e.PNG");

screen.wait(fileUpload, 10);
screen.click(fileUpload);
screen.wait(fileSelect, 10);
screen.click(fileSelect);
screen.type("a", KeyModifier.CTRL);
screen.type(Key.BACKSPACE,"C:\\Users\\PoojaPatange\\eclipse-workspacepractice\\CIToolAutomationRegression\\lib");
screen.type(Key.ENTER);
screen.wait(AWBSelect, 10);
screen.click(AWBSelect);
screen.wait(AWBupload, 10); 
screen.click(AWBupload);
screen.wait(AWBSearch, 10); 
screen.click(AWBSearch); 

【问题讨论】:

  • 您是否在 org.sikuli.script.Region.wait 上方收到任何“FindFailed:找不到”错误。请发布您的完整 java 代码和错误堆栈跟踪。
  • 嗨@Dhru'soni,我已经添加了我的代码和屏幕截图,请检查,是的,我发现了失败的问题。
  • 这意味着无论您使用什么按钮搜索窗口,您的图像都与您的数据不完全匹配。重新检查并尝试使用准确的图像。
  • 如果解决方案有效,请投票并标记为答案。谢谢

标签: java selenium sikuli


【解决方案1】:

您需要使用图像的确切路径,如下面的代码。在这里我测试了谷歌页面搜索内容并点击谷歌搜索按钮。

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.sikuli.script.FindFailed;
import org.sikuli.script.Pattern;
import org.sikuli.script.Screen;

public class DemoWindowBasedApplication {


    public static void main(String[] args) throws FindFailed {

        Screen screen = new Screen();
        Pattern image = new Pattern("C:\\Users\\test\\Videos\\snspshot\\october\\12\\google.png");
        Pattern image1 = new Pattern("C:\\Users\\test\\Videos\\snspshot\\october\\12\\testGoogle.png");
        Pattern googleSearch = new Pattern("C:\\Users\\test\\Videos\\snspshot\\october\\12\\googleSearch.png");
        Pattern closeBrowser = new Pattern("C:\\Users\\test\\Videos\\snspshot\\october\\12\\close.png");

        WebDriver driver;
        System.setProperty("webdriver.gecko.driver",
                "D:\\Automation\\Drivers_Automation\\geckodriver\\geckodriver.exe");
        driver = new FirefoxDriver();
        driver.get("http://www.google.com");
        screen.click(image);
        screen.type(image1,"Software testing");
        screen.click(googleSearch);
        screen.click(closeBrowser);
        screen.wait(image, 10);

    }
}

我附上了示例图片,您如何在运行 sikuli 程序时拍摄快照并精确匹配

【讨论】:

  • screen.wait(10); java.lang.IllegalMonitorStateException 我遇到异常我可以使用上面的等待条件吗?
  • @PoojaPatange 获取Sikuli的wait()方法(签名wait(long value)(egswait(1)被JavaObject占用)使用这个screen.wait(double value)(eg screen.wait (10.0) )
  • 谢谢你的建议,你能帮我在命令提示符下运行上面的代码吗?我收到错误为 java.lang.NoClassDefFoundError: org/sikuli/script/Screen 和 java.lang.ClassNotFoundException: org.sikuli.script.Screen
猜你喜欢
  • 1970-01-01
  • 2013-10-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-01-02
  • 2011-10-24
  • 2023-04-03
  • 2017-08-09
相关资源
最近更新 更多