Forum Discussion

MarkSchofer's avatar
MarkSchofer
Frequent Contributor
4 years ago

Find Child Method -Doing 2 different Things

In the code below = I am able to click on the object Consistently however when Ito write it to the log it "errors" on the  else statement as if the object does not exist. 

It seems like I am doing the same thing twice and getting a different result.

def CheckRequestPersonEnhanced():
myChRequest = ' '
PropArray = ["ObjectType","contentText"]
ValuesArray = ["Link","Browse Check Request - Person"];
#Log.Message(ValuesArray)
browser = Aliases.browser
page = browser.Page("*")
page.FindChild(PropArray, ValuesArray,10).click()
myChRequest = page.FindChild(PropArray, ValuesArray,10)
if (myChRequest.exists):
Log.Message("Success Check Detail")
else:
Log.Message("Processing Exemptions")
sPath = "C:\\Users\\Schofem\\Logs\\BadChecks.txt"
# Creates a text file at the specified location
aqFile.Create(sPath)
# Opens the created file for writing
myFile = aqFile.OpenTextFile(sPath, aqFile.faWrite, aqFile.ctUnicode)
# Writes text to the file
myFile.WriteLine(aqDateTime.Now())
# myFile.WriteLine(DDT.CurrentDriver.Value[0])
# myFile.WriteLine(DDT.CurrentDriver.Value[26])
# myFile.WriteLine(DDT.CurrentDriver.Value[27])

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi,

     

    page.FindChild(PropArray, ValuesArray,10).click()

    What happens in the tested application, especially, with the link been clicked, after the click?

    If the link is removed from the page then subsequent .FindChild() will not find it and test code will proceed to the 'else:' block.

     

    • MarkSchofer's avatar
      MarkSchofer
      Frequent Contributor

      Sorry to be remiss as I get working on other things. In the application the click works fine and then it goes into the else. 
      I I can run it 20 times and it will work correctly most of the time and then it errors. Specifically -it clicks the ling and capriciously errors