jmcpeek
12 years agoContributor
waitbrowser.exists not consistent
I'm trying to create a pretty straight-forward function that takes in a browser name against which to run a test, close the browser if it's open, and launch the browser. However when I run the code below, I get a different result each time. You'll see I have a check to see if the browser exists and if so, I log an event. Then after that I call a function that has the exact same IF that closes the browser if open. Yes, I know the call to close the browser should be in the IF, not after it, but there is a reason...
projectsuite.variables.browser = "IE"
if projectsuite.variables.browser = "IE" then
browsername = """iexplore"""
else
browsername = """" & projectsuite.variables.browser & """"
end if
statement = "sys.waitbrowser("& browsername &")"
if eval(statement).exists then
log.event projectsuite.variables.browser & " is already open. Closing it and reopening..."
end if
call forceBrowserClose(statement)
runstatement = "Browsers.Item("& browsername &")"
Call eval(runstatement).Run()
I ran this exact chunk of code 10 times with IE open.
nothing happened. no event, no close/re-open of IE
nothing happened. no event, no close/re-open of IE
nothing happened. no event, no close/re-open of IE
worked as expected, logged event and closed/re-opened IE
closed/re-opened IE, but didn't log event
closed/re-opened IE, but didn't log event
nothing happened. no event, no close/re-open of IE
nothing happened. no event, no close/re-open of IE
worked as expected, logged event and closed/re-opened IE
closed/re-opened IE, but didn't log event
I know the evals are odd, but it was the only way I could get it to work without an actual error.
Any ideas on why this might be happening?