How to perform Basic Authentication for FirefoxDriver, ChromeDriver and IEdriver in Selenium WebDriver?

前端 未结 7 1156
一个人的身影
一个人的身影 2020-11-27 16:46

I am using the Selenium-Firefox-driver and Selenium-Chrome-Driver version 2.0a5 (Web Driver API), and I am trying to test a web app that h

7条回答
  •  情歌与酒
    2020-11-27 16:56

    Add this New Firefox Profile on your code

    ProfilesIni profile = new ProfilesIni();
    FirefoxProfile myprofile = profile.getProfile("myProjectProfile"); //replace "myProjectProfile" with your profile"
    WebDriver driver = new FirefoxDriver(myprofile);
    

    Firefox configuration settings

    This works fine without prompting any authentication when you do the following settings..

    • Type "about:config" on your FF url
    • Now type "Proxy" in the search field
    • Make sure "signon.autologin.proxy" is set "true" (By default it is "false")

    Load Default/Custom Chrome Profile to run tests using Selenium WebDriver


    1. Download chromedriver.exe
    2. Extract the chromedriver_win_26.0.1383.0.zip folder and locate .exe file to C:/ folder

    Add this Script on your JAVA code

    DesiredCapabilities capability = DesiredCapabilities.chrome();
    System.setProperty("webdriver.chrome.driver", "C:/chromedriver.exe");
    capability.setCapability("chrome.switches", Arrays.asList("–disable-extensions"));
    capability.setCapability("chrome.binary", "C:/Users/user_name/AppData/Local/Google/Chrome/Application/chrome.exe");
    ChromeOptions options = new ChromeOptions();
    options.addArguments("user-data-dir=C:/Users/user_name/AppData/Local/Google/Chrome/User Data/Default");
    driver = new ChromeDriver(capability);
    

    Note: IE doesn't need profile setup to run tests because they run on Server user while Firefox and Chrome works with binary.

提交回复
热议问题