Before class & after class not working with Selenium web driver

I am writing functional test cases using Selenium+Cucumber

I would like to place the following code in BeforeClass

System.setProperty("webdriver.chrome.driver","<somepath>\\chromedriver.exe");
driver = new ChromeDriver();

I tried to place the Before class both in Super class and in same class as well. But it doesnt get fired. What is the reason ?

  1. BeforeClass in super class

    public class Super_Steps {
        @BeforeClass    
        public static void beforeClass() {
            System.out.println("Before class");
        }
    ..
    }
    
    public class Login_Steps extends Super_Steps  {
    ..
    
  2. BeforeClass in same class

    public class Login_Steps {
        @BeforeClass
        public static void beforeClass() {
            System.out.println("Before class");
        }
    ...
    }
    

Answers


There is no restriction for using @BeforeClass in superclasses. According to the JUnit api: "The @BeforeClass methods of superclasses will be run before those the current class." Possibly double check if you have imported in the superclass junit.BeforeClass:

import org.junit.BeforeClass;

Need Your Help

CSS multiple different height float left elements arranged in 2 columns

javascript html css angularjs

this is a problem with white spaces: I have multiple, float:left elements, that I need arranged in 2 columns, and, they all have different heights.