我正在使用selenium自动化。我需要在运行时更新GUI.properties键值对。我尝试了以下代码,但没有反映变化。
Properties p = new Properties();
try {
p.load(PropertyMap.class.getResourceAsStream("/gui.properties"));
p.setProperty(key, value);
return p;
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
在调用方法中,我这样调用
PropertyMap.setProperties("SoftwareLifecycleStage.Selectors", "Concept");
clickOnFieldIfValueIsNotNull(getSelectorsXPath(properties.getProperty("Myssi.SoftwareLifecycleStage.Selectors")), "LifecycleStageSelectors");
上述方法clickonfieldifvalueisnotnull
是一种通用方法,只需按xpath
点击给定元素,getSelectorsXPath
只需提供该元素的xpath
。
我也试过以下代码......
Properties p = new Properties();
try {
PropertiesConfiguration config = new PropertiesConfiguration("src/test/resources/gui.properties");
config.setProperty(key, value);
} catch (ConfigurationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
请帮帮我吗?
更新: -
添加
Config.save(); 为我工作...但我面临的问题是保存文件后,我已经给出了Thread.sleep(2000);仅反映更改,但它没有获取下一行的更改值。我尝试删除thread.sleep,但同样重复....执行测试后,我检查了gui.properties,相应的值已经改变...
答案 0 :(得分:1)
你需要调用config.save();最后的方法?
GET /_analyze?analyzer=standard&text=-this is
{
"tokens": [
{
"token": "this",
"start_offset": 1,
"end_offset": 5,
"type": "<ALPHANUM>",
"position": 1
},
{
"token": "is",
"start_offset": 6,
"end_offset": 8,
"type": "<ALPHANUM>",
"position": 2
}
]
}
GET /_analyze?analyzer=standard&text=---------this is
{
"tokens": [
{
"token": "this",
"start_offset": 9,
"end_offset": 13,
"type": "<ALPHANUM>",
"position": 1
},
{
"token": "is",
"start_offset": 14,
"end_offset": 16,
"type": "<ALPHANUM>",
"position": 2
}
]
}