51Testing软件测试论坛
标题:
QTP调用外部环境变量运行问题
[打印本页]
作者:
bingbingyang11
时间:
2015-2-15 16:29
标题:
QTP调用外部环境变量运行问题
Dim EnvironmentPath
EnvironmentPath="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 语法错误。
作者:
Charles_H
时间:
2015-2-28 10:57
我运行了一下你的代码,也执行不过去,但并没有提示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>"
欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/)
Powered by Discuz! X3.2