use of org.openqa.selenium.remote.DesiredCapabilities in project selenium_java by sergueik.
the class NgScrollableTableTest method setUp.
@Before
public void setUp() throws Exception {
// change according to platform
System.setProperty("webdriver.chrome.driver", osName.toLowerCase().startsWith("windows") ? new File("c:/java/selenium/chromedriver.exe").getAbsolutePath() : resolveEnvVars(chromeDriverPath));
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
if (isMobile) {
Map<String, String> mobileEmulation = new HashMap<>();
mobileEmulation.put("deviceName", "Google Nexus 5");
Map<String, Object> chromeOptions = new HashMap<>();
chromeOptions.put("mobileEmulation", mobileEmulation);
capabilities.setCapability(ChromeOptions.CAPABILITY, chromeOptions);
seleniumDriver = new ChromeDriver(capabilities);
// set ignoreSynchronization to true to handle page sync ourselves
// instead of using waitForAngular call in JProtractor
ngDriver = new NgWebDriver(seleniumDriver, true);
} else {
seleniumDriver = new ChromeDriver(capabilities);
ngDriver = new NgWebDriver(seleniumDriver, true);
}
ngDriver.get(baseUrl);
ngDriver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
page = new NgScrollableTablePage();
page.setDriver(ngDriver);
JPageFactory.initElements(ngDriver, channel, page);
}
use of org.openqa.selenium.remote.DesiredCapabilities in project selenium_java by sergueik.
the class NgMultiSelectTest method setUp.
@Before
public void setUp() throws Exception {
// change according to platform
// NOTE:
// java.lang.IllegalStateException: The driver executable does not exist: /var/run/chromedriver
// java.lang.IllegalStateException: The driver is not executable: /var/run/chromedriver
System.setProperty("webdriver.chrome.driver", osName.toLowerCase().startsWith("windows") ? new File("c:/java/selenium/chromedriver.exe").getAbsolutePath() : resolveEnvVars(chromeDriverPath));
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
if (isMobile) {
Map<String, String> mobileEmulation = new HashMap<>();
mobileEmulation.put("deviceName", "Google Nexus 5");
Map<String, Object> chromeOptions = new HashMap<>();
chromeOptions.put("mobileEmulation", mobileEmulation);
capabilities.setCapability(ChromeOptions.CAPABILITY, chromeOptions);
seleniumDriver = new ChromeDriver(capabilities);
// set ignoreSynchronization to true to handle page sync ourselves
// instead of using waitForAngular call in JProtractor
ngDriver = new NgWebDriver(seleniumDriver, true);
} else {
seleniumDriver = new ChromeDriver(capabilities);
ngDriver = new NgWebDriver(seleniumDriver);
}
ngDriver.get(baseUrl);
ngDriver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
page = new NgMultiSelectPage();
page.setDriver(ngDriver);
JPageFactory.initElements(ngDriver, channel, page);
}
use of org.openqa.selenium.remote.DesiredCapabilities in project selenium_java by sergueik.
the class NgQualityShepherdTest method setUp.
@Before
public void setUp() throws Exception {
// change according to platformm
System.setProperty("webdriver.chrome.driver", osName.toLowerCase().startsWith("windows") ? new File("c:/java/selenium/chromedriver.exe").getAbsolutePath() : resolveEnvVars(chromeDriverPath));
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
if (isMobile) {
Map<String, String> mobileEmulation = new HashMap<>();
mobileEmulation.put("deviceName", "Google Nexus 5");
Map<String, Object> chromeOptions = new HashMap<>();
chromeOptions.put("mobileEmulation", mobileEmulation);
capabilities.setCapability(ChromeOptions.CAPABILITY, chromeOptions);
seleniumDriver = new ChromeDriver(capabilities);
// set ignoreSynchronization to true to handle page sync ourselves
// instead of using waitForAngular call in JProtractor
ngDriver = new NgWebDriver(seleniumDriver, true);
} else {
seleniumDriver = new ChromeDriver(capabilities);
ngDriver = new NgWebDriver(seleniumDriver);
}
ngDriver.get(baseUrl);
ngDriver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
page = new NgQualityShepherdPage();
page.setDriver(ngDriver);
JPageFactory.initElements(ngDriver, channel, page);
}
use of org.openqa.selenium.remote.DesiredCapabilities in project selenium_java by sergueik.
the class AppTest method setupBeforeSuite.
@BeforeSuite(alwaysRun = true)
public void setupBeforeSuite(ITestContext context) throws InterruptedException, MalformedURLException {
selenium_host = context.getCurrentXmlTest().getParameter("selenium.host");
selenium_port = context.getCurrentXmlTest().getParameter("selenium.port");
selenium_browser = context.getCurrentXmlTest().getParameter("selenium.browser");
selenium_run = context.getCurrentXmlTest().getParameter("selenium.run");
// Remote Configuration
if (selenium_browser.compareToIgnoreCase("remote") == 0) {
String hub = "http://" + selenium_host + ":" + selenium_port + "/wd/hub";
LoggingPreferences logging_preferences = new LoggingPreferences();
logging_preferences.enable(LogType.BROWSER, Level.ALL);
logging_preferences.enable(LogType.CLIENT, Level.INFO);
logging_preferences.enable(LogType.SERVER, Level.INFO);
if (selenium_browser.compareToIgnoreCase("chrome") == 0) {
DesiredCapabilities capabilities = new DesiredCapabilities("chrome", "", Platform.ANY);
capabilities.setBrowserName("chrome");
capabilities.setCapability(CapabilityType.LOGGING_PREFS, logging_preferences);
try {
driver = new RemoteWebDriver(new URL("http://" + selenium_host + ":" + selenium_port + "/wd/hub"), capabilities);
} catch (MalformedURLException ex) {
}
} else {
DesiredCapabilities capabilities = new DesiredCapabilities("firefox", "", Platform.ANY);
capabilities.setBrowserName("firefox");
FirefoxProfile profile = new ProfilesIni().getProfile("default");
capabilities.setCapability("firefox_profile", profile);
capabilities.setCapability(CapabilityType.LOGGING_PREFS, logging_preferences);
try {
driver = new RemoteWebDriver(new URL("http://" + selenium_host + ":" + selenium_port + "/wd/hub"), capabilities);
} catch (MalformedURLException ex) {
}
}
} else // standalone
{
if (selenium_browser.compareToIgnoreCase("chrome") == 0) {
System.setProperty("webdriver.chrome.driver", "c:/java/selenium/chromedriver.exe");
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
LoggingPreferences logging_preferences = new LoggingPreferences();
logging_preferences.enable(LogType.BROWSER, Level.ALL);
capabilities.setCapability(CapabilityType.LOGGING_PREFS, logging_preferences);
/*
prefs.js:user_pref("extensions.logging.enabled", true);
user.js:user_pref("extensions.logging.enabled", true);
*/
driver = new ChromeDriver(capabilities);
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
} else {
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
LoggingPreferences logging_preferences = new LoggingPreferences();
logging_preferences.enable(LogType.BROWSER, Level.ALL);
capabilities.setCapability(CapabilityType.LOGGING_PREFS, logging_preferences);
driver = new FirefoxDriver(capabilities);
}
}
try {
driver.manage().window().setSize(new Dimension(600, 800));
driver.manage().timeouts().pageLoadTimeout(50, TimeUnit.SECONDS);
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
} catch (Exception ex) {
System.out.println(ex.toString());
}
}
use of org.openqa.selenium.remote.DesiredCapabilities in project selenium_java by sergueik.
the class RecordSettingsBase method prepareRecord.
@Override
public void prepareRecord(int timeout) {
this.proxy = new BrowserMobProxySupplier(timeout, requestFilter, responseFilter).get();
Proxy seleniumProxy = new SeleniumProxySupplier(proxy).get();
DesiredCapabilities desiredCapabilities = new DesiredCapabilitiesSupplier(seleniumProxy).get();
this.driver = webDriverSupplier.get(desiredCapabilities);
this.driver.manage().window().maximize();
}
Aggregations