Search code examples
pythonstringseleniumcollectionsrobotframework

Robot framework identify card types using if condition


Before selecting button, need to check either input or output card. need a logic to identify either it is INPUT or OUTPUT Card using robot framework and if condition for web automation testing.

 **IO CARDS**
  SLOT 1 :DI
  SLOT 2 :DI
  SLOT 3 :DI
  SLOT 4 :DI
  SLOT 5 :DO
  SLOT 6 :DO
  SLOT 7 :DI

Please try to solve this


Solution

  • ${elementId}= |  Set Variable | Slot${slotNumber}BTN
    Log To Console |  ${elementId}    
    
    Click Element   |    slot${slotNumber}BTN
    Sleep |  3s
     
    ${slotLink} =  |  get text   | id=slot${slotNumber}BTN        
    Log to Console |  ${slotLink}  
    IF   | '${slotLink}'== 'Slot ${slotNumber} : DI'        
        Validate Input Card Options  ${slotNumber}
    END
    IF   | '${slotLink}'== 'Slot ${slotNumber} : DO'        
        Validate Output Card Options  ${slotNumber}
    END