今天想试试用Java读取yaml文件,由于自己的粗心大意,搞了好长时间总是报错。还是其它同事一眼发现了问题,是少了一个冒号。记录一下,以后别犯这种低级错误啦。
Exception in thread "main" org.ho.yaml.exception.YamlException: Error near line 0: End of document expected.
at org.ho.yaml.JYamlParserEvent.error(Unknown Source)
at org.ho.yaml.YamlDecoder.firstDocument(Unknown Source)
at org.ho.yaml.YamlDecoder.readObjectOfType(Unknown Source)
at org.ho.yaml.YamlConfig.loadType(Unknown Source)
at org.ho.yaml.YamlConfig.loadType(Unknown Source)
at org.ho.yaml.Yaml.loadType(Unknown Source)
at com.test.yaml.baidu.PaserYamlDemo1.getDataMap(PaserYamlDemo1.java:25)
at com.test.yaml.baidu.Test.main(Test.java:11)
错误的yaml文件
demo_input:
des: username
xpath: %xpath%
demo_className:
des:use classname to locate element
className: han
超链接文本:
des: use linkText to locate element
linkText:easonhan.info
标签名称:
des:Locating elements in webdriver with tag name
tagName: input
xpath:
des:xpath sample
xpath: "//div[@id='input']/input"
RadioButton
des: RadioButton Sample
name: identity
RadioButton后面,少了一个冒号。