How to use filterOutputDirectory method of com.paypal.selion.internal.platform.grid.SeleniumGridListener class

Best SeLion code snippet using com.paypal.selion.internal.platform.grid.SeleniumGridListener.filterOutputDirectory

Source:SeleniumGridListener.java Github

copy

Full Screen

...258 * @param suiteName259 * String suiteName specified by config file260 * @return String - path to output directory for that particular suite261 */262 public static String filterOutputDirectory(String base, String suiteName) {263 logger.entering(new Object[] { base, suiteName });264 int index = base.lastIndexOf(suiteName);265 String outputFolderWithoutName = base.substring(0, index);266 logger.exiting(outputFolderWithoutName + File.separator);267 return outputFolderWithoutName + File.separator;268 }269 /**270 * Closes selenium session when suite finished to run271 * 272 * @see org.testng.ISuiteListener#onFinish(org.testng.ISuite)273 */274 @Override275 public void onFinish(ISuite suite) {276 logger.entering(suite);277 if (ListenerManager.executeCurrentMethod(this) == false) {278 logger.exiting(ListenerManager.THREAD_EXCLUSION_MSG);279 return;280 }281 if (sessionMap != null && !sessionMap.isEmpty()) {282 if (logger.isLoggable(Level.FINE)) {283 logger.log(Level.FINE, "Thread " + Thread.currentThread().getId() + " finished Suite, Open Sessions = "284 + sessionMap.toString());285 }286 // This is NOT an optimal solution. But we need to find out some way to clear out all those sessions287 // which we ended up persisting or else the browser instances wont be cleaned up.288 Class<?>[] supportedAnnotations = TestSessionFactory.getSupportedAnnotations();289 for (Class<?> eachAnnotation : supportedAnnotations) {290 AbstractTestSession config = TestSessionFactory.newInstance(eachAnnotation);291 if (config.handleSessions()) {292 config.closeAllSessions(sessionMap);293 }294 }295 }296 LocalGridManager.shutDownHub();297 logger.exiting();298 }299 /**300 * 301 * @see org.testng.ISuiteListener#onFinish(org.testng.ISuite)302 */303 @Override304 public void onFinish(ITestContext context) {305 // Below conditional check needs to be invoked in all TestNG Listener interface implementation.306 // Failing to do so can have un-predictable results.307 if (ListenerManager.executeCurrentMethod(this) == false) {308 logger.exiting(ListenerManager.THREAD_EXCLUSION_MSG);309 return;310 }311 return;312 }313 /**314 * On start each suite initialize config object and report object315 */316 @Override317 public void onStart(ITestContext context) {318 logger.entering(context);319 if (ListenerManager.executeCurrentMethod(this) == false) {320 logger.exiting(ListenerManager.THREAD_EXCLUSION_MSG);321 return;322 }323 sessionMap = new HashMap<String, SeLionSession>();324 String testName = context.getCurrentXmlTest().getName();325 // initializing the ConfigSummaryData before initializers so that config details can be added.326 ConfigSummaryData.initLocalConfigSummary(testName);327 // We have to ensure that our configuration is the first thing that gets loaded.328 // Our loading mechanism is going to be via listeners. But the problem with TestNG listeners is329 // that the order of loading is never guaranteed. Things become complicated if our downstream consumers330 // want to piggy back on our configuration and want to have their configurations loaded as well.331 // Because of all these issues, we cannot rely on building a config specific listener.332 // So we are relying on the ServiceLoaders in Java to do it for us. The moment we are here, we ensure that333 // not only the SeLion specific configurations are loaded, but all downstream consumer's configurations334 // are loaded as well along with us. So SeLion now becomes the single point of initialization and thus335 // does away with all the inherent setbacks that are associated with TestNG listeners orders.336 invokeInitializersBasedOnPriority(context);337 ConfigManager.printConfiguration(testName);338 ISuite suite = context.getSuite();339 if (!suite.getParallel().equals("false") && logger.isLoggable(Level.FINE)) {340 logger.log(Level.FINE, "Parallel suite execution. Updating SeLion local config for Test, "341 + context.getCurrentXmlTest().getName());342 }343 String base = suite.getOutputDirectory();344 String suiteName = suite.getName();345 String rootFolder = filterOutputDirectory(base, suiteName);346 WebReporter.setTestNGOutputFolder(rootFolder);347 WebReporter.init();348 logger.exiting();349 }350 @Override351 public void onTestFailedButWithinSuccessPercentage(ITestResult result) {352 // Below conditional check needs to be invoked in all TestNG Listener interface implementation.353 // Failing to do so can have un-predictable results.354 if (ListenerManager.executeCurrentMethod(this) == false) {355 logger.exiting(ListenerManager.THREAD_EXCLUSION_MSG);356 return;357 }358 return;359 }...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful