введите описание изображения здесь // Пакет базового класса com.IVAPP.qa.Base;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
public class BaseClass {
public static Properties prop;
public static WebDriver driver;
public BaseClass() throws IOException{
try{
prop = new Properties();
//prop.load(this.getClass().getResourceAsStream("C:\\Users\\Jomonli\\workspace\\IVAPP_Automation\\src\\main\\java\\com\\IVAPP\\qa\\Config\\Config.properties"));
FileInputStream ip = new FileInputStream(System.getProperty("C:\\Users\\Jomonli\\workspace\\IVAPP_Automation\\src\\main\\java\\com\\IVAPP\\qa\\Config\\Config.properties"));
prop.load(ip);
}catch(FileNotFoundException e){
e.printStackTrace();
}catch(IOException e){
e.printStackTrace();
}
}
public void intialization(){
// String browserName = prop.getProperty("browser");
//
// if(browserName.equals("IE")){
// System.setProperty("webdriver.ie.driver","C:\\Users\\Jomonli\\Desktop\\IEDriverServer_x64_3.14.0\\IEDriverServer.exe");
// //driver = new InternetExplorerDriver(); }
File file = new File("C:\\Users\\Jomonli\\Desktop\\IEDriverServer_x64_3.14.0\\IEDriverServer.exe");
System.setProperty("webdriver.ie.driver", file.getAbsolutePath());
driver = new InternetExplorerDriver();
driver.manage().window().maximize();
driver.get(prop.getProperty("url"));
}
}
Это базовый класс, который расширен до класса, который я пытаюсьзапустить.
LoginPageTest
package com.IVAPP.qa.OffShoreTestCases;
import java.io.IOException;
import org.openqa.selenium.WebDriver;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import com.IVAPP.qa.Base.BaseClass;
import com.IVAPP.qa.OffShorePage.HomePage;
import com.IVAPP.qa.OffShorePage.LoginPage;
public class LoginPageTest extends BaseClass {
LoginPage loginpage;
HomePage homePage;
WebDriver driver;
public LoginPageTest() throws IOException{
super();
}
@BeforeMethod
public void setUp() throws IOException{
intialization();
// String exePath = "C:\\Users\\Jomonli\\Desktop\\IEDriverServer_x64_3.14.0\\IEDriverServer.exe";
// //For use of IE only; Please enable for IE Browser
// System.setProperty("webdriver.ie.driver", exePath);
// driver = new InternetExplorerDriver();
this.loginpage =new LoginPage();
homePage = new HomePage();
}
@Test(description="Logging in with valid credentials")
public void LoginTest() throws IOException{
homePage = loginpage.login(prop.getProperty("UserID"), prop.getProperty("Password"));
}
@AfterMethod
public void teardown(){
driver.quit();
}
}
================================================================================================ Файл Testng.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite">
<test name="Test">
<classes>
<class name="com.IVAPP.qa.OffShoreTestCases.LoginPageTest"/>
</classes>
</test> <!-- Test -->
</suite> <!-- Suite -->
Это testng .xml, он указывает на правильный класс, который я пытаюсь запустить, но он говорит, что не может создать экземпляр класса. Это как-то связано с путем к драйверу.
Я попробовал Project> Clean> Update maven, изменил путь, написал другой код, но ничего не получилось
Exception errors
org.testng.TestNGException:
Cannot instantiate class com.IVAPP.qa.OffShoreTestCases.LoginPageTest
at org.testng.internal.ObjectFactoryImpl.newInstance(ObjectFactoryImpl.java:40)
at org.testng.internal.ClassHelper.createInstance1(ClassHelper.java:373)
at org.testng.internal.ClassHelper.createInstance(ClassHelper.java:285)
at org.testng.internal.ClassImpl.getDefaultInstance(ClassImpl.java:126)
at org.testng.internal.ClassImpl.getInstances(ClassImpl.java:191)
at org.testng.TestClass.getInstances(TestClass.java:104)
at org.testng.TestClass.initTestClassesAndInstances(TestClass.java:90)
at org.testng.TestClass.init(TestClass.java:82)
at org.testng.TestClass.<init>(TestClass.java:45)
at org.testng.TestRunner.initMethods(TestRunner.java:422)
at org.testng.TestRunner.init(TestRunner.java:252)
at org.testng.TestRunner.init(TestRunner.java:222)
at org.testng.TestRunner.<init>(TestRunner.java:171)
at org.testng.remote.support.RemoteTestNG6_9_10$1.newTestRunner(RemoteTestNG6_9_10.java:28)
at org.testng.remote.support.RemoteTestNG6_9_10$DelegatingTestRunnerFactory.newTestRunner(RemoteTestNG6_9_10.java:61)
at org.testng.SuiteRunner$ProxyTestRunnerFactory.newTestRunner(SuiteRunner.java:604)
at org.testng.SuiteRunner.init(SuiteRunner.java:170)
at org.testng.SuiteRunner.<init>(SuiteRunner.java:117)
at org.testng.TestNG.createSuiteRunner(TestNG.java:1359)
at org.testng.TestNG.createSuiteRunners(TestNG.java:1346)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1200)
at org.testng.TestNG.runSuites(TestNG.java:1124)
at org.testng.TestNG.run(TestNG.java:1096)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:132)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:236)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:81)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.testng.internal.ObjectFactoryImpl.newInstance(ObjectFactoryImpl.java:29)
... 25 more
Caused by: java.lang.NullPointerException
at java.util.Properties$LineReader.readLine(Unknown Source)
at java.util.Properties.load0(Unknown Source)
at java.util.Properties.load(Unknown Source)
at com.IVAPP.qa.Base.BaseClass.<init>(BaseClass.java:28)
at com.IVAPP.qa.OffShoreTestCases.LoginPageTest.<init>(LoginPageTest.java:23)
... 30 more
Это два исключения, которые яполучение