QTP调用外部环境变量运行问题
Dim EnvironmentPathEnvironmentPath="D:\EnvLib.xml"
Call createEnvironmentXML(EnvironmentPath)
Environment.LoadFromFile EnvironmentPath
URL=Environment.Value("netUrl")
SystemUtil.Run URL
Function createEnvironmentXML(xmlPath)
Set fso=CreateObject("Scripting.FileSystemobject")
Set oXml=fso.CreateTextFile(xmlPath)
oXml.Write
"<Environment>"+vbCrLf+_
"<Variable>"+vbCrLf+_
"<Name>netName</Name>"+vbCrLf+_
"<Value>baidu</Value>"+vbCrLf+_
"</Variable>"+vbCrLf+_
"<Variable>"+vbCrLf+_
"<Name>netUrl</Name>"+vbCrLf+_
"<Value>http://www.baidu.com</Value>"+vbCrLf+_
"</Variable>"+vbCrLf+_
"</Environment>"
Set oXml=nothing
Set fso=nothing
End Function
执行不过去,总提示Environment 语法错误。 我运行了一下你的代码,也执行不过去,但并没有提示lz所谓的Environment 语法错误,查看后,将写入的内容改了一下,就可以了。
oXml.Write "<Environment>"+vbCrLf+ "<Variable>"+vbCrLf+"<Name>netName</Name>"+vbCrLf+ "<Value>baidu</Value>"+vbCrLf+"</Variable>"+vbCrLf+"<Variable>"+vbCrLf+ "<Name>netUrl</Name>"+vbCrLf+ "<Value>http://www.baidu.com</Value>"+vbCrLf+"</Variable>"+vbCrLf+ "</Environment>"
页:
[1]