Repeat Exists (Avoid Writing Log Errors) Python
This is a script I have pared down in the utter hope I can make my slf clear.
I an using different users in loops and some elements do not exist for certain users.
I am using exists to see if an item exists,
If it doesn't exist, it writes errors to the log.--I dont want this.
Documentations says to use this methodology.
if (Sys.Process("notepad").WaitWindow("#32770", "About Notepad", 1, 5000).Exists):
# Notepad is running
else:
# Notepad is not running
My code snippet
def a1():
try:
# # finds the link and verifies it exists on page
# myLinkXPath = "//a[text()='Purchase Inquiry']"
# myTestLink = JCCommon.verify_link(myLinkXPath)
# myTestLink.Click()
#
browser = Aliases.browser
CurrPage = browser.Page("*")
CurrPage.Wait()
myPT = CurrPage.FindElement("//font[.='Purchase Types']")
if myPT.Exists: -This works or throws an error if it doesn't exist.
Log.Message("I am the Rain Queen")
if myPT.WaitWindow("#32770","Wait Window",-1,10000).Exists: Per Documentation however this doesn't work.
Log.Message("Found Purchase Type Header")
else:
Log.Message('Not Found Purchase Type')
except Exception as e:
myErrMessage = JCCommon.capture_error(e)
Log.Error(myErrMessage)