简体   繁体   中英

set proxy for firefox using sikuli in java

I'm new to sikuli and I want to run firefox and set proxy on it (through foxyproxy) using sikuli. This code opens firefox and load " https://google.com ". How would I click on foxyproxy button in firefox toolbar and create new proxy using 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();
    }

}

Thanks,

Sikuli works based on visual pattern matching. In order to do what you need, you have to:

  1. take a screenshot with the area of the screen you want to interact with (in your case the FoxyProxy icon in FF)
  2. Define an object of type Pattern
  3. Used the object defined in step to to find the pattern on the screen
Pattern pattern = new Pattern("screenshot.png");
Match m = s.find(pattern);
m.click();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM