2017-08-10 1 views
0

enter image description hereECLIPSEは - リポジトリのプログラムオブジェクト -

を示すのNullPointerExceptionエラーは、オブジェクトリポジトリライブラリファイルを使用してSeleniumのプログラムの下に持っていますが、同じことは、失敗とjava.lang.NullPointerExceptionがを示しています。特定の構文行に「エラー」とコメントしました。また、エラーscreenshotとconfig.propertyファイルを添付してください。ここに画像の説明を入れてください。原因を特定しようとしましたが、できませんでした。失敗したエラーメッセージの原因を明確にしてください。 enter image description here

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; 
} 
} 
+0

'Prop'は' null'なのであるに設定されることはありません。あなたはそれが 'ヌル 'ではないことを期待していますか? – nitind

+0

@badri - 私の答えはあなたの問題に対処していますか? –

+0

[コードのスクリーンショットは悪い考えです](https://meta.stackoverflow.com/questions/303812/discourage-screenshots-of-code-and-or-errors)の理由をお読みください。コードを貼り付け、正しくフォーマットします。 – JeffC

答えて

0

変更210

は、この場合、あなたのコードがそれに任意のコードを持っていませんdefaultコンストラクタを呼び出している - したがって、変数Props

関連する問題