use of org.openqa.selenium.Proxy in project page-factory-2 by sbtqa.
the class TagWebDriver method createDriver.
private static void createDriver() throws UnsupportedBrowserException, MalformedURLException {
DesiredCapabilities capabilities = new WebDriverCapabilitiesParser().parse();
if (!PROPERTIES.getProxy().isEmpty()) {
Proxy seleniumProxy = ProxyConfigurator.configureProxy();
capabilities.setCapability(CapabilityType.PROXY, seleniumProxy);
}
String browserName = getBrowserName();
capabilities.setBrowserName(browserName);
String webDriverUrl = PROPERTIES.getWebDriverUrl();
if (!webDriverUrl.isEmpty()) {
setWebDriver(createRemoteWebDriver(webDriverUrl, capabilities));
} else {
if (browserName.equalsIgnoreCase(FIREFOX)) {
setWebDriver(new FirefoxDriver(capabilities));
} else if (browserName.equalsIgnoreCase(SAFARI)) {
setWebDriver(new SafariDriver(capabilities));
} else if (browserName.equalsIgnoreCase(CHROME)) {
WebDriverManagerConfigurator.configureDriver(ChromeDriverManager.getInstance(), CHROME);
setWebDriver(new ChromeDriver(capabilities));
} else if (browserName.equalsIgnoreCase(IE)) {
WebDriverManagerConfigurator.configureDriver(InternetExplorerDriverManager.getInstance(), IE);
setWebDriver(new InternetExplorerDriver(capabilities));
} else {
throw new UnsupportedBrowserException("'" + browserName + "' is not supported yet");
}
}
webDriver.manage().timeouts().pageLoadTimeout(PageFactory.getTimeOutInSeconds(), TimeUnit.SECONDS);
setBrowserSize();
webDriver.get(PROPERTIES.getStartingUrl());
}
use of org.openqa.selenium.Proxy in project page-factory-2 by sbtqa.
the class ProxyConfigurator method configureProxy.
public static Proxy configureProxy() {
BrowserMobProxy browserMobProxy = new BrowserMobProxyServer();
browserMobProxy.start(0);
Proxy seleniumProxy = ClientUtil.createSeleniumProxy(browserMobProxy);
return seleniumProxy;
}
use of org.openqa.selenium.Proxy in project page-factory-2 by sbtqa.
the class WebDriverService method createDriver.
private void createDriver() throws UnsupportedBrowserException, MalformedURLException {
DesiredCapabilities capabilities = new WebDriverCapabilitiesParser().parse();
if (!PROPERTIES.getProxy().isEmpty()) {
Proxy seleniumProxy = ProxyConfigurator.configureProxy();
capabilities.setCapability(CapabilityType.PROXY, seleniumProxy);
}
BrowserName browserName = WebEnvironment.getBrowserName();
capabilities.setBrowserName(browserName.getName());
String webDriverUrl = PROPERTIES.getWebDriverUrl();
if (!webDriverUrl.isEmpty()) {
setWebDriver(createRemoteWebDriver(webDriverUrl, capabilities));
} else {
if (browserName.equals(BrowserName.FIREFOX)) {
setWebDriver(new CreatedFirefoxDriver(capabilities).get());
} else if (browserName.equals(BrowserName.SAFARI)) {
setWebDriver(new CreatedSafariDriver(capabilities).get());
} else if (browserName.equals(BrowserName.CHROME)) {
setWebDriver(new CreatedChromeDriver(capabilities).get());
} else if (browserName.equals(BrowserName.INTERNET_EXPLORER)) {
setWebDriver(new CreatedInternetExplorerDriver(capabilities).get());
} else if (browserName.equals(BrowserName.EDGE)) {
setWebDriver(new CreatedEdgeDriver(capabilities).get());
} else {
throw new UnsupportedBrowserException("'" + browserName + "' is not supported yet");
}
}
webDriver.manage().timeouts().pageLoadTimeout(PROPERTIES.getTimeout(), TimeUnit.SECONDS);
setBrowserSize();
webDriver.get(PROPERTIES.getStartingUrl());
}
use of org.openqa.selenium.Proxy in project NoraUi by NoraUi.
the class Context method initializeRobot.
public synchronized void initializeRobot(Class<?> clazz) throws TechnicalException {
logger.info("Context > initializeRobot() with " + clazz.getCanonicalName());
// set browser: chrome,firefox or ie
browser = getProperty(BROWSER_KEY, applicationProperties);
// set Webdriver file: src/test/resources/drivers/...
initializeWebdriversProperties(Thread.currentThread().getContextClassLoader());
// wait delay until web element is displayed.
timeout = setIntProperty(TIMEOUT_KEY, applicationProperties);
// set version of selectors used to deliver several versions
selectorsVersion = getProperty(SELECTORS_VERSION, applicationProperties);
// proxies configuration
proxy = new Proxy();
proxy.setAutodetect(true);
final String httpProxy = getProperty(HTTP_PROXY, applicationProperties);
if (httpProxy != null && !"".equals(httpProxy)) {
proxy.setAutodetect(false);
proxy.setHttpProxy(httpProxy);
}
final String httpsProxy = getProperty(HTTPS_PROXY, applicationProperties);
if (httpsProxy != null && !"".equals(httpsProxy)) {
proxy.setAutodetect(false);
proxy.setSslProxy(httpsProxy);
}
final String noProxy = getProperty(NO_PROXY, applicationProperties);
if (noProxy != null && !"".equals(noProxy)) {
proxy.setAutodetect(false);
proxy.setNoProxy(noProxy);
}
// authentication mode configuration
Auth.setAuthenticationType(getProperty(AUTH_TYPE, applicationProperties));
// stacktrace configuration
displayStackTrace = "true".equals(getProperty(DISPLAY_STACK_TRACE, applicationProperties));
// enable browser headless mode ?
isHeadless = "true".equals(getProperty(HEADLESS, applicationProperties));
// init driver callbacks
exceptionCallbacks.put(Callbacks.RESTART_WEB_DRIVER, STEPS_BROWSER_STEPS_CLASS_QUALIFIED_NAME, RESTART_WEB_DRIVER_METHOD_NAME);
exceptionCallbacks.put(Callbacks.CLOSE_WINDOW_AND_SWITCH_TO_DEMO_HOME, STEPS_BROWSER_STEPS_CLASS_QUALIFIED_NAME, GO_TO_URL_METHOD_NAME, DEMO_HOME);
exceptionCallbacks.put(Callbacks.CLOSE_WINDOW_AND_SWITCH_TO_LOGOGAME_HOME, STEPS_BROWSER_STEPS_CLASS_QUALIFIED_NAME, GO_TO_URL_METHOD_NAME, LOGOGAME_HOME);
exceptionCallbacks.put(Callbacks.CLOSE_WINDOW_AND_SWITCH_TO_COUNTRIES_HOME, STEPS_BROWSER_STEPS_CLASS_QUALIFIED_NAME, GO_TO_URL_METHOD_NAME, COUNTRIES_HOME);
// init applications
initApplicationDom(clazz.getClassLoader(), selectorsVersion, DEMO_KEY);
applications.put(DEMO_KEY, new Application(DEMO_HOME, getProperty(DEMO_KEY, applicationProperties) + "/index.html"));
initApplicationDom(clazz.getClassLoader(), selectorsVersion, LOGOGAME_KEY);
applications.put(LOGOGAME_KEY, new Application(LOGOGAME_HOME, getProperty(LOGOGAME_KEY, applicationProperties) + "/index.html"));
initApplicationDom(clazz.getClassLoader(), selectorsVersion, COUNTRIES_KEY);
applications.put(COUNTRIES_KEY, new Application(COUNTRIES_HOME, getProperty(COUNTRIES_KEY, applicationProperties) + "/index.html"));
// read and init all cucumber methods
cucumberMethods = Step.getAllCucumberMethods(clazz);
}
use of org.openqa.selenium.Proxy in project selenified by Coveros.
the class TestSetupTest method setupProxyTest.
@Test
public void setupProxyTest() {
TestSetup setup = new TestSetup();
setup.setupProxy();
DesiredCapabilities capability = setup.getDesiredCapabilities();
Assert.assertFalse(capability.is(CapabilityType.PROXY));
System.setProperty("proxy", "localhost");
setup.setupProxy();
capability = setup.getDesiredCapabilities();
Proxy export = (Proxy) capability.getCapability(CapabilityType.PROXY);
Assert.assertEquals(export.getHttpProxy(), "localhost");
}
Aggregations