from time import sleep
from Common.selenium_wrapper import selenium_wrapper

class page_AddComp():
    def __init__(self):
        self.varSelWrap = selenium_wrapper.wrapper()
        self.lnkAddComp = "link=add your competencies,"
        self.txtEmpId = "id=id_emp_id"
        self.txtName = "id=id_name"
        self.selRole = "id=id_role"
        self.butSubmit ="//input[@value='Submit my Assessment']"
        self.lblSuccessMsg = "//div[@id='new-user']//span[@class='messages']"
        self.assessmentOne = "//input[@name='capability82' and @value='2']"
        self.assessmentTwo = "//input[@name='capability83' and @value='2']"
        self.assessmentThree = "//input[@name='capability85' and @value='2']"
        self.assessmentFour = "//input[@name='capability86' and @value='2']"
        self.assessmentFive = "//input[@name='capability96' and @value='3']"
        self.assessmentSix = "//input[@name='capability97' and @value='3']"
        self.assessmentSeven = "//input[@name='capability98' and @value='3']"
        self.assessmentEight = "//input[@name='capability99' and @value='3']"
        self.ErrormessageForId = "//div[@id='new-user']/table/tbody/tr[2]/td[3]"
        self.ErrormessageForName = "//div[@id='new-user']/table/tbody/tr[3]/td[3]"
        self.ErrormessageForRole = "//div[@id='new-user']/table/tbody/tr[4]/td[3]"
             
    def GoToPageAddComp(self):
        varSelWrap = self.varSelWrap
        varSelWrap.Click(self.lnkAddComp)
        sleep(2)
        print "---Selected Link Add Your Competencies" 
        
    def EnterEmpId(self,EmpId):
        varSelWrap = self.varSelWrap
        varSelWrap.Type(self.txtEmpId,EmpId)
        print "---Set Emp ID as " + EmpId 
        
    def EnterEmpName(self,EmpName):
        varSelWrap = self.varSelWrap
        varSelWrap.Type(self.txtName,EmpName)
        print "---Set Emp Name as " + EmpName 

    def SelectRole(self,Role):
        varSelWrap = self.varSelWrap
        varSelWrap.Select(self.selRole,Role)
        sleep(2)
        print "---Selected Role as " + Role 
    
    def SelectCompetency(self):
        varSelWrap = self.varSelWrap
        
        varSelWrap.Click(self.assessmentOne)
        varSelWrap.Click(self.assessmentTwo)
        varSelWrap.Click(self.assessmentThree)
        varSelWrap.Click(self.assessmentFour)
        varSelWrap.Click(self.assessmentFive)
        varSelWrap.Click(self.assessmentSix)
        varSelWrap.Click(self.assessmentSeven)
        varSelWrap.Click(self.assessmentEight)
        print ".. selected competencies"
        
    def getErrormessageForId(self):
        varSelWrap = self.varSelWrap
        return varSelWrap.GetText(self.ErrormessageForId)
        
    def getErrormessageForName(self):
        varSelWrap = self.varSelWrap
        return varSelWrap.GetText(self.ErrormessageForName)
        
    def getErrorMessageForRole(self):
        varSelWrap = self.varSelWrap
        return varSelWrap.GetText(self.ErrormessageForRole)
        
    def SubmitCompetency(self):
        varSelWrap = self.varSelWrap
        varSelWrap.Click(self.butSubmit)
        print "---Clicked button submit assessment"
        sleep(2)
        
    def GetSuccessVerificationMessage(self):
        varSelWrap = self.varSelWrap
        return varSelWrap.GetText(self.lblSuccessMsg)
            
    def setBasicDetailsForAddComp(self,name,id,role):
        self.EnterEmpName(name)
        self.EnterEmpId(id)
        self.SelectRole(role)
        sleep(1)
               
       
        