0

我是sikuli的新手,我想运行 firefox 并使用 sikuli 在其上设置代理(通过 foxyproxy)。此代码打开 Firefox 并加载“ https://google.com ”。如何单击 Firefox 工具栏中的 foxyproxy 按钮并使用 sikuli 创建新代理?

import org.sikuli.script.*;


public class SikulixTest {

    public static void main(String[] args) {

        Screen s = new Screen();
        App browser = App.open("Firefox");
        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {

            e.printStackTrace();
        }
        browser.focus();
        s.highlight(0);
        s.type("https://google.com" + Key.ENTER);
        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {

            e.printStackTrace();
        }

        browser.close();
    }

}

谢谢,

4

1 回答 1

1

Sikuli 的工作基于视觉模式匹配。为了做你需要的,你必须:

  1. 用您要与之交互的屏幕区域截取屏幕截图(在您的情况下,FF 中的 FoxyProxy 图标)
  2. 定义一个类型的对象Pattern
  3. 使用步骤中定义的对象在屏幕上查找图案
Pattern pattern = new Pattern("screenshot.png");
Match m = s.find(pattern);
m.click();
于 2018-12-10T14:48:50.393 回答