0
ECLIPSEは - リポジトリのプログラムオブジェクト -
を示すのNullPointerExceptionエラーは、オブジェクトリポジトリライブラリファイルを使用してSeleniumのプログラムの下に持っていますが、同じことは、失敗とjava.lang.NullPointerExceptionがを示しています。特定の構文行に「エラー」とコメントしました。また、エラーscreenshotとconfig.propertyファイルを添付してください。ここに画像の説明を入れてください。原因を特定しようとしましたが、できませんでした。失敗したエラーメッセージの原因を明確にしてください。
package objectrepository;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.WebDriver;
import org.testng.annotations.Test;
import objectrepository.Lib_ChromeDriver;
public class OBRClass_2 {
@Test
public void launch_chrome() throws Exception{
Lib_ChromeDriver LCD = new Lib_ChromeDriver();// Lib_ChromeDriver is the Object Repository Library File
System.setProperty("webdriver.chrome.driver", LCD.Path());// error shown
WebDriver Snap = new ChromeDriver();
Snap.get(LCD.AppURL());
}
}
と:あなたが呼び出しているコードは、あなたのコンストラクタではなくと呼ばれる方法ではありません
public void Lib_ChromeDriver() // not a constructor
public Lib_ChromeDriver() // is a constructor
に
// a Java Class containing Constructor & method and is saved as Library file.
// Constructor has will call the ObjectRepository File and
// method will call the Call the ChromeDriver Location to Launch the same
// this Library Class can be called in Selenium program to launch the Chrome Driver
package objectrepository;
import java.io.File;
import java.io.FileInputStream;
import java.util.Properties;
import org.testng.annotations.Test;
public class Lib_ChromeDriver {
Properties Prop;
@Test
public void Lib_ChromeDriver() throws Exception{// Constructor calling the Object Repository File
File OB_File = new File("./Config/Config.property");
FileInputStream OB_FIS = new FileInputStream(OB_File);
Prop = new Properties();
Prop.load(OB_FIS);
}
public String Path() throws Exception{// method calling the ChromeDriver Path to Launch the same
String ChromePath = Prop.getProperty("ChromeDriver"); // error shown
return ChromePath;
}
public String AppURL() throws Exception{
String AppURL = Prop.getProperty("URL");
return AppURL;
}
}
'Prop'は' null'なのであるに設定されることはありません。あなたはそれが 'ヌル 'ではないことを期待していますか? – nitind
@badri - 私の答えはあなたの問題に対処していますか? –
[コードのスクリーンショットは悪い考えです](https://meta.stackoverflow.com/questions/303812/discourage-screenshots-of-code-and-or-errors)の理由をお読みください。コードを貼り付け、正しくフォーマットします。 – JeffC