Updating Environment Variable, UFT fails test even though PATH is updated when viewing manually
Question ID: 105492

We have 2 tests in our test set. One installs an application, the second one verifies that the install happened properly.

Test 1 updates the Windows PATH environment variable.

Test 2 verifies the installation by running a verification program. This program depends on the updates to the PATH environment variable being made. This is failing EVERY time, but when we check manually, the PATH variable has been updated. How do we fix this??

Marked as spam
Posted by (Questions: 386, Answers: 64)
Asked on July 10, 2014 8:52 pm
Answers (1)
Private answer

When an application is launched, it grabs the current value of all environment variables and stores them in a cache for use. When the installer from the first test updates the PATH variable, UFT can't 'see' that update. You have to close UFT (and probably the remote agent too) and restart it to get it to recognize the new value.

One way to work around this, manually add the required path to the Path variable resident in memory. The code would look something like this:

Set wshShell = CreateObject(''WScript.Shell'')

Set WshSysEnv = WshShell.Environment(''SYSTEM'')

msgbox WshSysEnv(''Path'') ' Displays current Path value

WshSysEnv(''Path'') = WshSysEnv(''Path'') & ''; C:MyNewPath''

msgbox WshSysEnv(''Path'') 'displays updated Path value

Marked as spam
Posted by (Questions: 16, Answers: 807)
Answered on July 10, 2014 8:53 pm
Worked great! thanks!
( at July 10, 2014 8:54 pm)

Welcome back to "EyeOnTesting" brought to you by Orasi Software, Inc.

Scroll to Top