【问题标题】:Propert file is not loading properly属性文件未正确加载
【发布时间】:2017-02-02 09:50:18
【问题描述】:

在中间运行我的所有脚本时获取NullPointerException。我在属性文件中写入了xpath,我正在将属性文件加载到BeforeSuite 中。元素将出现,页面也将出现。在定位器中获取null

【问题讨论】:

标签: java selenium


【解决方案1】:

可能是您的属性文件没有给出您元素的确切值。 尝试通过提供属性名称来调用此函数。

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);

    } 

【讨论】:

    猜你喜欢
    • 2014-12-09
    • 2014-07-21
    • 2021-06-25
    • 2023-04-03
    • 2013-01-15
    • 2020-12-16
    • 1970-01-01
    • 2023-03-04
    相关资源
    最近更新 更多