2017-04-07 1 views
-1

전역 세션 변수를 만드는 방법을 알려주고 그 세션 변수를 키워드/테스트 사례에서 사용해야 하는지요? $ {itoc_session} 찾을 수 없으므로 다음과 같은 방법을 시도하고 오류가 발생했습니다.세션에 대한 전역 변수를 생성하고 테스트 케이스 (RobotFramework, REST API)에서 사용하는 방법

*** Settings *** 
Library   RequestsLibrary 
Library   Collections 


*** Keywords *** 

Create session for server 
    @{auth}= Create List admin admin123 
    Create Session httpbin https://host141.swlab.net:71/ [email protected]{auth} 
    Set Global Variable  ${itoc_session}  httpbin 

Get Policy for Server 
    ${resp}= Get Request ${itoc_session}  uri=/policies/ 
    Log  ${resp.status_code} 
    :FOR ${item} in @{resp.json()} 
    \ Log ${item} 
    \ ${get_policy_id}= Get Variable Value ${item['id']} 
    \ ${get_policy_name}= Get Variable Value ${item['name']} 
    \ Log  ${get_policy_id},${get_policy_name}  
    Set Global Variable ${policy_id}  ${get_policy_id} 


Get Policy with policyID 
    ${res}= Get Request ${itoc_session}  uri = /policies/${policy_id} 
    Log ${res} 
    Log ${res.json()['name']} , ${res.json()['extReference']} 



*** Test case *** 

get_policy_id 
    Get Policy for Server 

get_policy_details 
    Get Policy with policyID 

답변

1

Create session for server을 결코 호출하지 않으므로 변수가 설정되지 않습니다.

+0

실수를 식별 해 주셔서 감사합니다. '경우 PolicyID 으로 정책을 가져 오기하는 요청 $ {itoc_session을} 서버 \t $ {고해상도를} 세션을 만들기 = 가져 오기 URI =/정책/$ {POLICY_ID} \t 로그인 $ {고해상도} \t #Log $ {res.json() [ 'name']} '. – Madhu