나는 상호 의존적이 여행 사이트 테스트 케이스는 1입니다) 로그인 2 일) 예약 3) 취소 등Webdriver TestNG를 NullPointer 예외
내가 Webdriver 때에 'NullPointer 예외'에 직면하고있다에서 말할 수 있습니다하기 TestNG을 testcases를 실행하려고 2 차 테스트에서 호출되었습니다 .. 또한 드라이버를 공개 정적으로 선언 했으므로 어떤 아이디어가 나옵니다. 속성 파일에서 로케이터를 읽습니다.
TestNG 버그입니까?
여기 .. 포인터 예외를 보려면 아래로 스크롤하십시오 내 코드의
공용 클래스 LoginTest {
public static WebDriver driver;
public static Properties p;
public static FileInputStream f ;
@Test
public void loginTest() {
System.out.println("Enter LoginTest");
Properties p=new Properties();
FileInputStream f = null;
try {
f = new FileInputStream("D:\\BOSSFramework\\Framework\\locators.properties");
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
p.load(f);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
WebDriver driver = new FirefoxDriver();
driver.get("https://in3.seatseller.travel/");
driver.manage().window().maximize();
// Login Process Starts here ..
try{
driver.findElement(By.name(p.getProperty("login.username.textfield"))).sendKeys("user");
driver.findElement(By.name(p.getProperty("login.password.textfield"))).sendKeys("password");
WebElement ele =driver.findElement(By.id(p.getProperty("login.signin.button")));
ele.click();
/*String classValue = ele.getAttribute("class");*/
}
catch (Exception e) {
}
}
@Test (dependsOnMethods={"loginTest"})
public void booking() throws InterruptedException{
System.out.println("Enter Booking");
// Type Bangalore on Source Field..
Properties p=new Properties();
FileInputStream f = null;
try {
f = new FileInputStream("D:\\BOSSFramework\\Framework\\locators.properties");
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
p.load(f);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
/*Null Pointer is on Below Line*/
WebDriverWait wait = new WebDriverWait(driver, 30);
wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath(p.getProperty("oneapp.source.textfield"))));
driver.findElement(By.xpath(p.getProperty("oneapp.source.textfield"))).sendKeys("Bangalore");
driver.findElement(By.xpath(p.getProperty("oneapp.source.textfield"))).sendKeys(Keys.TAB);
Thread.sleep(900L);
그럼 내 2 차 테스트에 드라이버 = 새로운 FirefoxDriver()를 추가하는 시도, 그것은 단지 – Himadri