How to get Firefox working with Selenium WebDriver on Mac OSX

前端 未结 8 1608
慢半拍i
慢半拍i 2020-12-14 03:12

I am trying to config proxy settings for the WebDriver so I have used the following code ....

FirefoxProfile profile = new FirefoxProfile();
pro         


        
8条回答
  •  执笔经年
    2020-12-14 03:49

    For Mac:

    1. Use selenium jar 2.44.0 (make sure selenium server jar is 2.44.0)
    2. firefox version 33 (https://ftp.mozilla.org/pub/mozilla.org/firefox/releases/33.0/mac/en-US/)
    3. In terminal of Mac, Use this command to create profile for firefox : "/Applications/Firefox.app/Contents/MacOS/firefox-bin" -p

      1. while creating the profile, you would see the path of profile with .default, - make note of this for entering the same in code for profile path.

      2. Code would look like this:

    String profilePath="/Users/admin/Library/ApplicationSupport/Firefox/Profiles/4duhjf19.default";

                    System.out.println("profilePath: "+profilePath);
                    File checkProfile = new File(profilePath);
                    File[] allFolder = checkProfile.listFiles();
                    for (int i = 0; i < allFolder.length; i++) {
    
                        if (allFolder[i].getName().endsWith(".default")) {
                            profilePath = profilePath + allFolder[i].getName();
                            break;
                        }
                    }
    FirefoxProfile firefoxprofile1 = new FirefoxProfile(new File(
                            profilePath));
                    System.out.println("profile path : " + firefoxprofile1);
                    driver = new FirefoxDriver(firefoxprofile1);
                    System.out.println("webdriver FF");
                    driver.manage().deleteAllCookies();
    

提交回复
热议问题