# 6/24共筆
{%hackmd 1lpg7PuqRoaui6XyJcrylw %}
- 針對Robot的開發規則說明
- Library(Implement Code)
- Class-base
- Module-base
:::info
:question: 比較各種Implement Code的寫法?
:::
- Task
- For other automation purposes instead of test automation (e.g. robotic process automation, RPA)
- sysntax與Test Case相同
| | Test Cases | Tasks |
| ------- |:------------------:|:-------------------------:|
| Purpose | test automation | RPA or general automation |
| Section | *** Test Cases *** | *** Tasks *** |
| Syntax | same as Tasks | same as Test Cases |
- 常與[RPA Framework](https://rpaframework.org/)的library一起使用
- 條件式和迴圈
- 若以「Readability」做為測項撰寫原則
- ==Test Cases中盡量避免使用==
- 建議使用在Keywords中(Resource/Library)
- 邏輯仿造Python,但改成Robotframework的Syntax
- For Loop常與 `RANGE`, `ENUMERATE`, `ZIP`合用
- Test TimeOut
- Under `Setting`, a test case or user keyword`
- Input Value:
- 沒有timeout: `NONE`, 0 , negative number
- Use time format
- days, day, d
- hours, hour, h
- minutes, minute, mins, min, m
- seconds, second, secs, sec, s (default units)
- milliseconds, millisecond, millis, ms
```
1 day 2 hours 3 minutes 4 seconds 5 milliseconds
1d 2h 3m 4s 5ms
10
10 s
```
- timer string
- hh\:mm\:ss.mil
- Evaluate: 將string視為python script執行,並將執行過的值回傳。
- In line `{}` 搭配 `${}` `@{}` `&{}`
```
${{'positive' if ${x} > 0 else 'negative'}}
```
- keyword `Evalute` 搭配 `${}` `@{}` `&{}`
```
${type} = Evaluate 'positive' if ${x} > 0 else 'negative'
```
:::info
:question: 可不可以直接在Test Case或User Keyword中直接使用python的syntax?
:bulb: 用`Evalute`就可以,但*為什麼需要?*
:::
---
- [Robot Framework User Guide - For, If, Timeout](https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#advanced-features)
- [Robot Framework User Guide - Time Format](https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#time-format)
- [Robot Framework User Guide - Evaluate](https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#evaluating-expressions)
- [BuiltIn Keyword](https://robotframework.org/robotframework/latest/libraries/BuiltIn.html)