How to use Proxy class of org.openqa.selenium package

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

Source:RemoteWebElementWrapper.java Github

copy

Full Screen

...41import org.openqa.selenium.interactions.internal.Coordinates;42import org.openqa.selenium.remote.FileDetector;43import org.openqa.selenium.remote.RemoteWebDriver;44import org.openqa.selenium.remote.RemoteWebElement;45import com.neotys.selenium.proxies.helpers.ProxySendHelper;46import com.neotys.selenium.proxies.helpers.SeleniumProxyConfig;47import com.neotys.selenium.proxies.helpers.WrapperUtils;48/** We tried to avoid using direct wrapper methods like this, but we found a case where an "instanceof" check was done49 * for a @RemoteWebElement in @org.openqa.selenium.remote.internal.WebElementToJsonConverter#apply(). */50public class RemoteWebElementWrapper extends RemoteWebElement {51 final WebDriver webDriver;52 final SeleniumProxyConfig proxyConfig;53 final ProxySendHelper proxySendHelper;54 final WrapperUtils wrapperUtils;55 final RemoteWebElement original;56 private static final List<String> METHODS_SEND_ON_EXCEPTION_ONLY = WebElementProxy.METHODS_SEND_ON_EXCEPTION_ONLY;57 private static final List<String> METHODS_ALWAYS_SEND = WebElementProxy.METHODS_ALWAYS_SEND;58 public RemoteWebElementWrapper(final WebDriver webDriver, final RemoteWebElement original, final SeleniumProxyConfig proxyConfig){59 this.webDriver = webDriver;60 this.proxyConfig = proxyConfig;61 this.proxySendHelper = new ProxySendHelper(proxyConfig);62 this.wrapperUtils = new WrapperUtils(proxyConfig);63 this.original = original;64 }65 66 @Override67 public void setFileDetector(FileDetector detector) {68 original.setFileDetector(detector);69 }70 71 @Override72 public void setId(String id) {73 original.setId(id);74 }75 76 @Override77 public void setParent(RemoteWebDriver parent) {78 super.setParent(parent);79 original.setParent(parent);80 }81 82 @Override83 public void click() {84 if (!SeleniumProxyConfig.isEnabled()) {85 original.click();86 return;87 }88 try {89 final Method method = RemoteWebElement.class.getDeclaredMethod("click", (Class<?>[])null);90 proxySendHelper.sendAndReturn(METHODS_ALWAYS_SEND, METHODS_SEND_ON_EXCEPTION_ONLY, Collections.<String>emptyList(),91 webDriver, original, method, (Object[])null);92 } catch (final IllegalAccessException | InvocationTargetException | NoSuchMethodException | SecurityException e) {93 throw new NeotysWrappingException("Issue with NeoLoad proxy.", e);94 }95 }96 @Override97 public void submit() {98 if (!SeleniumProxyConfig.isEnabled()) {99 original.submit();100 return;101 }102 try {103 final Method method = RemoteWebElement.class.getDeclaredMethod("submit", (Class<?>[])null);104 proxySendHelper.sendAndReturn(METHODS_ALWAYS_SEND, METHODS_SEND_ON_EXCEPTION_ONLY, Collections.<String>emptyList(),105 webDriver, original, method, (Object[])null);106 } catch (final IllegalAccessException | InvocationTargetException | NoSuchMethodException | SecurityException e) {107 throw new NeotysWrappingException("Issue with NeoLoad proxy.", e);108 }109 }110 @Override111 public String getTagName() {112 if (!SeleniumProxyConfig.isEnabled()) {113 return original.getTagName();114 }115 try {116 final Method method = RemoteWebElement.class.getDeclaredMethod("getTagName", (Class<?>[])null);117 return (String) proxySendHelper.sendAndReturn(METHODS_ALWAYS_SEND, METHODS_SEND_ON_EXCEPTION_ONLY, Collections.<String>emptyList(),118 webDriver, original, method, (Object[])null);119 } catch (final IllegalAccessException | InvocationTargetException | NoSuchMethodException | SecurityException e) {120 throw new NeotysWrappingException("Issue with NeoLoad proxy.", e);121 }122 }123 @Override124 public String getAttribute(final String name) {125 if (!SeleniumProxyConfig.isEnabled()) {126 return original.getAttribute(name);127 }128 try {129 final Method method = RemoteWebElement.class.getDeclaredMethod("getAttribute", (new Class<?>[]{String.class}));130 return (String) proxySendHelper.sendAndReturn(METHODS_ALWAYS_SEND, METHODS_SEND_ON_EXCEPTION_ONLY, Collections.<String>emptyList(),131 webDriver, original, method, new Object[]{name});132 } catch (final IllegalAccessException | InvocationTargetException | NoSuchMethodException | SecurityException e) {133 throw new NeotysWrappingException("Issue with NeoLoad proxy.", e);134 } 135 }136 @Override137 public List<WebElement> findElements(final By by) {138 if (!SeleniumProxyConfig.isEnabled()) {139 return original.findElements(by);140 }141 try {142 final Method method = RemoteWebElement.class.getDeclaredMethod("findElements", (new Class<?>[]{By.class}));143 return proxySendHelper.sendAndReturn(METHODS_ALWAYS_SEND, METHODS_SEND_ON_EXCEPTION_ONLY, Collections.<String>emptyList(),144 webDriver, original, method, new Object[]{by});145 } catch (final IllegalAccessException | InvocationTargetException | NoSuchMethodException | SecurityException e) {146 throw new NeotysWrappingException("Issue with NeoLoad proxy.", e);147 } 148 }149 @Override150 public WebElement findElement(final By by) {151 if (!SeleniumProxyConfig.isEnabled()) {152 return original.findElement(by);153 }154 try {155 final Method method = RemoteWebElement.class.getDeclaredMethod("findElement", (new Class<?>[]{By.class}));156 return proxySendHelper.sendAndReturn(METHODS_ALWAYS_SEND, METHODS_SEND_ON_EXCEPTION_ONLY, Collections.<String>emptyList(),157 webDriver, original, method, new Object[]{by});158 } catch (final IllegalAccessException | InvocationTargetException | NoSuchMethodException | SecurityException e) {159 throw new NeotysWrappingException("Issue with NeoLoad proxy.", e);160 } 161 }162 @Override163 public WebElement findElementById(final String using) {164 if (!SeleniumProxyConfig.isEnabled()) {165 return original.findElementById(using);166 }167 try {168 final Method method = RemoteWebElement.class.getDeclaredMethod("findElementById", (new Class<?>[]{String.class}));169 return proxySendHelper.sendAndReturn(METHODS_ALWAYS_SEND, METHODS_SEND_ON_EXCEPTION_ONLY, Collections.<String>emptyList(),170 webDriver, original, method, new Object[]{using});171 } catch (final IllegalAccessException | InvocationTargetException | NoSuchMethodException | SecurityException e) {172 throw new NeotysWrappingException("Issue with NeoLoad proxy.", e);173 } 174 }175 @Override176 public List<WebElement> findElementsById(final String using) {177 if (!SeleniumProxyConfig.isEnabled()) {178 return original.findElementsById(using);179 }180 try {181 final Method method = RemoteWebElement.class.getDeclaredMethod("findElementsById", (new Class<?>[]{String.class}));182 return proxySendHelper.sendAndReturn(METHODS_ALWAYS_SEND, METHODS_SEND_ON_EXCEPTION_ONLY, Collections.<String>emptyList(),183 webDriver, original, method, new Object[]{using});184 } catch (final IllegalAccessException | InvocationTargetException | NoSuchMethodException | SecurityException e) {185 throw new NeotysWrappingException("Issue with NeoLoad proxy.", e);186 } 187 }188 @Override189 public WebElement findElementByLinkText(final String using) {190 if (!SeleniumProxyConfig.isEnabled()) {191 return original.findElementByLinkText(using);192 }193 try {194 final Method method = RemoteWebElement.class.getDeclaredMethod("findElementByLinkText", (new Class<?>[]{String.class}));195 return proxySendHelper.sendAndReturn(METHODS_ALWAYS_SEND, METHODS_SEND_ON_EXCEPTION_ONLY, Collections.<String>emptyList(),196 webDriver, original, method, new Object[]{using});197 } catch (final IllegalAccessException | InvocationTargetException | NoSuchMethodException | SecurityException e) {198 throw new NeotysWrappingException("Issue with NeoLoad proxy.", e);199 } 200 }201 @Override202 public List<WebElement> findElementsByLinkText(final String using) {203 if (!SeleniumProxyConfig.isEnabled()) {204 return original.findElementsByLinkText(using);205 }206 try {207 final Method method = RemoteWebElement.class.getDeclaredMethod("findElementsByLinkText", (new Class<?>[]{String.class}));208 return proxySendHelper.sendAndReturn(METHODS_ALWAYS_SEND, METHODS_SEND_ON_EXCEPTION_ONLY, Collections.<String>emptyList(),209 webDriver, original, method, new Object[]{using});210 } catch (final IllegalAccessException | InvocationTargetException | NoSuchMethodException | SecurityException e) {211 throw new NeotysWrappingException("Issue with NeoLoad proxy.", e);212 } 213 }214 @Override215 public WebElement findElementByName(final String using) {216 if (!SeleniumProxyConfig.isEnabled()) {217 return original.findElementByName(using);218 }219 try {220 final Method method = RemoteWebElement.class.getDeclaredMethod("findElementByName", (new Class<?>[]{String.class}));221 return proxySendHelper.sendAndReturn(METHODS_ALWAYS_SEND, METHODS_SEND_ON_EXCEPTION_ONLY, Collections.<String>emptyList(),222 webDriver, original, method, new Object[]{using});223 } catch (final IllegalAccessException | InvocationTargetException | NoSuchMethodException | SecurityException e) {224 throw new NeotysWrappingException("Issue with NeoLoad proxy.", e);225 } 226 }227 @Override228 public List<WebElement> findElementsByName(final String using) {229 if (!SeleniumProxyConfig.isEnabled()) {230 return original.findElementsByName(using);231 }232 try {233 final Method method = RemoteWebElement.class.getDeclaredMethod("findElementsByName", (new Class<?>[]{String.class}));234 return proxySendHelper.sendAndReturn(METHODS_ALWAYS_SEND, METHODS_SEND_ON_EXCEPTION_ONLY, Collections.<String>emptyList(),235 webDriver, original, method, new Object[]{using});236 } catch (final IllegalAccessException | InvocationTargetException | NoSuchMethodException | SecurityException e) {237 throw new NeotysWrappingException("Issue with NeoLoad proxy.", e);238 } 239 }240 @Override241 public WebElement findElementByClassName(final String using) {242 if (!SeleniumProxyConfig.isEnabled()) {243 return original.findElementByClassName(using);244 }245 try {246 final Method method = RemoteWebElement.class.getDeclaredMethod("findElementByClassName", (new Class<?>[]{String.class}));247 return proxySendHelper.sendAndReturn(METHODS_ALWAYS_SEND, METHODS_SEND_ON_EXCEPTION_ONLY, Collections.<String>emptyList(),248 webDriver, original, method, new Object[]{using});249 } catch (final IllegalAccessException | InvocationTargetException | NoSuchMethodException | SecurityException e) {250 throw new NeotysWrappingException("Issue with NeoLoad proxy.", e);251 } 252 }253 @Override254 public List<WebElement> findElementsByClassName(final String using) {255 if (!SeleniumProxyConfig.isEnabled()) {256 return original.findElementsByClassName(using);257 }258 try {259 final Method method = RemoteWebElement.class.getDeclaredMethod("findElementsByClassName", (new Class<?>[]{String.class}));260 return proxySendHelper.sendAndReturn(METHODS_ALWAYS_SEND, METHODS_SEND_ON_EXCEPTION_ONLY, Collections.<String>emptyList(),261 webDriver, original, method, new Object[]{using});262 } catch (final IllegalAccessException | InvocationTargetException | NoSuchMethodException | SecurityException e) {263 throw new NeotysWrappingException("Issue with NeoLoad proxy.", e);264 } 265 }266 @Override267 public WebElement findElementByCssSelector(final String using) {268 if (!SeleniumProxyConfig.isEnabled()) {269 return original.findElementByCssSelector(using);270 }271 try {272 final Method method = RemoteWebElement.class.getDeclaredMethod("findElementByCssSelector", (new Class<?>[]{String.class}));273 return proxySendHelper.sendAndReturn(METHODS_ALWAYS_SEND, METHODS_SEND_ON_EXCEPTION_ONLY, Collections.<String>emptyList(),274 webDriver, original, method, new Object[]{using});275 } catch (final IllegalAccessException | InvocationTargetException | NoSuchMethodException | SecurityException e) {276 throw new NeotysWrappingException("Issue with NeoLoad proxy.", e);277 } 278 }279 @Override280 public List<WebElement> findElementsByCssSelector(final String using) {281 if (!SeleniumProxyConfig.isEnabled()) {282 return original.findElementsByCssSelector(using);283 }284 try {285 final Method method = RemoteWebElement.class.getDeclaredMethod("findElementsByCssSelector", (new Class<?>[]{String.class}));286 return proxySendHelper.sendAndReturn(METHODS_ALWAYS_SEND, METHODS_SEND_ON_EXCEPTION_ONLY, Collections.<String>emptyList(),287 webDriver, original, method, new Object[]{using});288 } catch (final IllegalAccessException | InvocationTargetException | NoSuchMethodException | SecurityException e) {289 throw new NeotysWrappingException("Issue with NeoLoad proxy.", e);290 } 291 }292 @Override293 public WebElement findElementByXPath(final String using) {294 if (!SeleniumProxyConfig.isEnabled()) {295 return original.findElementByXPath(using);296 }297 try {298 final Method method = RemoteWebElement.class.getDeclaredMethod("findElementByXPath", (new Class<?>[]{String.class}));299 return proxySendHelper.sendAndReturn(METHODS_ALWAYS_SEND, METHODS_SEND_ON_EXCEPTION_ONLY, Collections.<String>emptyList(),300 webDriver, original, method, new Object[]{using});301 } catch (final IllegalAccessException | InvocationTargetException | NoSuchMethodException | SecurityException e) {302 throw new NeotysWrappingException("Issue with NeoLoad proxy.", e);303 } 304 }305 @Override306 public List<WebElement> findElementsByXPath(final String using) {307 if (!SeleniumProxyConfig.isEnabled()) {308 return original.findElementsByXPath(using);309 }310 try {311 final Method method = RemoteWebElement.class.getDeclaredMethod("findElementsByXPath", (new Class<?>[]{String.class}));312 return proxySendHelper.sendAndReturn(METHODS_ALWAYS_SEND, METHODS_SEND_ON_EXCEPTION_ONLY, Collections.<String>emptyList(),313 webDriver, original, method, new Object[]{using});314 } catch (final IllegalAccessException | InvocationTargetException | NoSuchMethodException | SecurityException e) {315 throw new NeotysWrappingException("Issue with NeoLoad proxy.", e);316 } 317 }318 @Override319 public WebElement findElementByPartialLinkText(final String using) {320 if (!SeleniumProxyConfig.isEnabled()) {321 return original.findElementByPartialLinkText(using);322 }323 try {324 final Method method = RemoteWebElement.class.getDeclaredMethod("findElementByPartialLinkText", (new Class<?>[]{String.class}));325 return proxySendHelper.sendAndReturn(METHODS_ALWAYS_SEND, METHODS_SEND_ON_EXCEPTION_ONLY, Collections.<String>emptyList(),326 webDriver, original, method, new Object[]{using});327 } catch (final IllegalAccessException | InvocationTargetException | NoSuchMethodException | SecurityException e) {328 throw new NeotysWrappingException("Issue with NeoLoad proxy.", e);329 } 330 }331 @Override332 public List<WebElement> findElementsByPartialLinkText(final String using) {333 if (!SeleniumProxyConfig.isEnabled()) {334 return original.findElementsByPartialLinkText(using);335 }336 try {337 final Method method = RemoteWebElement.class.getDeclaredMethod("findElementsByPartialLinkText", (new Class<?>[]{String.class}));338 return proxySendHelper.sendAndReturn(METHODS_ALWAYS_SEND, METHODS_SEND_ON_EXCEPTION_ONLY, Collections.<String>emptyList(),339 webDriver, original, method, new Object[]{using});340 } catch (final IllegalAccessException | InvocationTargetException | NoSuchMethodException | SecurityException e) {341 throw new NeotysWrappingException("Issue with NeoLoad proxy.", e);342 } 343 }344 @Override345 public WebElement findElementByTagName(final String using) {346 if (!SeleniumProxyConfig.isEnabled()) {347 return original.findElementByTagName(using);348 }349 try {350 final Method method = RemoteWebElement.class.getDeclaredMethod("findElementByTagName", (new Class<?>[]{String.class}));351 return proxySendHelper.sendAndReturn(METHODS_ALWAYS_SEND, METHODS_SEND_ON_EXCEPTION_ONLY, Collections.<String>emptyList(),352 webDriver, original, method, new Object[]{using});353 } catch (final IllegalAccessException | InvocationTargetException | NoSuchMethodException | SecurityException e) {354 throw new NeotysWrappingException("Issue with NeoLoad proxy.", e);355 } 356 }357 @Override358 public List<WebElement> findElementsByTagName(final String using) {359 if (!SeleniumProxyConfig.isEnabled()) {360 return original.findElementsByTagName(using);361 }362 try {363 final Method method = RemoteWebElement.class.getDeclaredMethod("findElementsByTagName", (new Class<?>[]{String.class}));364 return proxySendHelper.sendAndReturn(METHODS_ALWAYS_SEND, METHODS_SEND_ON_EXCEPTION_ONLY, Collections.<String>emptyList(),365 webDriver, original, method, new Object[]{using});366 } catch (final IllegalAccessException | InvocationTargetException | NoSuchMethodException | SecurityException e) {367 throw new NeotysWrappingException("Issue with NeoLoad proxy.", e);368 } 369 }370 @Override371 public WebDriver getWrappedDriver() {372 if (!SeleniumProxyConfig.isEnabled()) {373 return original.getWrappedDriver();374 }375 return (WebDriver) wrapperUtils.wrapIfNecessary(webDriver, super.getWrappedDriver());376 }377 @Override378 protected Object clone() throws CloneNotSupportedException {379 if (!SeleniumProxyConfig.isEnabled()) {380 return super.clone();381 }382 return wrapperUtils.wrapIfNecessary(webDriver, super.clone());383 }384 // automatically generated wrapper methods --------------------------------------------------------385 /**386 * @return387 * @see org.openqa.selenium.remote.RemoteWebElement#getId()388 */389 @Override390 public String getId() {391 return original.getId();392 }393 /**...

Full Screen

Full Screen

Source:InternetExplorerOptions.java Github

copy

Full Screen

...37import org.openqa.selenium.Beta;38import org.openqa.selenium.Capabilities;39import org.openqa.selenium.MutableCapabilities;40import org.openqa.selenium.PageLoadStrategy;41import org.openqa.selenium.Proxy;42import org.openqa.selenium.UnexpectedAlertBehaviour;43import org.openqa.selenium.internal.ElementScrollBehavior;44import org.openqa.selenium.remote.BrowserType;45import org.openqa.selenium.remote.CapabilityType;46import java.time.Duration;47import java.util.Arrays;48import java.util.HashMap;49import java.util.LinkedList;50import java.util.List;51import java.util.Map;52import java.util.Set;53import java.util.concurrent.TimeUnit;54import java.util.stream.Collectors;55import java.util.stream.Stream;56/**57 * Options for configuring the use of IE. Can be used like so:58 * <pre>InternetExplorerOptions options = new InternetExplorerOptions()59 * .requireWindowFocus();60 *61 *new InternetExplorerDriver(options);</pre>62 */63@Beta64public class InternetExplorerOptions extends MutableCapabilities {65 final static String IE_OPTIONS = "se:ieOptions";66 private static final String FULL_PAGE_SCREENSHOT = "ie.enableFullPageScreenshot";67 private static final String UPLOAD_DIALOG_TIMEOUT = "ie.fileUploadDialogTimeout";68 private static final String FORCE_WINDOW_SHELL_API = "ie.forceShellWindowsApi";69 private static final String VALIDATE_COOKIE_DOCUMENT_TYPE = "ie.validateCookieDocumentType";70 private final static Set<String> CAPABILITY_NAMES = ImmutableSortedSet.<String>naturalOrder()71 .add(BROWSER_ATTACH_TIMEOUT)72 .add(ELEMENT_SCROLL_BEHAVIOR)73 .add(ENABLE_PERSISTENT_HOVERING)74 .add(FULL_PAGE_SCREENSHOT)75 .add(FORCE_CREATE_PROCESS)76 .add(FORCE_WINDOW_SHELL_API)77 .add(IE_ENSURE_CLEAN_SESSION)78 .add(IE_SWITCHES)79 .add(IE_USE_PER_PROCESS_PROXY)80 .add(IGNORE_ZOOM_SETTING)81 .add(INITIAL_BROWSER_URL)82 .add(INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS)83 .add(REQUIRE_WINDOW_FOCUS)84 .add(UPLOAD_DIALOG_TIMEOUT)85 .add(VALIDATE_COOKIE_DOCUMENT_TYPE)86 .build();87 private Map<String, Object> ieOptions = new HashMap<>();88 public InternetExplorerOptions() {89 setCapability(BROWSER_NAME, BrowserType.IE);90 setCapability(IE_OPTIONS, ieOptions);91 }92 public InternetExplorerOptions(Capabilities source) {93 super();94 merge(source);95 }96 @Override97 public InternetExplorerOptions merge(Capabilities extraCapabilities) {98 super.merge(extraCapabilities);99 return this;100 }101 public InternetExplorerOptions withAttachTimeout(long duration, TimeUnit unit) {102 return withAttachTimeout(Duration.ofMillis(unit.toMillis(duration)));103 }104 public InternetExplorerOptions withAttachTimeout(Duration duration) {105 return amend(BROWSER_ATTACH_TIMEOUT, duration.toMillis());106 }107 public InternetExplorerOptions elementScrollTo(ElementScrollBehavior behavior) {108 return amend(ELEMENT_SCROLL_BEHAVIOR, behavior.getValue());109 }110 /**111 * Enable persistently sending {@code WM_MOUSEMOVE} messages to the IE window during a mouse112 * hover.113 */114 public InternetExplorerOptions enablePersistentHovering() {115 return amend(ENABLE_PERSISTENT_HOVERING, true);116 }117 /**118 * Force the use of the Windows CreateProcess API when launching Internet Explorer.119 */120 public InternetExplorerOptions useCreateProcessApiToLaunchIe() {121 return amend(FORCE_CREATE_PROCESS, true);122 }123 /**124 * Use the Windows ShellWindows API when attaching to Internet Explorer.125 */126 public InternetExplorerOptions useShellWindowsApiToAttachToIe() {127 return amend(FORCE_WINDOW_SHELL_API, true);128 }129 /**130 * Clear the Internet Explorer cache before launching the browser. When set clears the system131 * cache for all instances of Internet Explorer, even those already running when the driven132 * instance is launched.133 */134 public InternetExplorerOptions destructivelyEnsureCleanSession() {135 return amend(IE_ENSURE_CLEAN_SESSION, true);136 }137 public InternetExplorerOptions addCommandSwitches(String... switches) {138 Object raw = getCapability(IE_SWITCHES);139 if (raw == null) {140 raw = new LinkedList<>();141 } else if (raw instanceof String) {142 raw = Arrays.asList(((String) raw).split(" "));143 }144 return amend(145 IE_SWITCHES,146 Streams.concat((Stream<?>) List.class.cast(raw).stream(), Stream.of(switches))147 .filter(i -> i instanceof String)148 .map(String.class::cast)149 .collect(ImmutableList.toImmutableList()));150 }151 /**152 * Use the {@link org.openqa.selenium.Proxy} defined in other {@link Capabilities} on a153 * per-process basis, not updating the system installed proxy setting. This is only valid when154 * setting a {@link org.openqa.selenium.Proxy} where the155 * {@link org.openqa.selenium.Proxy.ProxyType} is one of156 * <ul>157 * <li>{@link org.openqa.selenium.Proxy.ProxyType#DIRECT}158 * <li>{@link org.openqa.selenium.Proxy.ProxyType#MANUAL}159 * <li>{@link org.openqa.selenium.Proxy.ProxyType#SYSTEM}160 * </ul>161 */162 public InternetExplorerOptions usePerProcessProxy() {163 return amend(IE_USE_PER_PROCESS_PROXY, true);164 }165 public InternetExplorerOptions withInitialBrowserUrl(String url) {166 return amend(INITIAL_BROWSER_URL, Preconditions.checkNotNull(url));167 }168 public InternetExplorerOptions requireWindowFocus() {169 return amend(REQUIRE_WINDOW_FOCUS, true);170 }171 public InternetExplorerOptions waitForUploadDialogUpTo(long duration, TimeUnit unit) {172 return waitForUploadDialogUpTo(Duration.ofMillis(unit.toMillis(duration)));173 }174 public InternetExplorerOptions waitForUploadDialogUpTo(Duration duration) {175 return amend(UPLOAD_DIALOG_TIMEOUT, duration.toMillis());176 }177 public InternetExplorerOptions introduceFlakinessByIgnoringSecurityDomains() {178 return amend(INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);179 }180 public InternetExplorerOptions enableNativeEvents() {181 return amend(NATIVE_EVENTS, true);182 }183 public InternetExplorerOptions ignoreZoomSettings() {184 return amend(IGNORE_ZOOM_SETTING, true);185 }186 public InternetExplorerOptions takeFullPageScreenshot() {187 return amend(FULL_PAGE_SCREENSHOT, true);188 }189 public InternetExplorerOptions setPageLoadStrategy(PageLoadStrategy strategy) {190 return amend(PAGE_LOAD_STRATEGY, strategy);191 }192 public InternetExplorerOptions setUnhandledPromptBehaviour(UnexpectedAlertBehaviour behaviour) {193 return amend(UNHANDLED_PROMPT_BEHAVIOUR, behaviour);194 }195 public InternetExplorerOptions setProxy(Proxy proxy) {196 setCapability(CapabilityType.PROXY, proxy);197 return this;198 }199 private InternetExplorerOptions amend(String optionName, Object value) {200 setCapability(optionName, value);201 return this;202 }203 @Override204 public void setCapability(String key, Object value) {205 super.setCapability(key, value);206 if (IE_SWITCHES.equals(key)) {207 if (value instanceof List) {208 value = ((List<?>) value).stream().map(Object::toString).collect(Collectors.joining(" "));209 }...

Full Screen

Full Screen

Source:DriverFactory.java Github

copy

Full Screen

...162 IEDriverServer = p.getProperty("IEDriverServer");163 }164 System.setProperty("webdriver.ie.driver", IEDriverServer);165 String PROXY = "http://proxy:8083";166 org.openqa.selenium.Proxy proxy = new org.openqa.selenium.Proxy();167 proxy.setHttpProxy(PROXY).setFtpProxy(PROXY).setSslProxy(PROXY);168169 DesiredCapabilities ds = DesiredCapabilities.internetExplorer();170 ds.setCapability(171 InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,172 true);173 ds.setCapability("ignoreProtectedModeSettings", true);174 ds.setCapability(CapabilityType.PROXY, proxy);175 WebDriver driver = new InternetExplorerDriver(ds);176 return driver;177 }178179 /**180 * This method will create RemoteWebdriver181 * 182 * @author Young183 * @param remoteBrowserBean184 * @return WebDriver185 */186 public static WebDriver getRemoteDriver(RemoteBrowserBean remoteBrowserBean) {187 DesiredCapabilities capability = null;188 if (remoteBrowserBean.getBrowserName().contains("firefox")) {189 capability = DesiredCapabilities.firefox();190 } else if (remoteBrowserBean.getBrowserName().contains("chrome")) {191 capability = DesiredCapabilities.chrome();192 }193194 WebDriver driver = null;195 try {196 driver = new RemoteWebDriver(197 new URL(remoteBrowserBean.getHubURL()), capability);198 } catch (MalformedURLException e) {199 e.printStackTrace();200 }201 capability.setBrowserName(remoteBrowserBean.getBrowserName());202 capability.setVersion(remoteBrowserBean.getVersion());203 capability.setCapability(remoteBrowserBean.getPlatform()[0],204 remoteBrowserBean.getPlatform()[1]);205 driver.manage().window().maximize();206 return driver;207 }208209 public static WebDriver getEDGEDriver() {210 try {211 p = ConfigUtilsJi.getProperties(config);212 } catch (IOException e) {213 e.printStackTrace();214 }215 if (p != null) {216 EDGEDriver = p.getProperty("EDGEDriver");217 }218 System.setProperty("webdriver.edge.driver", EDGEDriver);219 String PROXY = "https://raw.githubusercontent.com/seveniruby/gfwlist2pac/master/test/proxy.pac";220 org.openqa.selenium.Proxy proxy = new org.openqa.selenium.Proxy();221 proxy.setHttpProxy(PROXY).setFtpProxy(PROXY).setSslProxy(PROXY);222 DesiredCapabilities capabilities = DesiredCapabilities.edge();223 EdgeOptions options = new EdgeOptions();224 options.setPageLoadStrategy("normal");225 capabilities.setCapability(EdgeOptions.CAPABILITY, options);226 capabilities.setCapability(CapabilityType.PROXY, proxy);227 WebDriver driver = new EdgeDriver(capabilities);228 return driver;229 }230231} ...

Full Screen

Full Screen

Source:WebDriverType.java Github

copy

Full Screen

...42 * proxyServer.enableHarCaptureTypes(CaptureType.REQUEST_CONTENT,43 * CaptureType.RESPONSE_CONTENT);44 * proxyServer.newHar(LocalDateTime.now().toString());45 * 46 * Proxy proxy = ClientUtil.createSeleniumProxy(proxyServer); FirefoxProfile47 * profile = new FirefoxProfile(); String host =48 * proxy.getHttpProxy().split(":")[0]; int port =49 * Integer.parseInt(proxy.getHttpProxy().split(":")[1]);50 * profile.setPreference("network.proxy.type", 1);51 * profile.setPreference("network.proxy.http", host);52 * profile.setPreference("network.proxy.http_port", port);53 * profile.setPreference("network.proxy.ssl", host);54 * profile.setPreference("network.proxy.ssl_port", port);55 * profile.setPreference("acceptInsecureCerts", true);56 */57 // DesiredCapabilities desiredCapabilities = DesiredCapabilities.firefox();58 // desiredCapabilities.setCapability(CapabilityType.LOGGING_PREFS,59 // this.createBrowserLog());60 // desiredCapabilities.setAcceptInsecureCerts(true);61 // desiredCapabilities.setCapability(FirefoxDriver.PROFILE, profile);62 // FirefoxBinary firefoxBinary = new FirefoxBinary();63 // firefoxBinary.addCommandLineOptions("--headless");...

Full Screen

Full Screen

Source:DriverType.java Github

copy

Full Screen

...19import org.openqa.selenium.remote.RemoteWebDriver;20import org.openqa.selenium.safari.SafariDriver;21import org.openqa.selenium.safari.SafariOptions;22import org.openqa.selenium.Platform;23import org.openqa.selenium.Proxy;24import static org.openqa.selenium.Proxy.ProxyType.MANUAL;25class DriverType {26 27 static WebDriver getDriverType(String browserName, String useRemote, String GridURL,28 String platform, String browserVersion,29 String proxyEnabled, String proxyHost, String proxyPort) {30 WebDriver driver;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()) {...

Full Screen

Full Screen

Source:ElementFactory.java Github

copy

Full Screen

...13public class ElementFactory {14 /**15 * See {@link org.openqa.selenium.support.PageFactory#initElements(org.openqa.selenium.WebDriver driver, Class)}16 */17 public static <T> T initElements(OrasiDriver driver, Class<T> pageClassToProxy) {18 TestReporter.logTrace("Entering ElementFactory#initElements");19 TestReporter.logTrace("Creating Page Object");20 T page = instantiatePage(driver, pageClassToProxy);21 TestReporter.logTrace("Successfully created Page Object");22 final OrasiDriver driverRef = driver;23 TestReporter.logTrace("Initialize Page Elements");24 PageFactory.initElements(new ElementDecorator(new CustomElementLocatorFactory(driverRef)), page);25 TestReporter.logTrace("Successfully created Page Elements");26 TestReporter.logTrace("Exiting ElementFactory#initElements");27 return page;28 }29 /**30 * See {@link org.openqa.selenium.support.PageFactory#initElements(org.openqa.selenium.support.pagefactory.FieldDecorator, Object)}31 */32 public static void initElements(OrasiDriver driver, Object page) {33 TestReporter.logTrace("Entering ElementFactory#initElements");34 final OrasiDriver driverRef = driver;35 TestReporter.logTrace("Initialize Page Elements");36 PageFactory.initElements(new ElementDecorator(new CustomElementLocatorFactory(driverRef), driverRef), page);37 TestReporter.logTrace("Successfully created Page Elements");38 TestReporter.logTrace("Exiting ElementFactory#initElements");39 }40 /**41 * see {@link org.openqa.selenium.support.PageFactory#initElements(org.openqa.selenium.support.pagefactory.ElementLocatorFactory, Object)}42 */43 public static void initElements(CustomElementLocatorFactory factory, Object page) {44 TestReporter.logTrace("Entering ElementFactory#initElements");45 final CustomElementLocatorFactory factoryRef = factory;46 TestReporter.logTrace("Initialize Page Elements");47 PageFactory.initElements(new ElementDecorator(factoryRef), page);48 TestReporter.logTrace("Successfully created Page Elements");49 TestReporter.logTrace("Exiting ElementFactory#initElements");50 }51 /**52 * see {@link org.openqa.selenium.support.PageFactory#initElements(org.openqa.selenium.support.pagefactory.ElementLocatorFactory, Object)}53 */54 public static void initElements(FieldDecorator decorator, Object page) {55 TestReporter.logTrace("Entering ElementFactory#initElements");56 TestReporter.logTrace("Initialize Page Elements");57 PageFactory.initElements(decorator, page);58 TestReporter.logTrace("Successfully created Page Elements");59 TestReporter.logTrace("Exiting ElementFactory#initElements");60 }61 /**62 * Copy of {@link org.openqa.selenium.support.PageFactory#instantiatePage(org.openqa.selenium.WebDriver, Class)}63 */64 private static <T> T instantiatePage(WebDriver driver, Class<T> pageClassToProxy) {65 TestReporter.logTrace("Entering ElementFactory#instantiatePage");66 try {67 try {68 TestReporter.logTrace("Create Constructor of Page object");69 Constructor<T> constructor = pageClassToProxy.getConstructor(WebDriver.class);70 TestReporter.logTrace("Successfully created Constructor");71 TestReporter.logTrace("Create new instance of Page object");72 T instance = constructor.newInstance(driver);73 TestReporter.logTrace("Successfully created new Page instance");74 TestReporter.logTrace("Exiting ElementFactory#instantiatePage");75 return instance;76 } catch (NoSuchMethodException e) {77 try{ 78 TestReporter.logTrace("Entering ElementFactory#instantiatePage");79 return pageClassToProxy.newInstance();80 }catch(InstantiationException ie){ 81 throw new PageInitialization("Failed to create instance of: " + pageClassToProxy.getName(), driver);82 }83 }84 } catch (InstantiationException e) {85 throw new PageInitialization("Failed to create instance of: " + pageClassToProxy.getName(), driver);86 } catch (IllegalAccessException e) {87 throw new RuntimeException(e);88 } catch (InvocationTargetException e) {89 throw new RuntimeException(e);90 }91 }92}...

Full Screen

Full Screen

Source:Refactor.java Github

copy

Full Screen

...5import java.util.ArrayList;6import java.util.List;78import org.openqa.selenium.By;9import org.openqa.selenium.Proxy;10import org.openqa.selenium.WebDriver;11import org.openqa.selenium.WebElement;12import org.openqa.selenium.chrome.ChromeDriver;13import org.openqa.selenium.firefox.FirefoxDriver;14import org.openqa.selenium.remote.CapabilityType;15import org.openqa.selenium.remote.DesiredCapabilities;16import org.openqa.selenium.support.FindBy;17import org.testng.annotations.AfterTest;18import org.testng.annotations.BeforeTest;19import org.testng.annotations.Test;2021import com.unityworks.core.CoreClass;22import com.unityworks.pages.MethodClass;2324import net.lightbody.bmp.BrowserMobProxy;25import net.lightbody.bmp.BrowserMobProxyServer;26import net.lightbody.bmp.client.ClientUtil;27import net.lightbody.bmp.core.har.Har;28import net.lightbody.bmp.proxy.CaptureType;29import net.lightbody.bmp.proxy.CaptureType;3031public class Refactor {32 33 String driverPath = "F:\\JavaWithSelenium\\UnityworksReportTest\\src\\main\\resources\\";34 String sFileName = "F:/SeleniumEasy.har";35 36 public WebDriver driver;37 public BrowserMobProxy proxy;38 MethodClass Method = new MethodClass();39 40 @BeforeTest41 public void setUp() {42 43 // start the proxy44 proxy = new BrowserMobProxyServer();45 proxy.start(0);46 //proxy.blacklistRequests("http://www.google-analytics.com/r/__utm.gif", 404); 4748 //get the Selenium proxy object - org.openqa.selenium.Proxy;49 Proxy seleniumProxy = ClientUtil.createSeleniumProxy(proxy);50 5152 // configure it as a desired capability53 DesiredCapabilities capabilities = new DesiredCapabilities();54 capabilities.setCapability(CapabilityType.PROXY, seleniumProxy);55 56 //set chromedriver system property57 //System.setProperty("webdriver.chrome.driver", driverPath+"chromedriver.exe");58 //driver = new ChromeDriver(capabilities);59 driver = new FirefoxDriver(capabilities);60 61 // enable more detailed HAR capture, if desired (see CaptureType for the complete list)62 /*proxy.enableHarCaptureTypes(CaptureType.REQUEST_CONTENT,63 CaptureType.REQUEST_BINARY_CONTENT,CaptureType.REQUEST_HEADERS, 64 CaptureType.REQUEST_COOKIES, 65 CaptureType.RESPONSE_CONTENT, CaptureType.RESPONSE_BINARY_CONTENT, 66 CaptureType.RESPONSE_HEADERS, CaptureType.RESPONSE_COOKIES);*/67 68 proxy.enableHarCaptureTypes(CaptureType.REQUEST_CONTENT); ...

Full Screen

Full Screen

Source:ProxyTest.java Github

copy

Full Screen

1package net.ukr.automation.selenium.session09;2import io.github.bonigarcia.wdm.WebDriverManager;3import net.lightbody.bmp.BrowserMobProxy;4import net.lightbody.bmp.BrowserMobProxyServer;5import net.lightbody.bmp.client.ClientUtil;6import net.lightbody.bmp.core.har.Har;7import net.lightbody.bmp.core.har.HarEntry;8import net.lightbody.bmp.core.har.HarRequest;9import net.lightbody.bmp.core.har.HarResponse;10import net.lightbody.bmp.proxy.CaptureType;11import org.junit.After;12import org.junit.Before;13import org.junit.Test;14import org.openqa.selenium.By;15import org.openqa.selenium.Keys;16import org.openqa.selenium.Proxy;17import org.openqa.selenium.WebDriver;18import org.openqa.selenium.chrome.ChromeDriver;19import org.openqa.selenium.chrome.ChromeOptions;20import org.openqa.selenium.remote.CapabilityType;21import org.openqa.selenium.support.ui.ExpectedConditions;22import org.openqa.selenium.support.ui.WebDriverWait;23public class ProxyTest {24 WebDriver driver;25 WebDriverWait wait;26 BrowserMobProxy proxy;27 @Before28 public void start() {29 // WebDriverManager.chromedriver().setup();30 proxy = new BrowserMobProxyServer();31 proxy.start(0);32 Proxy seleniumProxy = ClientUtil.createSeleniumProxy(proxy);33 ChromeOptions opt = new ChromeOptions();34 opt.setCapability(CapabilityType.PROXY, seleniumProxy);35 driver = new ChromeDriver(opt);36 wait = new WebDriverWait(driver,5);37 proxy.enableHarCaptureTypes(CaptureType.REQUEST_CONTENT, CaptureType.RESPONSE_CONTENT);38 }39 @Test40 public void proxyTest() {41 proxy.newHar("google");42 driver.get("http://google.com");43 driver.findElement(By.name("q")).sendKeys("Selenium" + Keys.ENTER);44 wait.until(ExpectedConditions.elementToBeClickable(By.cssSelector("h3"))).click();45 Har har = proxy.getHar();46 for (HarEntry entry: har.getLog().getEntries())47 {48 HarRequest request = entry.getRequest();...

Full Screen

Full Screen

Proxy

Using AI Code Generation

copy

Full Screen

1import org.openqa.selenium.By;2import org.openqa.selenium.Proxy;3import org.openqa.selenium.WebDriver;4import org.openqa.selenium.WebElement;5import org.openqa.selenium.firefox.FirefoxDriver;6import org.openqa.selenium.firefox.FirefoxProfile;7import org.openqa.selenium.remote.DesiredCapabilities;8import org.openqa.selenium.remote.RemoteWebDriver;9import org.openqa.selenium.support.ui.ExpectedConditions;10import org.openqa.selenium.support.ui.WebDriverWait;11import org.testng.annotations.BeforeClass;12import org.testng.annotations.Test;13import java.net.MalformedURLException;14import java.net.URL;15import java.util.concurrent.TimeUnit;16public class ProxyTest {17 WebDriver driver;18 public void setUp() throws MalformedURLException {19 Proxy proxy = new Proxy();20 proxy.setProxyType(Proxy.ProxyType.MANUAL);21 proxy.setHttpProxy("localhost:8888");22 proxy.setSslProxy("localhost:8888");23 proxy.setFtpProxy("localhost:8888");24 FirefoxProfile profile = new FirefoxProfile();25 profile.setPreference("network.proxy.type", 1);26 profile.setPreference("network.proxy.http", "localhost");27 profile.setPreference("network.proxy.http_port", 8888);28 profile.setPreference("network.proxy.ssl", "localhost");29 profile.setPreference("network.proxy.ssl_port", 8888);30 profile.setPreference("network.proxy.ftp", "localhost");31 profile.setPreference("network.proxy.ftp_port", 8888);32 DesiredCapabilities capabilities = DesiredCapabilities.firefox();33 capabilities.setCapability(FirefoxDriver.PROFILE, profile);34 capabilities.setCapability("proxy", proxy);35 driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);36 }37 public void testProxy() {38 WebElement element = driver.findElement(By.name("q"));39 element.sendKeys("selenium

Full Screen

Full Screen

Proxy

Using AI Code Generation

copy

Full Screen

1import org.openqa.selenium.Proxy;2import org.openqa.selenium.WebDriver;3import org.openqa.selenium.firefox.FirefoxDriver;4import org.openqa.selenium.remote.CapabilityType;5import org.openqa.selenium.remote.DesiredCapabilities;6import org.openqa.selenium.remote.RemoteWebDriver;7public class ProxyTest {8 public static void main(String[] args) {9 Proxy proxy = new Proxy();10 proxy.setHttpProxy("

Full Screen

Full Screen

Proxy

Using AI Code Generation

copy

Full Screen

1import org.openqa.selenium.Proxy;2import org.openqa.selenium.remote.DesiredCapabilities;3import org.openqa.selenium.WebDriver;4import org.openqa.selenium.firefox.FirefoxDriver;5import org.openqa.selenium.By;6import org.openqa.selenium.WebElement;7import org.openqa.selenium.support.ui.WebDriverWait;8import org.openqa.selenium.support.ui.ExpectedConditions;9import java.util.concurrent.TimeUnit;10import java.lang.System;11import org.openqa.selenium.firefox.FirefoxProfile;12import org.openqa.selenium.remote.DesiredCapabilities;13import org.openqa.selenium.firefox.FirefoxDriver;14public class Firefox_Proxy {15 public static void main(String[] args) {16 System.setProperty("webdriver.gecko.driver","C:\\Users\\sandeep\\Downloads\\geckodriver-v0.23.0-win64\\geckodriver.exe");17 FirefoxProfile profile = new FirefoxProfile();18 profile.setPreference("network.proxy.type", 1);19 profile.setPreference("network.proxy.http", "proxy.cognizant.com");20 profile.setPreference("network.proxy.http_port", 6050);21 profile.setPreference("network.proxy.ssl", "proxy.cognizant.com");22 profile.setPreference("network.proxy.ssl_port

Full Screen

Full Screen

Proxy

Using AI Code Generation

copy

Full Screen

1public class ProxyTest {2 public static void main(String[] args) {3 Proxy proxy = new Proxy();4 proxy.setHttpProxy("localhost:8080");5 proxy.setSslProxy("localhost:8080");6 DesiredCapabilities capabilities = new DesiredCapabilities();7 capabilities.setCapability("proxy", proxy);8 WebDriver driver = new ChromeDriver(capabilities);9 driver.quit();10 }11}12DesiredCapabilities is a class which is used to set the capabilities for the browser. It is a key-value pair data structure. It is used to set the capabilities of the browser. The setCapability() method is used to set the capabilities. The following is the syntax of the setCapability() method:13public void setCapability(String key, Object value)14public class ProxyTest {15 public static void main(String[] args) {16 Proxy proxy = new Proxy();17 proxy.setHttpProxy("localhost:8080");18 proxy.setSslProxy("localhost:8080");19 DesiredCapabilities capabilities = new DesiredCapabilities();20 capabilities.setCapability("proxy", proxy);21 WebDriver driver = new ChromeDriver(capabilities);22 driver.quit();23 }24}25public class ProxyTest {26 public static void main(String[] args) {27 System.setProperty("http.proxyHost", "localhost");28 System.setProperty("http.proxyPort", "8080");29 WebDriver driver = new ChromeDriver();30 driver.quit();31 }32}

Full Screen

Full Screen

Proxy

Using AI Code Generation

copy

Full Screen

1import org.openqa.selenium.Proxy;2import org.openqa.selenium.WebDriver;3import org.openqa.selenium.chrome.ChromeDriver;4import org.openqa.selenium.chrome.ChromeOptions;5public class ProxyTest {6 public static void main(String[] args) {7 Proxy proxy = new Proxy();8 proxy.setHttpProxy("proxy.example.com:8080");9 proxy.setSslProxy("proxy.example.com:8080");10 ChromeOptions options = new ChromeOptions();11 options.setCapability("proxy", proxy);12 WebDriver driver = new ChromeDriver(options);13 driver.quit();14 }15}16import org.openqa.selenium.Proxy;17import org.openqa.selenium.WebDriver;18import org.openqa.selenium.chrome.ChromeDriver;19import org.openqa.selenium.chrome.ChromeOptions;20public class ProxyTest {21 public static void main(String[] args) {22 Proxy proxy = new Proxy();23 proxy.setHttpProxy("proxy.example.com:8080");24 proxy.setSslProxy("proxy.example.com:8080");25 proxy.setProxyType(Proxy.ProxyType.MANUAL);26 ChromeOptions options = new ChromeOptions();27 options.setCapability("proxy", proxy);28 WebDriver driver = new ChromeDriver(options);29 driver.quit();30 }31}32import org.openqa.selenium.Proxy;33import org.openqa.selenium.WebDriver;34import org.openqa.selenium.chrome.ChromeDriver;35import org.openqa.selenium.chrome.ChromeOptions;36public class ProxyTest {37 public static void main(String[] args) {38 Proxy proxy = new Proxy();

Full Screen

Full Screen

Proxy

Using AI Code Generation

copy

Full Screen

1import org.openqa.selenium.net.Proxy;2import org.openqa.selenium.remote.DesiredCapabilities;3import org.openqa.selenium.firefox.FirefoxDriver;4public class proxy {5 public static void main(String[] args) {6 Proxy proxy = new Proxy();7 proxy.setHttpProxy("localhost:8888");8 DesiredCapabilities capabilities = new DesiredCapabilities();9 capabilities.setCapability("proxy", proxy);10 FirefoxDriver driver = new FirefoxDriver(capabilities);11 System.out.println(driver.getTitle());12 }13}14import org.openqa.selenium.net.Proxy;15import org.openqa.selenium.remote.DesiredCapabilities;16import org.openqa.selenium.firefox.FirefoxDriver;17public class proxy {18 public static void main(String[] args) {19 Proxy proxy = new Proxy();20 proxy.setHttpProxy("localhost:8888");21 DesiredCapabilities capabilities = new DesiredCapabilities();22 capabilities.setCapability("proxy", proxy);23 FirefoxDriver driver = new FirefoxDriver(capabilities);24 System.out.println(driver.getTitle());25 }26}

Full Screen

Full Screen
copy
1String a = new String("foo");2String b = new String("foo");3System.out.println(a == b); // prints false4System.out.println(a.equals(b)); // prints true5
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