Esempio n. 1
0
def stockNumberAndchangeAndvolumeVerification(stock_change_volume):
    se2lib = BuiltIn().get_library_instance("Selenium2Library")
    driver = se2lib._current_browser()
    names=["Stock Number","change","volume"]
    locator= getLocator(stock_change_volume)
    locatorType= getLocatorType(stock_change_volume)
    liste=getElementList(driver,locator, locatorType)
    if len(liste)==0:
        BuiltIn().log("Stock Number and Volume and change elments do not exist",level="error")
        assert False==True
  
    elif len(liste)!=3:
        BuiltIn().log("Uncertain number of elements found ==>"+str(len(liste)),level="error")
        assert False==True
    else:
        result=True
        for i in range(3):
            if i!=0:
                if liste[i].text!="":
                    BuiltIn().log(names[i]+" Verification successful")
                else:
                    BuiltIn().log(names[i]+" Verification unsuccessful")
                    result=False
                    
            else:
                if liste[i].text!="$":
                    BuiltIn().log(names[i]+" Verification successful")
                else:
                    BuiltIn().log(names[i]+" Verification unsuccessful")
                    result=False
        if result:
            BuiltIn().log("Stock Number, change ad volume are accurate")
        else:
            BuiltIn().log("Stock Number, change ad volume are not accurate",level="error")
            assert True==False
Esempio n. 2
0
def verifyCloseDate(date_element):
    se2lib = BuiltIn().get_library_instance("Selenium2Library")
    driver = se2lib._current_browser()
    try:
        date_element_locator = getLocator(date_element)
        date_element_locatorType = getLocatorType(date_element)
        at_close_date_item_text = getElement(
            driver,
            locator=date_element_locator,
            locatorType=date_element_locatorType).text
        at_close_date_item = at_close_date_item_text[28::]
        BuiltIn().log("At close date " + at_close_date_item)
        at_close_date = datetime.strptime(at_close_date_item, "%Y/%m/%d")
        today_date = datetime.strptime(date.today().strftime("%Y/%m/%d"),
                                       "%Y/%m/%d")
        days_difference = (today_date - at_close_date).days
        if days_difference <= 7:
            BuiltIn().log("Date is accurate ==> Less than a week")
        else:
            BuiltIn().log("Date is not accurate ==> More than a week",
                          level="error")
            assert False == True
    except:
        BuiltIn().log("Unable to extract date", level="error")
        assert False == True
Esempio n. 3
0
def boxesVerification(box,question,popover):
    se2lib = BuiltIn().get_library_instance("Selenium2Library")
    driver = se2lib._current_browser()
    boxlocator=getLocator(box)
    boxlocatorType=getLocatorType(box)
    questionlocator=getLocator(question)
    questionlocatorType=getLocatorType(question)
    popoverlocator=getLocator(popover)
    popoverlocatorType=getLocatorType(popover)
    boxes_liste=getElementList(driver,boxlocator,boxlocatorType) 
    question_marks=getElementList(driver,questionlocator,questionlocatorType)      
    l=len(boxes_liste)
    if l!=6:
         BuiltIn().log("Boxes List contains uncertain number of elements==>"+str(l),level="error")
         assert False==True
    else:
        count=0
        j=0
        result=True
        for i in range(l-1):
            if (boxes_liste[i].text!="Fail") &  (boxes_liste[i].text!="Pass") & (boxes_liste[i].text!="Missing Data" ):
                BuiltIn().log("Text in box number "+str(i+1)+"is not accurate",level="error") 
                result= False
            elif boxes_liste[i].text=="Pass":
                count+=1
            elif boxes_liste[i].text=="Fail":
                if iselementClick(driver,element= question_marks[j]):
                    j+=1
                    if isElementPresent(driver,popoverlocator,popoverlocatorType)==False:
                         BuiltIn().log("Pop over in box number "+str(j+1)+"doesn't exist",level="error")
                         result= False
                else:
                     BuiltIn().log("Unable to click question mark number "+str(j+1),level="error")
                     result= False
    compliance_text=str(count)+"/5"
    if (boxes_liste[l-1].text == compliance_text) == False:
         BuiltIn().log("Compliance text is not acccurate",level="error")
         result= False
    if result:
        BuiltIn().log("Boxes verification is successful")
    else:
        BuiltIn().log("Boxes verification is unsuccessful",level="error")
        assert False==True
Esempio n. 4
0
def Title(title,companyname):
    se2lib = BuiltIn().get_library_instance("Selenium2Library")
    driver = se2lib._current_browser()
    titlelocator=getLocator(title)
    titlelocatorType=getLocatorType(title)
    try:
        title_element= getElement(driver,titlelocator,titlelocatorType)
        if title_element.text==companyname:
            return True
        else:
            return False
    except:
        BuiltIn().log("Unable to locate the title")
        return True #This function returns false only if the title is not exact not when it doesn't exist 
Esempio n. 5
0
def clickAddToPortfolioBtn(locator):
    se2lib = BuiltIn().get_library_instance("Selenium2Library")
    driver = se2lib._current_browser()
    btn_locator = getLocator(locator)
    btn_locatorType = getLocatorType(locator)
    number_tries = 0
    clicked = False
    while (number_tries < 5):
        number_tries += 1
        if iselementClick(driver,
                          locator=btn_locator,
                          locatorType=btn_locatorType):
            clicked = True
            break
    if clicked:
        BuiltIn().log("Add to portfolio btn is clicked successfully")
    else:
        BuiltIn().log("Unable to click Add to portfolio btn", level="error")
    assert clicked == True