How to set Proxy Authentication in seleniumWebdriver for Chrome Browser

后端 未结 5 524
忘了有多久
忘了有多久 2021-01-05 17:58

I\'m trying to Automate a web application selenium 2.0 [webdriver+java].The web application is currently deployed in our UAT servers on our local network.My test cases are e

5条回答
  •  花落未央
    2021-01-05 18:31

        public class DriverClass {
    
        private String baseUrl;
        private String driverPath;
        private String driverName;
        private static WebDriver driver;
        private static DriverClass driverClass;
    
        public DriverClass() {
            try {
                baseUrl = "http://192.168.0.10:8282/ess";
                driverPath = "E:\\Work_Folder\\SelTools\\chromedriver.exe";
                driverName = "webdriver.chrome.driver";
                System.setProperty(driverName, driverPath);
    
                Proxy proxy = new org.openqa.selenium.Proxy();
                proxy.setSslProxy("192.168.0.200" + ":" + 3128);
                proxy.setFtpProxy("192.168.0.200" + ":" + 3128);
                proxy.setSocksUsername("avishka");
                proxy.setSocksPassword("12345678");
    
                DesiredCapabilities desiredCapabilities = DesiredCapabilities.chrome();
                desiredCapabilities.setCapability(CapabilityType.PROXY, proxy);
    
    
                driver = new ChromeDriver(desiredCapabilities);
    
    
                driver.get(baseUrl);
    
    
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
    

    The proxy setting has been added with desired capabilities to pass values to proxy authentication,worked finally

提交回复
热议问题