Forum Discussion

mschofer's avatar
mschofer
Occasional Contributor
3 years ago

Python Pointer

Long time no posting. In Python what is the best way to extract information from tables.  I am able to find the values quite easily and write to variables.  Is beautiful soup the recommended route.?...
  • mschofer's avatar
    mschofer
    3 years ago

    I got it working

     

    def chechdetails():
    browser = Aliases.browser
    page = browser.Page("*")
    CurrPage = browser.Page("*")
    PropArray = ["ObjectType","ContentText"]
    ValuesArray = ["Cell",aqConvert.DateTimeToFormatStr("12/1/2021", "%m/%d/%Y")];

    myDateTable = page.FindChild(PropArray, ValuesArray,10)
    Log.Message(myDateTable.RowIndex)
    # for r in range(1, 999):
    # checkNum = currPage.FindElements("//form[@id='']/div/table/tbody/tr[" + str(r) + "]/td[1]")
    # if len(rowOfCells) == 0:
    # break
    # if checkNum.innerText == "CK" + marksCheckNumFromExcel:
    # targetRow = r
    # break
    # if targetRow == 0:
    # Log.Error("couldn't find check #")
    # else:
    myText21 = CurrPage.FindElement("//table[@border=1]/tbody/tr["+str(myDateTable.RowIndex + 1)+"]/td[3]/div/table/tbody/tr[2]/td[2]")
    if (myText21.Exists):
    Log.Message(myText21.contentText)
    myText22 = CurrPage.FindElement("//table[@border=1]/tbody/tr["+str(myDateTable.RowIndex + 1)+"]/td[3]/div/table/tbody/tr[3]/td[2]")
    if (myText22.Exists):
    Log.Message(myText22.contentText)
    myText23 = CurrPage.FindElement("//div[@id='amtDtl.0_2']/table/tbody/tr[4]/td[2]")
    if (myText23.Exists):
    Log.Message(myText23.contentText)
    myText24 = CurrPage.FindElement("//div[@id='amtDtl.0_2']/table/tbody/tr[5]/td[2]")
    if (myText24.Exists):
    Log.Message(myText24.contentText)
    myText25 = CurrPage.FindElement("//div[@id='amtDtl.0_2']/table/tbody/tr[6]/td[2]")
    if (myText25.Exists):
    Log.Message(myText25.contentText)
    myText26 = CurrPage.FindElement("//div[@id='amtDtl.0_2']/table/tbody/tr[7]/td[2]")
    if (myText26.Exists):
    Log.Message(myText26.contentText)
    # myText27 = CurrPage.FindElement("//div[@id='amtDtl.0_2']/table/tbody/tr[8]/td[2]")
    # if (myText27.Exists):
    # Log.Message(myText27.contentText)
    myText28 = CurrPage.FindElement("//div[@id='amtDtl.0_2']/table/tbody/tr[9]/td[2]")
    if (myText28.Exists):
    Log.Message(myText28.contentText)
    # myText29 = CurrPage.FindElement("//div[@id='amtDtl.0_2']/table/tbody/tr[10]/td[2]")
    # if (myText29.Exists):
    # Log.Message(myText29.contentText)