i have a class Test1 where i use this line to click on a button:
try{
driver.findElement (By.xpath(Component._emp)).click();
System.out.println("Employment is clicked");
} catch (NoSuchElementException e17) {
System.out.println("Employment is not found [TEST FAILED]");
}
And another class named Util, in this class i copied the code above like this:
public static void click_person_employment(){
try{
driver.findElement (By.xpath(Component._emp)).click();
System.out.println("Employment is clicked");
} catch (NoSuchElementException e17) {
System.out.println("Employment is not found [TEST FAILED]");
}
}
So in my class Test1 when i call like this: Util.click_person_employment()
it throws java.lang.Nullpointer exception
Whta is the proper way to call this method. My goal is to reduce code in my class Test1 because i have more than 100 buttons to click. Thank you