use of org.openqa.selenium.logging.LoggingPreferences in project Bytecoder by mirkosertic.
the class BytecoderUnitTestRunner method newDriverForTest.
private WebDriver newDriverForTest() {
ChromeOptions theOptions = new ChromeOptions();
theOptions.addArguments("headless");
theOptions.addArguments("disable-gpu");
LoggingPreferences theLoggingPreferences = new LoggingPreferences();
theLoggingPreferences.enable(LogType.BROWSER, Level.ALL);
theOptions.setCapability(CapabilityType.LOGGING_PREFS, theLoggingPreferences);
DesiredCapabilities theCapabilities = DesiredCapabilities.chrome();
theCapabilities.setCapability(ChromeOptions.CAPABILITY, theOptions);
return new RemoteWebDriver(DRIVERSERVICE.getUrl(), theCapabilities);
}
use of org.openqa.selenium.logging.LoggingPreferences in project jmeter-plugins by undera.
the class ChromeDriverConfig method createCapabilities.
Capabilities createCapabilities() {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(CapabilityType.PROXY, createProxy());
LoggingPreferences logPrefs = new LoggingPreferences();
logPrefs.enable(LogType.BROWSER, Level.ALL);
capabilities.setCapability(CapabilityType.LOGGING_PREFS, logPrefs);
if (isAndroidEnabled() || isHeadlessEnabled()) {
// Map<String, String> chromeOptions = new HashMap<String, String>();
// chromeOptions.put("androidPackage", "com.android.chrome");
ChromeOptions chromeOptions = new ChromeOptions();
if (isAndroidEnabled()) {
chromeOptions.setExperimentalOption("androidPackage", "com.android.chrome");
}
if (isHeadlessEnabled()) {
chromeOptions.addArguments("--headless");
}
capabilities.setCapability(ChromeOptions.CAPABILITY, chromeOptions);
}
return capabilities;
}
use of org.openqa.selenium.logging.LoggingPreferences 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.logging.LoggingPreferences in project scout.rt by eclipse.
the class SeleniumDriver method setUpDriver.
public static WebDriver setUpDriver() {
// web-driver executable
String webdriverChromeDriver = System.getProperty(ChromeDriverService.CHROME_DRIVER_EXE_PROPERTY);
if (StringUtility.isNullOrEmpty(webdriverChromeDriver)) {
webdriverChromeDriver = OS.isFamilyWindows() ? "/seleniumDrivers/chromedriver.exe" : "/seleniumDrivers/chromedriver";
}
File chromeDriver = new File(webdriverChromeDriver);
if (!chromeDriver.exists()) {
System.out.println("Chrome driver executable not found at path: " + chromeDriver);
URL webdriverChromeDriverResource = SeleniumDriver.class.getResource(webdriverChromeDriver);
if (webdriverChromeDriverResource != null) {
chromeDriver = new File(webdriverChromeDriverResource.getFile());
webdriverChromeDriver = chromeDriver.getAbsolutePath();
}
}
if (!StringUtility.matches(webdriverChromeDriver, ".+\\.exe", Pattern.CASE_INSENSITIVE) && chromeDriver.exists() && !chromeDriver.canExecute()) {
chromeDriver.setExecutable(true);
}
System.setProperty(ChromeDriverService.CHROME_DRIVER_EXE_PROPERTY, webdriverChromeDriver);
logProperty(ChromeDriverService.CHROME_DRIVER_EXE_PROPERTY, webdriverChromeDriver);
// log-file for web-driver
File tmpDir = new File(System.getProperty("java.io.tmpdir"));
File logFile = new File(tmpDir, "webdriver.log");
String logFilePath = logFile.getAbsolutePath();
System.setProperty(ChromeDriverService.CHROME_DRIVER_LOG_PROPERTY, logFilePath);
logProperty(ChromeDriverService.CHROME_DRIVER_LOG_PROPERTY, logFilePath);
// set web-driver in verbose mode
System.setProperty(ChromeDriverService.CHROME_DRIVER_VERBOSE_LOG_PROPERTY, "true");
logProperty(ChromeDriverService.CHROME_DRIVER_VERBOSE_LOG_PROPERTY, "true");
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
// Prepare options
ChromeOptions options = new ChromeOptions();
String chromeBinary = System.getProperty("chrome.binary");
logProperty("chrome.binary", chromeBinary);
if (StringUtility.hasText(chromeBinary)) {
options.setBinary(chromeBinary);
}
options.addArguments("--lang=en");
options.addArguments("--verbose");
options.addArguments("--disable-infobars");
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
// Set logging preferences (see BrowserLogRule)
LoggingPreferences logPrefs = new LoggingPreferences();
logPrefs.enable(LogType.BROWSER, Level.ALL);
capabilities.setCapability(CapabilityType.LOGGING_PREFS, logPrefs);
// TODO [7.0] BSH Remove workaround, when Chrome bug is fixed
// <WORKAROUND> https://bugs.chromium.org/p/chromedriver/issues/detail?id=1552
Map<String, String> env = new HashMap<>();
env.put("LANG", "en_US.UTF-8");
System.out.println("Using custom environment variables for driver: " + new JSONObject(env).toString(2));
RemoteWebDriver driver = new ChromeDriver(new ChromeDriverService.Builder().usingAnyFreePort().withEnvironment(// <--
env).build(), capabilities);
// RemoteWebDriver driver = new ChromeDriver(options)
// </WORKAROUND>
driver.manage().timeouts().setScriptTimeout(10000, TimeUnit.SECONDS);
// Set window size roughly to the minimal supported screen size
// (1280x1024 minus some borders for browser toolbar and windows taskbar)
// Add extra 50 pixel height, because of yellow bar "Chrome is being controlled..." which comes up since v 65.0.3325
// even tough the disable-infobars property is set - doesn't work anymore :-(
driver.manage().window().setPosition(new Point(0, 0));
driver.manage().window().setSize(new Dimension(1200, 900 + 50));
Capabilities caps = driver.getCapabilities();
System.out.println("Selenium driver configured with driver=" + driver.getClass().getName() + " browser.name=" + caps.getBrowserName() + " browser.version=" + caps.getVersion());
return driver;
}
use of org.openqa.selenium.logging.LoggingPreferences in project ghostdriver by detro.
the class LogTest method setCustomHeaders.
@BeforeClass
public static void setCustomHeaders() {
LoggingPreferences logPrefs = new LoggingPreferences();
logPrefs.enable(LogType.BROWSER, Level.ALL);
logPrefs.enable("har", Level.ALL);
sCaps.setCapability(CapabilityType.LOGGING_PREFS, logPrefs);
}
Aggregations