0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

[T-DASH] テスト自動化でクッキーを制御する

Last updated at Posted at 2024-06-10

Outline

テスト自動化T-DASHでクライアント側でcookieを制御したい時がある。
そのときの手順に関して解説する

技術的情報

robot frameworkにcookieを制御する命令がいくつかある
今回、3つのkeywordsを用いる

keywords detail
Add Cookie cookieを追加する
Delete Cookie cookieを削除する
Get Cookie cookieを取得する

テスト対象

guru99を用いた。
任意のuserid , passwordを取得できる。
ログイン後、クッキーを取得、削除、追加することで、ログイン状態が解除されることを検証する

  1. 取得した、一時アカウントでログインをする

image.png

  1. ログインの検証とクッキーの確認

image.png

  1. クッキーを削除・変更し、Manager IDが空っぽ(ログアウトされた状態)

image.png

T-DASH 設定

カスタム動作

以下設定内容をCookie.yamlに保存する

ACT-CAT-CUSTOM-cf6328a1-ed05-40b3-9173-1133c9915975:
  action_category_name: Cookie
  icon: ''
  color: '#a1369a'
  custom_data:
    file_name: Cookie
    pip_list: []
    library_list:
    - SeleniumLibrary
    - DateTime
  actions:
    ACT-CUSTOM-14684897-8216-4938-9626-8798e5626511:
      action_name: Cookieを追加する
      action_type: operation
      action_format: 名前「設定値1」値「設定値2」のCookieを追加する
      action_note: ''
      action_args:
      - value1
      - value2
      action_def:
      - - ${now} =
        - get current date
      - - '${cookie_expiry} = '
        - Add Time To Date
        - ${now}
        - 30 days
      - - Add Cookie
        - ${value1}
        - ${value2}
        - secure=True
        - expiry=${cookie_expiry}
    ACT-CUSTOM-ecca49f1-fcb7-4c3a-bf18-f4f36b641cd6:
      action_name: Cookieを削除する
      action_type: operation
      action_format: 名前「設定値1」のCookieを削除する
      action_note: ''
      action_args:
      - value1
      action_def:
      - - Delete Cookie
        - ${value1}
    ACT-CUSTOM-687e13c7-6c95-4586-a24b-a19820ea1e72:
      action_name: Cookieを取得する
      action_type: operation
      action_format: 名前「設定値1」のCookieを取得して、変数share_valueに格納する
      action_note: ''
      action_args:
      - value1
      action_def:
      - - ${value} =
        - Get Cookie
        - ${value1}
      - - Log
        - cookie ${value1} value is ${value}
      - - Set Suite Variable
        - ${share_value}
        - ${value.value}

次に、作成されたChromeOpti.yamlをT-DASHの動作定義 -> カスタム動作 -> カスタム動作をインポート にてインポートする

Cookie 追加

cookieの有効期限30日で設定しています

image.png

Cookie 削除

image.png

Cookie 取得

image.png

スクリプト

cookieの操作3つのカスタム動作を利用する

image.png

実行ログを見ると、cookieの情報を確認できる

image.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?