Я получаю ошибку Exception In Initializer в моем коде и не знаю, что делаю не так, пожалуйста, помогите! Я с радостью отвечу, если у вас есть какие-либо вопросы. Ниже приведена ошибка, которую я получаю от maven: [ERROR] Failures: [ERROR] Homepage_Test.startURL: 13-> BaseClass.globalDriver: 26 »ExceptionInInitializer.
//My Homepage_Test which includes all tests. startURL() invokes webdriver and runs to get website:
public class Homepage_Test extends BaseClass{
@BeforeTest
public void startURL() {
globalDriver();
}
@Test
public void search_product() {
Homepage_Methods.search_and_add();
}
@Test
public void verify_product_text() {
Homepage_Methods.verify_search();
}
@Test
public void scroll_down_page() {
Homepage_Methods.scroll_down_verify_text();
}
@AfterClass
public void clear_field() {
Homepage_Methods.clear_inputfield();
}
}
// My BaseClass:
public class BaseClass {
public static void globalDriver() {
System.setProperty("webdriver.gecko.driver" , System.getProperty("user.dir")+"/resources/geckodriver.exe");
WebDriver driver = new FirefoxDriver();
@SuppressWarnings("unused")
Shop_Page_Objects cpo = new Shop_Page_Objects(driver);
@SuppressWarnings("unused")
Homepage_Objects hpom = new Homepage_Objects(driver);
@SuppressWarnings("unused")
Shop_Page_Methods spm = new Shop_Page_Methods(driver);
@SuppressWarnings("unused")
Homepage_Methods hpm = new Homepage_Methods(driver);
DesiredCapabilities dc = new DesiredCapabilities();
FirefoxOptions options = new FirefoxOptions();
options.setHeadless(true);
dc.setCapability(FirefoxOptions.FIREFOX_OPTIONS,options);
driver.manage().timeouts().implicitlyWait(6000, TimeUnit.SECONDS);
driver.get("blabla website");
}
}
//Line 26 of BaseClass contains Shop_Page_Methods which is very long but here is the snippet:
public class Shop_Page_Methods extends BaseClass{
private static WebDriver driver;
public Shop_Page_Methods(WebDriver driver) {
Shop_Page_Methods.driver = driver ;
}
public static WebElement product_1_to_add_to_cart = Shop_Page_Objects.get_cart_product_1();
public static List<WebElement> all_products = Shop_Page_Objects.get_All_Products();
public static int products_count = Shop_Page_Objects.get_All_Products().size();
public static List<WebElement> all_price = Shop_Page_Objects.get_price();
public static String remove_number = Shop_Page_Objects.get_number_to_remove().getText();
public static String[] remover_1 = remove_number.split("");
public static int remove_number_1 = Integer.parseInt(remover_1[0]);