Softasserts in TestNG

  • 29
    Aug

    Softasserts in TestNG

    There are two types of Assert: 1. Hard Assert => script execution stops (on failure of such asserts) 2. Soft Assert => script execution continues (on failure of such...

    Read More
  • 28
    Aug

    Set functions in Java

    package Set; import java.util.Arrays; import java.util.HashSet; import java.util.Iterator; import java.util.Set; import java.util.Spliterator; public class SetsExamples { static Set initSet1() { Set set1 = new HashSet(Arrays.asList(11,12,13,14,15)); return set1; } static...

    Read More
  • 24
    Aug

    Get free disk space from Java program

    Following code snippet can be used to find the free disk space on local file system import java.io.File; public class FreediskspaceinGB { public static void main(String args) { File...

    Read More
  • 24
    Aug

    kill a running process from your java program (in Windows)

    Following code snippet can be used to kill a process on windows system package practice; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class WindowsProcessKiller { // command used to...

    Read More
  • 23
    Aug

    Code snippet to execute dos command and process it’s result – (Find open TCP Ports on local system)

    package practice; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class freeport { public static void main(String args) { try { Runtime rt = Runtime.getRuntime(); String command = “netstat -an”;...

    Read More
  • 22
    Aug

    Generate HTML / XML logs with log4j

    In order to generate log4j logs in XML or HTML format one can configure log4j.properties file with following properties: log4j.rootLogger=DEBUG, CA log4j.appender.CA=org.apache.log4j.ConsoleAppender log4j.appender.CA.layout=org.apache.log4j.HTMLLayout log4j.appender.CA.layout.ConversionPattern=%-4r [%t] %-5p %c %x –...

    Read More
  • 22
    Aug

    Configure log4j to write logs to local filesystem – FileAppender

    Three main components that needs to be configured in log4j.properties file are: 1. logger => log messages. 2. appender => specifies the output destination like console or a file....

    Read More
  • 21
    Aug

    How to configure your log4j.properties file in Eclipse

    Step 1: Create a log4j.properties file (eg.) # Set root category priority to INFO and its only appender to CONSOLE. log4j.rootCategory=INFO, CONSOLE #log4j.rootCategory=INFO, CONSOLE, LOGFILE # Set the enterprise...

    Read More
  • 21
    Aug

    How to convert an Array as Map in java

    Following code snippet can be used to convert an Array to Map in java import org.apache.commons.lang3.ArrayUtils; import java.util.Map; import java.util.Map.Entry; import java.util.Set; public class ArraysToMap { public static void...

    Read More
  • 20
    Aug

    how to handle Untrusted sites in Selenium webdriver

    // Create DesiredCapabilities class object DesiredCapabilities cap=DesiredCapabilities.chrome(); // Set ACCEPT_SSL_CERTS variable to true cap.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true); // Set the driver path System.setProperty(“webdriver.chrome.driver”,”Chrome driver path”); // Open browser with capability WebDriver...

    Read More