SilkTest Question 23: How to set up proxy setting with 4test code?

In preparation for QA interview I try to develop script for setting up proxy server for Internet Explorer 6.0. So far I found two windows registry keys where proxy data are located on my Microsoft Windows XP testing machine.

I may turn proxy server on or off with 1 or 0 modifying
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyEnable

I may define proxy server ip and port modifying
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyServer

What to do next?


The code below contain Silk Test code for turning on specified proxy server and as your home work for QA interview you can easily modify script for turning off proxy server. By the way before you change the registry, make sure to back it up and make sure that you or someone else in your company know how to restore the registry if a problem occurs or play with this script only on test environment.

[ ] // Turns on specified proxy
[ ] // sProxyName -> ip:port
[+] configureProxyServer(STRING sProxyName)
[ ]
[ ] integer iKey = HKEY_CURRENT_USER
[ ] string sPath = "Software\Microsoft\Windows\CurrentVersion\Internet Settings\"
[ ] string sProxyServer = "ProxyServer"
[ ] string sProxyEnable = "ProxyEnable"
[ ] string sProxyOn = "REG_DWORD: 0x00000001"
[-] do
[ ] SYS_GetRegistryValue(iKey, sPath, sProxyServer, TRUE)
[ ] SYS_SetRegistryValue(iKey, sPath, sProxyServer, sProxyName)
[-] except
[ ] Reg_CreateValue(iKey, sPath, sProxyServer, serverName)
[ ]
[-] do
[ ] SYS_GetRegistryValue(iKey, sPath, sProxyServer, TRUE)
[ ] SYS_SetRegistryValue(iKey, sPath, sProxyEnable, sProxyOn)
[-] except
[ ] Reg_CreateValue(iKey, sPath, sProxyEnable, sProxyOn)
[ ]
[ ]

No comments:

SilkTest interview questions for QA Testers