2017-02-02 1 views
-3

중간에 모든 스크립트를 실행할 때 NullPointerException을 얻는 중입니다. 나는 xpath을 속성 파일에 기록했으며 속성 파일은 BeforeSuite에로드하고 있습니다. 요소가 나타나고 페이지도 나타납니다. 로케이터에 null을 입력하십시오.특성 파일이 제대로로드되지 않습니다.

+0

이제 가이드를 통해 질문을 읽어보십시오. http://www.catb.org/~esr/faqs/smart-questions.html – FaithReaper

답변

0

귀하의 속성 파일은 귀하의 정확한 값을 제공하지 않을 수 있습니다. 속성 이름을 제공하여이 함수를 호출 해보십시오.

public static String getProperty(String propertyname) 
    { 
     Properties prop = new Properties(); 
     InputStream input = null; 
     try { 
      input = new FileInputStream(("path of your property file")); 

      // load a properties file 
      prop.load(input); 
     } catch (IOException ex) { 
      ex.printStackTrace(); 
     } finally { 
      if (input != null) { 
       try { 
        input.close(); 
       } catch (IOException e) { 
        e.printStackTrace(); 
       } 
      } 
     } 
     System.out.println(prop.getProperty(propertyname)); 
     //Return the property value 
     return prop.getProperty(propertyname); 

    } 
관련 문제