use of org.openqa.selenium.logging.LoggingPreferences in project blueocean-plugin by jenkinsci.
the class AthModule method configure.
@Override
protected void configure() {
Config cfg = new Config();
File userConfig = new File(new File(System.getProperty("user.home")), ".blueocean-ath-config");
if (userConfig.canRead()) {
cfg.loadProps(userConfig);
}
bind(Config.class).toInstance(cfg);
String webDriverType = cfg.getString("webDriverType");
MutableCapabilities capability;
if ("firefox".equals(webDriverType)) {
capability = new FirefoxOptions();
} else {
capability = new ChromeOptions();
}
LoggingPreferences logPrefs = new LoggingPreferences();
logPrefs.enable(LogType.BROWSER, Level.ALL);
capability.setCapability(CapabilityType.LOGGING_PREFS, logPrefs);
String webDriverUrl = cfg.getString("webDriverUrl", "http://localhost:4444/wd/hub");
String webDriverBrowserSize = cfg.getString("webDriverBrowserSize");
try {
String launchUrl = cfg.getString("jenkinsUrl");
if (launchUrl == null) {
launchUrl = new String(Files.readAllBytes(Paths.get("runner/.blueocean-ath-jenkins-url")));
}
capability.setCapability("extendedDebugging", "true");
capability.setCapability("initialBrowserUrl", launchUrl);
if (!StringUtils.isBlank(cfg.getString("TUNNEL_IDENTIFIER"))) {
capability.setCapability("tunnelIdentifier", cfg.getString("TUNNEL_IDENTIFIER"));
}
WebDriver driver = new RemoteWebDriver(new URL(webDriverUrl), capability);
LocalDriver.setCurrent(driver);
driver = new Augmenter().augment(driver);
if (webDriverBrowserSize == null) {
driver.manage().window().maximize();
} else {
String[] widthXHeight = webDriverBrowserSize.split("x");
driver.manage().window().setSize(new Dimension(Integer.parseInt(widthXHeight[0]), Integer.parseInt(widthXHeight[1])));
}
driver.manage().deleteAllCookies();
bind(WebDriver.class).toInstance(driver);
bindConstant().annotatedWith(BaseUrl.class).to(launchUrl);
LocalDriver.setUrlBase(launchUrl);
JenkinsUser admin = new JenkinsUser(cfg.getString("adminUsername", "alice"), cfg.getString("adminPassword", "alice"));
bind(JenkinsUser.class).toInstance(admin);
CustomJenkinsServer server = new CustomJenkinsServer(new URI(launchUrl), admin);
bind(JenkinsServer.class).toInstance(server);
bind(CustomJenkinsServer.class).toInstance(server);
if (server.getComputerSet().getTotalExecutors() < 10) {
server.runScript("jenkins.model.Jenkins.get().setNumExecutors(10);\n" + "jenkins.model.Jenkins.get().save();\n", true);
}
Properties properties = new Properties();
File liveProperties = new File("live.properties");
if (liveProperties.canRead()) {
properties.load(new FileInputStream(liveProperties));
}
bind(Properties.class).annotatedWith(Names.named("live")).toInstance(properties);
} catch (Exception e) {
LocalDriver.destroy();
throw new RuntimeException(e);
}
install(new FactoryModuleBuilder().implement(ActivityPage.class, ActivityPage.class).build(ActivityPageFactory.class));
install(new FactoryModuleBuilder().implement(MultiBranchPipeline.class, MultiBranchPipeline.class).build(MultiBranchPipelineFactory.class));
install(new FactoryModuleBuilder().implement(FreestyleJob.class, FreestyleJob.class).build(FreestyleJobFactory.class));
install(new FactoryModuleBuilder().implement(ClassicPipeline.class, ClassicPipeline.class).build(ClassicPipelineFactory.class));
install(new FactoryModuleBuilder().implement(RunDetailsPipelinePage.class, RunDetailsPipelinePage.class).build(RunDetailsPipelinePageFactory.class));
install(new FactoryModuleBuilder().implement(RunDetailsArtifactsPage.class, RunDetailsArtifactsPage.class).build(RunDetailsArtifactsPageFactory.class));
install(new FactoryModuleBuilder().implement(RunDetailsTestsPage.class, RunDetailsTestsPage.class).build(RunDetailsTestsPageFactory.class));
install(new FactoryModuleBuilder().implement(BranchPage.class, BranchPage.class).build(BranchPageFactory.class));
install(new FactoryModuleBuilder().implement(PullRequestsPage.class, PullRequestsPage.class).build(PullRequestsPageFactory.class));
}
use of org.openqa.selenium.logging.LoggingPreferences in project selenium-tests by Wikia.
the class BrowserAbstract method setBrowserLogging.
protected void setBrowserLogging(Level logLevel) {
LoggingPreferences loggingprefs = new LoggingPreferences();
loggingprefs.enable(LogType.BROWSER, logLevel);
caps.setCapability(CapabilityType.LOGGING_PREFS, loggingprefs);
}
use of org.openqa.selenium.logging.LoggingPreferences in project NoraUi by NoraUi.
the class DriverFactory method setLoggingLevel.
/**
* Sets the logging level of the generated web driver.
*
* @param caps
* The web driver's capabilities
* @param level
* The logging level
*/
private void setLoggingLevel(DesiredCapabilities caps) {
final LoggingPreferences logPrefs = new LoggingPreferences();
logPrefs.enable(LogType.BROWSER, Level.ALL);
logPrefs.enable(LogType.CLIENT, Level.OFF);
logPrefs.enable(LogType.DRIVER, Level.OFF);
logPrefs.enable(LogType.PERFORMANCE, Level.OFF);
logPrefs.enable(LogType.PROFILER, Level.OFF);
logPrefs.enable(LogType.SERVER, Level.OFF);
caps.setCapability(CapabilityType.LOGGING_PREFS, logPrefs);
}
use of org.openqa.selenium.logging.LoggingPreferences in project Bytecoder by mirkosertic.
the class BytecoderMavenMojo method wat2wasm.
private int[] wat2wasm(WASMCompileResult aResult) throws IOException {
String theChromeDriverBinary = System.getenv("CHROMEDRIVER_BINARY");
if (theChromeDriverBinary == null || theChromeDriverBinary.isEmpty()) {
throw new RuntimeException("No chromedriver binary found! Please set CHROMEDRIVER_BINARY environment variable!");
}
ChromeDriverService.Builder theDriverServiceBuilder = new ChromeDriverService.Builder();
theDriverServiceBuilder = theDriverServiceBuilder.withVerbose(false);
theDriverServiceBuilder = theDriverServiceBuilder.usingDriverExecutable(new File(theChromeDriverBinary));
ChromeDriverService theDriverService = theDriverServiceBuilder.build();
theDriverService.start();
File theTempDirectory = Files.createTempDir();
File theGeneratedFile = new File(theTempDirectory, "compile.html");
// Copy WABT Tools
File theWABTFile = new File(theTempDirectory, "libwabt.js");
try (FileOutputStream theOS = new FileOutputStream(theWABTFile)) {
IOUtils.copy(getClass().getResourceAsStream("/libwabt.js"), theOS);
}
PrintWriter theWriter = new PrintWriter(theGeneratedFile);
theWriter.println("<html>");
theWriter.println(" <body>");
theWriter.println(" <h1>Module code</h1>");
theWriter.println(" <pre id=\"modulecode\">");
theWriter.println(aResult.getData());
theWriter.println(" </pre>");
theWriter.println(" <h1>Compilation result</h1>");
theWriter.println(" <pre id=\"compileresult\">");
theWriter.println(" </pre>");
theWriter.println(" <script src=\"libwabt.js\">");
theWriter.println(" </script>");
theWriter.println(" <script>");
theWriter.println(" function compile() {");
theWriter.println(" console.log('Compilation started');");
theWriter.println(" try {");
theWriter.println(" var module = wabt.parseWat('test.wast', document.getElementById(\"modulecode\").innerText);");
theWriter.println(" module.resolveNames();");
theWriter.println(" module.validate();");
theWriter.println(" var binaryOutput = module.toBinary({log: true, write_debug_names:true});");
theWriter.println(" document.getElementById(\"compileresult\").innerText = binaryOutput.log;");
theWriter.println(" return binaryOutput.buffer;");
theWriter.println(" } catch (e) {");
theWriter.println(" document.getElementById(\"compileresult\").innerText = e.toString();");
theWriter.println(" console.log(e.toString());");
theWriter.println(" console.log(e.stack);");
theWriter.println(" }");
theWriter.println(" }");
theWriter.println(" </script>");
theWriter.println(" </body>");
theWriter.println("</html>");
theWriter.flush();
theWriter.close();
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);
RemoteWebDriver theDriver = new RemoteWebDriver(theDriverService.getUrl(), theCapabilities);
theDriver.get(theGeneratedFile.toURI().toURL().toString());
ArrayList<Long> theResult = (ArrayList<Long>) theDriver.executeScript("return compile();");
int[] theBinaryDara = new int[theResult.size()];
for (int i = 0; i < theResult.size(); i++) {
long theLongValue = theResult.get(i);
theBinaryDara[i] = (int) (theLongValue);
}
List<LogEntry> theAll = theDriver.manage().logs().get(LogType.BROWSER).getAll();
for (LogEntry theEntry : theAll) {
System.out.println(theEntry.getMessage());
}
theDriver.close();
theDriverService.stop();
return theBinaryDara;
}
use of org.openqa.selenium.logging.LoggingPreferences in project chrome_page_performance_sqlite_java by sergueik.
the class ChromePagePerformanceUtilTest method beforeClass.
@SuppressWarnings("deprecation")
@BeforeClass
public static void beforeClass() throws IOException {
getOsName();
System.setProperty("webdriver.chrome.driver", osName.toLowerCase().startsWith("windows") ? new File("c:/java/selenium/chromedriver.exe").getAbsolutePath() : "/var/run/chromedriver");
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
ChromeOptions options = new ChromeOptions();
Map<String, Object> chromePrefs = new HashMap<>();
chromePrefs.put("profile.default_content_settings.popups", 0);
String downloadFilepath = System.getProperty("user.dir") + System.getProperty("file.separator") + "target" + System.getProperty("file.separator");
chromePrefs.put("download.default_directory", downloadFilepath);
chromePrefs.put("enableNetwork", "true");
options.setExperimentalOption("prefs", chromePrefs);
for (String option : (new String[] { "allow-running-insecure-content", "allow-insecure-localhost", "enable-local-file-accesses", "disable-notifications", /* "start-maximized" , */
"browser.download.folderList=2", "--browser.helperApps.neverAsk.saveToDisk=image/jpg,text/csv,text/xml,application/xml,application/vnd.ms-excel,application/x-excel,application/x-msexcel,application/excel,application/pdf", String.format("browser.download.dir=%s", downloadFilepath) /* "user-data-dir=/path/to/your/custom/profile" , */
})) {
options.addArguments(option);
}
// options for headless
if (headless) {
// headless option arguments
for (String option : (osName.toLowerCase().startsWith("windows")) ? new String[] { "headless", "disable-gpu", "disable-plugins", "window-size=1200x600", "window-position=-9999,0" } : new String[] { "headless", "disable-gpu", "remote-debugging-port=9222", "window-size=1200x600" }) {
options.addArguments(option);
}
// on Windows need ChromeDriver 2.31 / Chrome 60 to support headless
// With earlier versions of chromedriver: chrome not reachable...
// https://developers.google.com/web/updates/2017/04/headless-chrome
// https://stackoverflow.com/questions/43880619/headless-chrome-and-selenium-on-windows
}
//
if (useChromeLogging) {
LoggingPreferences loggingPreferences = new LoggingPreferences();
loggingPreferences.enable(LogType.PERFORMANCE, Level.ALL);
capabilities.setCapability(CapabilityType.LOGGING_PREFS, loggingPreferences);
}
capabilities.setBrowserName(DesiredCapabilities.chrome().getBrowserName());
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
driver = new ChromeDriver(capabilities);
assertThat(driver, notNullValue());
}
Aggregations