How to use equals method of org.openqa.selenium.Proxy class

Best Selenium code snippet using org.openqa.selenium.Proxy.equals

Source:WebDriverDiscovery.java Github

copy

Full Screen

...67 for (String configType : commandLineArgumentsList) {68 if (configType.contains("=")) {69 String configKey = configType.substring(0, configType.lastIndexOf("="));70 String configValue = configType.substring(configType.indexOf("=") + 1);71 if (configKey.equalsIgnoreCase("driverName")) {72 driverTypePath = getDriverTypePath(configValue);73 } else if (configKey.equalsIgnoreCase("OS")) {74 operatingSystem = configValue;75 } else if (configKey.equalsIgnoreCase("OS_Version")) {76 os_Version = configValue;77 } else if (configKey.equalsIgnoreCase("browserName")) {78 browserName = configValue;79 } else if (configKey.equalsIgnoreCase("browserVersion")) {80 browserVersion = configValue;81 }82 }83 }84 } else {85 driverTypePath = getDriverTypePath(driverType);86// operatingSystem = "BrowserStackDriver.OS";87// os_Version = "BrowserStackDriver.OS_Version";88// browserName = "BrowserStackDriver.browserName";89// browserVersion = "BrowserStackDriver.browserVersion";90 }91 }92 private String getDriverTypePath(String browserDriver) { 93 String driverTypePath = null;94// if (browserDriver.equalsIgnoreCase("BrowserStackDriver")) {95// driverTypePath = "steve.framework.BrowserStackDriver";96 if (browserDriver.equalsIgnoreCase("FirefoxDriver")) {97 driverTypePath = "org.openqa.selenium.firefox.FirefoxDriver";98 } else if (browserDriver.equalsIgnoreCase("ChromeDriver")) {99 driverTypePath = "org.openqa.selenium.chrome.ChromeDriver";100 } else if (browserDriver.equalsIgnoreCase("HtmlUnitDriver")) {101 driverTypePath = "org.openqa.selenium.htmlunit.HtmlUnitDriver";102 } else if (browserDriver.equalsIgnoreCase("InternetExplorerDriver")) {103 driverTypePath = "org.openqa.selenium.ie.InternetExplorerDriver";104 } else if (browserDriver.equalsIgnoreCase("SafariDriver")) {105 driverTypePath = "org.openqa.selenium.safari.SafariDriver";106 } else if (browserDriver.equalsIgnoreCase("PhantomJSDriver")) {107 driverTypePath = "org.openqa.selenium.phantomjs.PhantomJSDriver";108 }109 return driverTypePath;110 }111// @PostConstruct112 public void init() {113 try {114 initializeDriver();115 } catch (WebDriverException e) {116 LOG.error("Error upon initializing a driver:" + e.getMessage());117 e.printStackTrace();118 LOG.warn("Trying to open browser again...");119 initializeDriver();120 }...

Full Screen

Full Screen

Source:WebDriverUtil.java Github

copy

Full Screen

...50 @SuppressWarnings("unused")51 public static WebDriver createPhantomjsWebDriver(String path)52 throws Exception {53 DesiredCapabilities capabilities = DesiredCapabilities.phantomjs();54 if (path == null || "".equals(path)) {55 throw new Exception("配置错误,没有配置:phantomjs.binary.path");56 }57 capabilities.setCapability("phantomjs.binary.path", path);58 capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);59 capabilities.setJavascriptEnabled(true);60 capabilities.setCapability("takesScreenshot", true);61 capabilities62 .setBrowserName("Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3679.0 Safari/537.36");63 capabilities.setPlatform(Platform.WIN10);64 WebDriver webDriver = null;65 try {66 webDriver = new PhantomJSDriver(capabilities);67 } catch (RuntimeException e) {68 throw new Exception("创建webdriver失败");69 }70 if (webDriver == null) {71 throw new Exception("创建webdriver失败");72 }73 webDriver.manage().timeouts().pageLoadTimeout(5000, TimeUnit.SECONDS);74 webDriver.manage().window().setSize(new Dimension(1920, 1080));75 return webDriver;76 }7778 /**79 * 创建Chrome80 * 81 * @throws Exception82 */8384 public static int locationNum = 0;8586 public static WebDriver createChromeWebDriver(String path,87 boolean isUseProxy,boolean isUseImage) throws Exception {88 if (path == null || "".equals(path)) {89 throw new Exception("配置错误,没有配置:chrome path");90 }91 service = new ChromeDriverService.Builder()92 .usingDriverExecutable(new File(path)).usingAnyFreePort()93 .build();94 try {95 service.start();96 } catch (Exception e) {97 e.printStackTrace();98 }99 DesiredCapabilities cap = new DesiredCapabilities();100 if (SystemConfigParas.is_setting_proxy.equals("true")101 && isUseProxy == true) {102 if (TaskScheduleManager.isNull4ProxyIpPoolList()103 || TaskScheduleManager.getProxyIpPoolListSize() == SystemConfigParas.proxy_ip_pool104 .size()) {105 locationNum = 0;106 TaskScheduleManager.cleanProxyIpPoolList();107 }108 String proxy = SystemConfigParas.proxy_ip_pool.get(locationNum);109 logger.info("正在切换代理ip:" + proxy);110 setProxy(cap, proxy);111 TaskScheduleManager.addProxyIpPoolList(proxy);112 locationNum++;113 }114 setLog(cap);115 ChromeOptions options = new ChromeOptions();116 setOptionsArguments(SystemConfigParas.options_arguments, options);117 if(isUseImage){118 options.setExperimentalOption("prefs", prefs);119 }120 cap.setCapability(ChromeOptions.CAPABILITY, options);121122 System.getProperties().setProperty("webdriver.chrome.driver", path);123 WebDriver webDriver = new ChromeDriver(cap);124 webDriver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);125 webDriver.manage().timeouts().pageLoadTimeout(1200, TimeUnit.SECONDS);126 webDriver.manage().window().setSize(new Dimension(1920, 1080));127 128 return webDriver;129 }130131 public static String getPagStatus(WebDriver webDriver) {132 String currentURL = webDriver.getCurrentUrl();133 LogEntries logs = webDriver.manage().logs().get("performance");134 int status = -1;135 for (Iterator<LogEntry> it = logs.iterator(); it.hasNext();) {136 LogEntry entry = it.next();137 try {138 JSONObject json = JSON.parseObject(entry.getMessage());139 JSONObject message = json.getJSONObject("message");140 String method = message.getString("method");141 if (method != null && "Network.responseReceived".equals(method)) {142 JSONObject params = message.getJSONObject("params");143 JSONObject response = params.getJSONObject("response");144 String messageUrl = response.getString("url");145 if (currentURL.equals(messageUrl)) {146 status = response.getInteger("status");147 }148 }149 } catch (JSONException e) {150 e.printStackTrace();151 }152 }153 return String.valueOf(status);154 }155156 /**157 * 创建Firefox158 */159 public static WebDriver createFirefoxWebDriver(String path)160 throws Exception {161 if (path == null || "".equals(path)) {162 throw new Exception("配置错误, 没有配置 gecko path");163 }164 System.setProperty("webdriver.gecko.driver", path);165 WebDriver webDriver = new FirefoxDriver();166 return webDriver;167 }168169 /**170 * 创建chromedriver实例171 */172 public static WebDriver createWebDriver(boolean isUseProxy,boolean isUseImage) {173 WebDriver webDriver = null;174 try {175 webDriver = WebDriverUtil.createChromeWebDriver( ...

Full Screen

Full Screen

Source:WebDriverManager.java Github

copy

Full Screen

...63driver = new ChromeDriver(options);64 */65 DesiredCapabilities chromeCapabilities = DesiredCapabilities.chrome();66 String chromeBinary = System.getProperty(" ");67 if (name.equalsIgnoreCase("chrome"))68 {69 if (chromeBinary == null || chromeBinary.equals("")) {70 String os = System.getProperty("os.name").toLowerCase().substring(0, 3);71 chromeBinary = "lib/chromedriver-" + os + (os.equals("win") ? ".exe" : "");72 System.setProperty("webdriver.chrome.driver", chromeBinary);73 74 75 ChromeOptions options = new ChromeOptions();76 //options.addExtensions(new File("/path/to/extension.crx"));77 // /Users/igonzalez/Desktop/ChromeProfile/Profile 178 //options.addArguments("user-data-dir=/Users/igonzalez/Desktop/ChromeProfile/Profile 1");79 options.addArguments("user-data-dir=/Users/igonzalez/Library/Application Support/Google/Chrome/ChromeDriver");80 options.addArguments("--start-maximized");81 chromeCapabilities.setCapability(ChromeOptions.CAPABILITY, options);82 }83 }84 driver =new ChromeDriver(chromeCapabilities);85 defaultWindowSize(driver);86 return driver;87 }88 89 90 public static void stopDriver()91 {92 driver.quit();93 }94 public static WebDriver getDriverInstance()95 {96 //in progress97 return driver;98 }99 public static void defaultWindowSize(WebDriver driver)100 {101 //diver.manage().window().maximize(); //this would work only for Firefox and IE102 driver.manage().window().setPosition(new Point(0,0));103 java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();104 Dimension dim = new Dimension((int) screenSize.getWidth(), (int) screenSize.getHeight());105 driver.manage().window().setSize(dim);106 Reporter.log("Currently testing URL: " +driver.getCurrentUrl());107 }108 public static void getBrowser(WebDriver driver)109 {110 if (driver instanceof FirefoxDriver) {111 System.out.println("Firefox DRIVER");112 Reporter.log("Using Firefox browser version 24");113 } 114 else if (driver instanceof ChromeDriver) {115 System.out.println("Chrome DRIVER");116 Reporter.log("Using Chrome version 30 browser");117 }118 else if (driver instanceof SafariDriver) {119 System.out.println("Safari DRIVER");120 Reporter.log("Using Safari 6 browser");121 }122 }123 public static void setup(String platform, String browser, String version,124 String url) throws MalformedURLException, InterruptedException, UnknownHostException 125 {126 DesiredCapabilities caps = new DesiredCapabilities();127 // Platforms128 if (platform.equalsIgnoreCase("WINDOWS"))129 caps.setPlatform(org.openqa.selenium.Platform.WINDOWS);130 System.out.println(org.openqa.selenium.Platform.WINDOWS);131 if (platform.equalsIgnoreCase("MAC"))132 caps.setPlatform(org.openqa.selenium.Platform.MAC);133 System.out.println(org.openqa.selenium.Platform.MAC);134 // Browsers135 if (browser.equalsIgnoreCase("Internet Explorer"))136 caps = DesiredCapabilities.internetExplorer();137 if (browser.equalsIgnoreCase("Firefox"))138 caps = DesiredCapabilities.firefox();139 if (browser.equalsIgnoreCase("iPad"))140 caps = DesiredCapabilities.ipad();141 if (browser.equalsIgnoreCase("Android")) {142 caps = DesiredCapabilities.android();143 }144 }145 /* File file=new File("/Users/igonzalez/Desktop/SELENIUM_jar/chromedriver");146 //chrome driver version 2.8 need to replace path with relative so it works with jenkins147 //File file=new File("/Users/igonzalez/Desktop/SELENIUM_jar/chromedriver_v2_1");148 System.setProperty("webdriver.chrome.driver", file.getAbsolutePath());149 driver = new ChromeDriver();150 */151 public static void defaultSetUp()152 {153 dc = new DesiredCapabilities();154 // Platforms155 Platform platform = Platform.getCurrent();...

Full Screen

Full Screen

Source:CommonLib.java Github

copy

Full Screen

...73 74 //---------------------------------------------------------------------------------------------------75 public static int getBrowserId (String sBrowserName) throws Exception76 {77 if(sBrowserName.equalsIgnoreCase("ie")) 78 {79 return 1;80 };81 if(sBrowserName.equalsIgnoreCase("firefox")) return 2;82 if(sBrowserName.equalsIgnoreCase("chrome")) return 3;83 if(sBrowserName.equalsIgnoreCase("htmlunit")) return 4;84 85 return -1;86 }87 88 //---------------------------------------------------------------------------------------------------89 90 public static WebDriver getDriver( String sBrowserName) throws Exception91 {92 93 WebDriver oDriver=null;94 95 switch(getBrowserId (sBrowserName))96 {97 case 1: ...

Full Screen

Full Screen

Source:DriverType.java Github

copy

Full Screen

...31 System.out.println("Browser name : " +browserName);32 DesiredCapabilities capabilities = getDesiredCapabilities(browserName);33 System.out.println("Capabilities: " +capabilities);34 // Add proxy35 if (proxyEnabled.equalsIgnoreCase("y") || proxyEnabled.equalsIgnoreCase("yes")){36 String proxyDetails = proxyHost + ":" + proxyPort;37 System.out.println("Proxy is used as " + proxyDetails);38 Proxy proxy = new Proxy();39 proxy.setProxyType(MANUAL);40 proxy.setHttpProxy(proxyDetails);41 proxy.setSslProxy(proxyDetails);42 capabilities.setCapability(CapabilityType.PROXY, proxy);43 }44 45 if (useRemote.equalsIgnoreCase("y") || useRemote.equalsIgnoreCase("yes")) {46 URL seleniumGridURL = null;47 try {48 seleniumGridURL = new URL(GridURL);49 } catch (MalformedURLException e) {50 e.printStackTrace();51 }52 if (null != platform && !platform.isEmpty()) {53 capabilities.setPlatform(Platform.valueOf(platform.toUpperCase()));54 }55 if (null != browserVersion && !browserVersion.isEmpty()) {56 capabilities.setVersion(platform);57 }58 driver = new RemoteWebDriver(seleniumGridURL, capabilities);59 System.out.println("Remote driver is created on thread " + Thread.currentThread().getId());60 }61 else {62 driver = getLocalDriver(browserName, capabilities);63 System.out.println("Local driver is created on thread " + Thread.currentThread().getId());64 }65 return driver;66 }67 /**68 * If you want to add more Capabilities for browser modify this method69 * @param browser is browser name70 * @return WebDriver Capabilities for selected browser71 */72 private static DesiredCapabilities getDesiredCapabilities(String browser) {73 DesiredCapabilities capabilities;74 if (browser.equalsIgnoreCase("chrome")){75 capabilities = DesiredCapabilities.chrome();76 // Turn off default browser selection and remember password77 capabilities.setCapability("chrome.switches", Collections.singletonList("--no-default-browser-check"));78 HashMap<String, String> chromePreferences = new HashMap<>();79 chromePreferences.put("profile.password_manager_enabled", "false");80 capabilities.setCapability("chrome.prefs", chromePreferences);81 }82 else if (browser.equalsIgnoreCase("ie")) {83 capabilities = DesiredCapabilities.internetExplorer();84 capabilities.setCapability(CapabilityType.ForSeleniumServer.ENSURING_CLEAN_SESSION, true);85 capabilities.setCapability(InternetExplorerDriver.ENABLE_PERSISTENT_HOVERING, true);86 capabilities.setCapability("requireWindowFocus", true);87 capabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,true);88 }89 else if (browser.equalsIgnoreCase("safari")) {90 capabilities = DesiredCapabilities.safari();91 capabilities.setCapability("safari.cleanSession", true);92 }93 else if (browser.equalsIgnoreCase("firefox")){94 capabilities = DesiredCapabilities.firefox();95 }96 else {97 capabilities = DesiredCapabilities.firefox();98 }99 return capabilities;100 }101 102 /**103 * This method will return the correct local browser104 */105 private static WebDriver getLocalDriver(String browser, DesiredCapabilities capabilities) {106 WebDriver webDriver;107 if (browser.equalsIgnoreCase("chrome")){108 System.setProperty("webdriver.chrome.driver", System.getProperty("webdriver.chrome.driver"));109 ChromeOptions options = new ChromeOptions().merge(capabilities);110 webDriver = new ChromeDriver(options);111 }112 else if (browser.equalsIgnoreCase("ie")) {113 InternetExplorerOptions options = new InternetExplorerOptions().merge(capabilities);114 webDriver = new InternetExplorerDriver(options);115 }116 else if (browser.equalsIgnoreCase("safari")) {117 SafariOptions options = new SafariOptions().merge(capabilities);118 webDriver = new SafariDriver(options);119 }120 else {121 System.out.println(System.getProperty("webdriver.firefox.driver"));122 System.setProperty("webdriver.gecko.driver", System.getProperty("webdriver.gecko.driver"));123 FirefoxOptions options = new FirefoxOptions().merge(capabilities);124 webDriver = new FirefoxDriver(options);125 }126 return webDriver;127 }128}...

Full Screen

Full Screen

Source:DriverBuilder.java Github

copy

Full Screen

...34 public WebDriver build() throws Exception {35 // capabilities36 final DesiredCapabilities cap = this.getCapabilities();37 final String driver = _info.browser();38 if (DRIVER_CHROME.equalsIgnoreCase(driver)) {39 return null != cap ? new ChromeDriver(cap) : new ChromeDriver();40 } else if (DRIVER_FIREFOX.equalsIgnoreCase(driver)) {41 return null != cap ? new FirefoxDriver(new FirefoxOptions(cap)) : new FirefoxDriver();42 } else {43 return null != cap ? new FirefoxDriver(new FirefoxOptions(cap)) : new FirefoxDriver();44 }45 }46 // ------------------------------------------------------------------------47 // p r i v a t e48 // ------------------------------------------------------------------------49 private DesiredCapabilities getCapabilities() {50 final DesiredCapabilities cap = new DesiredCapabilities();51 // proxy52 final Proxy proxy = this.getProxy();53 if (null != proxy) {54 cap.setCapability(CapabilityType.PROXY, proxy);55 }56 return cap;57 }58 private Proxy getProxy() {59 Proxy response = null;60 final ModelPackage.Proxy pinfo = _info.proxy();61 if (pinfo.enabled()) {62 if (!StringUtils.hasText(pinfo.ip()) || pinfo.port() < 0) {63 // get random proxy (connection tested)64 final ModelProxy model = SeleniumManager.instance().proxies().getOneRndByProtocol(pinfo.protocol());65 pinfo.ip(model.ip());66 pinfo.port(model.port());67 }68 final String protocol = pinfo.protocol(); // http, ssl, socks4, socks569 final String proxy_text = pinfo.ip() + ":" + pinfo.port();70 final String driver = _info.browser();71 if (driver.equalsIgnoreCase(DRIVER_CHROME)72 || driver.equalsIgnoreCase(DRIVER_FIREFOX)73 || driver.equalsIgnoreCase(DRIVER_BASE)) {74 response = new Proxy();75 response.setProxyType(Proxy.ProxyType.MANUAL);76 if ("http".equalsIgnoreCase(protocol)) {77 response.setHttpProxy(proxy_text);78 } else if ("ssl".equalsIgnoreCase(protocol)) {79 response.setSslProxy(proxy_text);80 } else if ("socks4".equalsIgnoreCase(protocol)) {81 response.setSocksProxy(proxy_text);82 response.setSocksVersion(4);83 } else if ("socks5".equalsIgnoreCase(protocol)) {84 response.setSocksProxy(proxy_text);85 response.setSocksVersion(5);86 } else {87 response.setSocksProxy(proxy_text);88 response.setSocksVersion(5);89 }90 }91 }92 return response;93 }94 // ------------------------------------------------------------------------95 // S T A T I C96 // ------------------------------------------------------------------------97 public static WebDriver build(final ModelPackage info) throws Exception {...

Full Screen

Full Screen

Source:DriverFactory.java Github

copy

Full Screen

...18class DriverFactory19{20 private static final Logger logger = Logger.getLogger(DriverFactory.class);21 public static final WebDriver getDriver(SharedDriver.DriverType driverType) {22 if (driverType.equals(SharedDriver.DriverType.CHROME))23 return (WebDriver)getChromeDriver();24 if (driverType.equals(SharedDriver.DriverType.FIREFOX))25 return (WebDriver)getFirefoxDriver();26 if (driverType.equals(SharedDriver.DriverType.REMOTE)) {27 return getRemoteDriver();28 }29 return (WebDriver)getFirefoxDriver();30 }31 private static final ChromeDriver getChromeDriver() {32 String chromeDriverPath = "";33 if (TestConfiguration.getProperty("cct.run.os").equals("windows")) {34 chromeDriverPath = TestConfiguration.getProperty("cct.run.browser.windows.chromeDriverPath");35 } else if (TestConfiguration.getProperty("cct.run.os").equals("linux")) {36 chromeDriverPath = TestConfiguration.getProperty("cct.run.browser.linux.chromeDriverPath");37 }38 ChromeOptions options = new ChromeOptions();39 logger.info("Chrome driver path: " + chromeDriverPath);40 System.setProperty("webdriver.chrome.driver", chromeDriverPath);41 if (TestConfiguration.getProperty("cct.run.browser.headless").equalsIgnoreCase("true")) {42 logger.info("Running browser headless...");43 options.addArguments("no-sandbox");44 options.addArguments("disable-dev-shm-usage");45 options.addArguments("--headless");46 options.addArguments("--start-maximized");47 //options.addArguments("--window-size=1980,1080");48 //capabilities.setCapability("goog:chromeOptions", chromeOptions);49 }50 options.addArguments("--disable-web-security");51 options.addArguments("--allow-running-insecure-content");52 options.addArguments("--ignore-certificate-errors");53 options.addArguments("--disable-gpu");54 options.addArguments("--allow-insecure-localhost");55 return new ChromeDriver(options);56 }57 private static final WebDriver getRemoteDriver() {58 System.setProperty("webdriver.chrome.driver",TestConfiguration.getProperty("cct.run.browser.windows.chromeDriverPath"));59 ChromeDriverService service = (ChromeDriverService)((ChromeDriverService.Builder)((ChromeDriverService.Builder)(new ChromeDriverService.Builder()).usingDriverExecutable(new File(TestConfiguration.getProperty("cct.run.browser.windows.chromeDriverPath")))).usingAnyFreePort()).build();60 try {61 service.start();62 } catch (IOException e) {63 e.printStackTrace();64 }65 return (WebDriver)new RemoteWebDriver(service.getUrl(), (Capabilities)DesiredCapabilities.chrome());66 }67 private static void setProxy(DesiredCapabilities capabilities) {68 Proxy proxy = new Proxy();69 proxy.setProxyType(Proxy.ProxyType.PAC);70 proxy.setProxyAutoconfigUrl("http://proxyconf.glb.nsn-net.net/proxy.pac");71 capabilities.setCapability("proxy", proxy);72 }73 private static final FirefoxDriver getFirefoxDriver() {74 String firefoxExecutablePath = "";75 if (TestConfiguration.getProperty("cct.run.os").equals("windows")) {76 firefoxExecutablePath = TestConfiguration.getProperty("cct.run.browser.windows.firefoxPath");77 } else if (TestConfiguration.getProperty("cct.run.os").equals("linux")) {78 firefoxExecutablePath = TestConfiguration.getProperty("cct.run.browser.linux.firefoxPath");79 }80 System.setProperty("webdriver.gecko.driver", firefoxExecutablePath);81 logger.info("Firefox executable path: " + firefoxExecutablePath);82 FirefoxBinary firefox = new FirefoxBinary(new File(firefoxExecutablePath));83 firefox.addCommandLineOptions(new String[] { "-new-instance" });84 if (TestConfiguration.getProperty("cct.run.browser.headless").equalsIgnoreCase("true")) {85 // firefox.setEnvironmentProperty("DISPLAY", "localhost:20.0");86 }87 DesiredCapabilities capabilities = DesiredCapabilities.firefox();88 if (TestConfiguration.getProperty("cct.proxy").equals("true")) {89 setProxy(capabilities);90 }91 FirefoxProfile profile = new FirefoxProfile();92 profile.setAcceptUntrustedCertificates(true);93 return new FirefoxDriver((Capabilities)capabilities);94 }95}...

Full Screen

Full Screen

Source:FirefoxLauncher.java Github

copy

Full Screen

...33 throws InvalidBrowserExecutableException {34 String browserName = BrowserType.FIREFOX;35 BrowserLocator locator = new CombinedFirefoxLocator();36 String version = (String) browserOptions.getCapability(CapabilityType.VERSION);37 if ("2".equals(version)) {38 browserName = BrowserType.FIREFOX_2;39 locator = new Firefox2Locator();40 }41 if ("3".equals(version)) {42 browserName = BrowserType.FIREFOX_3;43 locator = new Firefox3Locator();44 }45 String mode = (String) browserOptions.getCapability("mode");46 if (mode == null) {47 mode = "chrome";48 }49 if ("default".equals(mode)) {50 mode = "chrome";51 }52 BrowserInstallation installation =53 ApplicationRegistry.instance().browserInstallationCache().locateBrowserInstallation(54 browserName, browserLaunchLocation, locator);55 if (installation == null) {56 throw new InvalidBrowserExecutableException(57 "The specified path to the browser executable is invalid.");58 }59 if ("chrome".equals(mode)) {60 realLauncher =61 new FirefoxChromeLauncher(browserOptions, configuration, sessionId, installation);62 return;63 }64 boolean proxyInjectionMode =65 browserOptions.is("proxyInjectionMode") || "proxyInjection".equals(mode);66 // You can't just individually configure a browser for PI mode; it's a server-level67 // configuration parameter68 boolean globalProxyInjectionMode = configuration.getProxyInjectionModeArg();69 if (proxyInjectionMode && !globalProxyInjectionMode) {70 if (proxyInjectionMode) {71 throw new RuntimeException(72 "You requested proxy injection mode, but this server wasn't configured with -proxyInjectionMode on the command line");73 }74 }75 // if user didn't request PI, but the server is configured that way, just switch up to PI76 proxyInjectionMode = globalProxyInjectionMode;77 if (proxyInjectionMode) {78 realLauncher =79 new ProxyInjectionFirefoxCustomProfileLauncher(browserOptions, configuration, sessionId,80 installation);81 return;82 }83 // the mode isn't "chrome" or "proxyInjection"; at this point it had better be84 // CapabilityType.PROXY85 if (!CapabilityType.PROXY.equals(mode)) {86 throw new RuntimeException("Unrecognized browser mode: " + mode);87 }88 realLauncher =89 new FirefoxCustomProfileLauncher(browserOptions, configuration, sessionId, installation);90 }91 public void close() {92 realLauncher.close();93 }94 public void launchHTMLSuite(String suiteUrl, String baseUrl) {95 realLauncher.launchHTMLSuite(suiteUrl, baseUrl);96 }97 public void launchRemoteSession(String url) {98 realLauncher.launchRemoteSession(url);99 }...

Full Screen

Full Screen

equals

Using AI Code Generation

copy

Full Screen

1public class ProxyExample {2 public static void main(String[] args) {3 Proxy proxy = new Proxy();4 proxy.setProxyType(ProxyType.MANUAL);5 proxy.setHttpProxy("localhost:8888");6 proxy.setSslProxy("localhost:8888");7 ChromeOptions options = new ChromeOptions();8 options.setProxy(proxy);9 WebDriver driver = new ChromeDriver(options);10 }11}

Full Screen

Full Screen

equals

Using AI Code Generation

copy

Full Screen

1import org.openqa.selenium.Proxy;2import org.openqa.selenium.remote.CapabilityType;3import org.openqa.selenium.remote.DesiredCapabilities;4public class ProxySettings {5 public static void main(String[] args) {6 Proxy proxy = new Proxy();7 proxy.setProxyType(Proxy.ProxyType.MANUAL);8 proxy.setHttpProxy("

Full Screen

Full Screen

equals

Using AI Code Generation

copy

Full Screen

1import org.openqa.selenium.Proxy;2public class ProxyClass {3 public static void main(String[] args) {4 Proxy proxy = new Proxy();5 proxy.setHttpProxy("localhost:8080");6 proxy.setSslProxy("localhost:8080");7 Proxy proxy1 = new Proxy();8 proxy1.setHttpProxy("localhost:8080");9 proxy1.setSslProxy("localhost:8080");10 if(proxy.equals(proxy1)) {11 System.out.println("Both proxy objects are equal");12 } else {13 System.out.println("Both proxy objects are not equal");14 }15 }16}

Full Screen

Full Screen

equals

Using AI Code Generation

copy

Full Screen

1public class ProxyExample {2public static void main(String[] args) {3Proxy proxy = new Proxy();4proxy.setHttpProxy("localhost:8888");5proxy.setFtpProxy("localhost:8888");6proxy.setSslProxy("localhost:8888");7DesiredCapabilities capabilities = new DesiredCapabilities();8capabilities.setCapability(CapabilityType.PROXY, proxy);9WebDriver driver = new FirefoxDriver(capabilities);10}11}

Full Screen

Full Screen

equals

Using AI Code Generation

copy

Full Screen

1Proxy proxy = new Proxy();2proxy.setHttpProxy("proxy.server:3128");3proxy.setSslProxy("proxy.server:3128");4proxy.setFtpProxy("proxy.server:3128");5proxy.setSocksProxy("proxy.server:3128");6proxy.setSocksUsername("username");7proxy.setSocksPassword("password");8proxy.setNoProxy("localhost,

Full Screen

Full Screen

equals

Using AI Code Generation

copy

Full Screen

1package org.openqa.selenium.example;2import org.openqa.selenium.Proxy;3import org.openqa.selenium.WebDriver;4import org.openqa.selenium.firefox.FirefoxDriver;5public class ProxyExample {6 public static void main(String[] args) {7 WebDriver driver = new FirefoxDriver();8 System.out.println("Page title is: " + driver.getTitle());9 System.out.println("Page title is: " + driver.getTitle());10 driver.quit();11 }12}

Full Screen

Full Screen

equals

Using AI Code Generation

copy

Full Screen

1import org.openqa.selenium.Proxy;2import org.openqa.selenium.WebDriver;3import org.openqa.selenium.remote.DesiredCapabilities;4import org.openqa.selenium.remote.RemoteWebDriver;5import java.net.MalformedURLException;6import java.net.URL;7public class ProxyEquals {8 public static void main(String[] args) throws MalformedURLException {9 Proxy proxy = new Proxy();10 proxy.setHttpProxy("localhost:8888");11 DesiredCapabilities capabilities = new DesiredCapabilities();12 capabilities.setCapability("proxy", proxy);13 Proxy proxy2 = new Proxy();14 proxy2.setHttpProxy("localhost:8888");15 DesiredCapabilities capabilities2 = new DesiredCapabilities();16 capabilities2.setCapability("proxy", proxy2);17 System.out.println("Are the two proxy objects equal? " + proxy.equals(proxy2));18 System.out.println("Are the two webdriver objects equal? " + driver.equals(driver2));19 driver.close();20 driver2.close();21 }22}

Full Screen

Full Screen

Selenium 4 Tutorial:

LambdaTest’s Selenium 4 tutorial is covering every aspects of Selenium 4 testing with examples and best practices. Here you will learn basics, such as how to upgrade from Selenium 3 to Selenium 4, to some advanced concepts, such as Relative locators and Selenium Grid 4 for Distributed testing. Also will learn new features of Selenium 4, such as capturing screenshots of specific elements, opening a new tab or window on the browser, and new protocol adoptions.

Chapters:

  1. Upgrading From Selenium 3 To Selenium 4?: In this chapter, learn in detail how to update Selenium 3 to Selenium 4 for Java binding. Also, learn how to upgrade while using different build tools such as Maven or Gradle and get comprehensive guidance for upgrading Selenium.

  2. What’s New In Selenium 4 & What’s Being Deprecated? : Get all information about new implementations in Selenium 4, such as W3S protocol adaption, Optimized Selenium Grid, and Enhanced Selenium IDE. Also, learn what is deprecated for Selenium 4, such as DesiredCapabilites and FindsBy methods, etc.

  3. Selenium 4 With Python: Selenium supports all major languages, such as Python, C#, Ruby, and JavaScript. In this chapter, learn how to install Selenium 4 for Python and the features of Python in Selenium 4, such as Relative locators, Browser manipulation, and Chrom DevTool protocol.

  4. Selenium 4 Is Now W3C Compliant: JSON Wireframe protocol is retiring from Selenium 4, and they are adopting W3C protocol to learn in detail about the advantages and impact of these changes.

  5. How To Use Selenium 4 Relative Locator? : Selenium 4 came with new features such as Relative Locators that allow constructing locators with reference and easily located constructors nearby. Get to know its different use cases with examples.

  6. Selenium Grid 4 Tutorial For Distributed Testing: Selenium Grid 4 allows you to perform tests over different browsers, OS, and device combinations. It also enables parallel execution browser testing, reads up on various features of Selenium Grid 4 and how to download it, and runs a test on Selenium Grid 4 with best practices.

  7. Selenium Video Tutorials: Binge on video tutorials on Selenium by industry experts to get step-by-step direction from automating basic to complex test scenarios with Selenium.

Selenium 101 certifications:

LambdaTest also provides certification for Selenium testing to accelerate your career in Selenium automation testing.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful