ModernWeb
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Write
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Help
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Write
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    # 從內部工具開始的網頁自動化測試人生 / Set Mao(毛太一) {%hackmd @ModernWeb/HkqZxb98v %} ### [簡報下載](https://s.itho.me/modernweb/2020/Slides/d504.pdf) > 共筆從這開始 ### 怎麼確保功能運作正常 1. 選擇並上傳檔案 2. 上傳中 3. 確認並匯入資料 4. 匯入完成 5. 檢視完整資料 ### 這樣有什麼問題? * 無聊、浪費⼈⼒(錢)、~~沒有我就只是想玩看看 selenium~~ * ⽽且隨著⽀援平台的增加、測試檔案的增加、測試所花的⼈⼒成本也會跟著越來越⾼ ## 怎麼開始的? ### How? * Python + Selenium ### Result 1. ~~選擇並上傳檔案~~ 2. 上傳中 3. 確認並匯入資料 4. 匯入完成 5. 檢視完整資料 > 減少了 10~15 分鐘的⼿動上傳操作時間,但是仍然需要⼈⼒比對答案,⽽且要從CLI 介⾯啟動,對沒有程式背景的⼈來說不那麼友善 > ## 人是貪心的,能不能更好用一點? ### 難⽤的點 * 只有上傳功能,沒有⾃動按匯入的功能-> 寫 * 還是需要⼈⼒檢查答案-> 只判斷資料筆數就好 * 要從 CLI 啟動-> 包成 exe * 測試檔案要⾃⼰下載-> 串 google drive api 直接從雲端下載檔案 > 測試流程全部⾃動化了(⼤約減少 1 時/天) > ~~⼯讀⽣也掰掰了~~ > ## 一個你就滿足了嗎?有没有想過提高測試範圍? ### 在寫扣之外 * 測試⽂件 * 測試檔案 * 測試流程 * 測試環境 ### 在寫扣之前 * 現有的扣有什麼問題? * ### 你有聽過 Page Objects 嗎? * Benefits of using page object pattern: * Creating **reusable**code that can be shared across multiple test cases * **Reducing** the amount of **duplicated code** * If the user interface changes, the fix needs **changes in only one place** ### Page Objects 是什麼? Selenium(Python) 的官⽅⽂件中 Page Objects 會包含以下幾種 東⻄ 1. Test case 2. Page object classes 3. Page Element 4. Locators ### 第⼀步,寫好測試流程 1. 進到儀表板⾴⾯ 2. 定位到想要看的圖表 3. 確認圖表中的數字是否正確 ### 第⼆步,把網⾴切成⼀塊⼀塊的 ![](https://i.imgur.com/1tfnBo9.png) ### 第三步,抓到每個要⽤的元素的位置 ### 替代⽅案 * Selenium IDE 1. 建立專案 2. 錄腳本 3. 輸出程式碼 > Result > ⽤ Page Object 改寫完了看起來⼀切都很完美 所以我們可以開始寫下⼀個測試了( 嗎?) 這個東⻄看起來很讚,但是可以讓它每天⾃⼰跑嗎? 啊,跑完記得要回傳測試結果喔 ## 這個東西很讚,可以讓它每天自己跑嗎? * crontab * Selenium hub * Docker * Slack * Result ![](https://i.imgur.com/I3RkgjR.png) ## 自動化測試該怎麼跟手動測試合作、溝通? ### 來⾃⼿動測試⼼中的疑惑 * ~~你們在幹嘛?~~ 1. 你們做了哪些 Test case? 2. 測試覆蓋度多⼤? 3. 可以教我怎麼操作⾃動化測試嗎? * ~~教他看 Code?~~ * ~~寫⽂件?~~ * **Gherkin(Python: Behave)** ### Gherkin * Gherkin uses a set of special keywords to give **structure** and **meaning** to **executable specifications.** * Each keyword is translated to many spoken languages. ![](https://i.imgur.com/Q5A4G1k.png) * Given(假如) -> 前置條件 * When(當) -> 動作 * Then(那麼) -> 結果 * And(⽽且) * But(但是) > Given I go to login page > When I login with correct account and password > Then I should login success > And I will redirect to index page ### Behave * behave is behaviour-driven development, Python style. * behave uses tests written in a natural language style, backed upby Python code. * Result * Before: **Test Case** -> Page -> Locator/Element * After: **Feature -> Step** -> Page -> Locator/Element * ~~這個怎麼⽤?~~ 1. 我要怎麼使⽤⾃動化測試? 2. 我要怎麼知道執⾏結果是成功還是失敗? 3. 我要怎麼知道是哪個測試失敗了? ### [Jenkins](https://www.jenkins.io/) Result ![](https://i.imgur.com/VOmMyKI.png) ### Conclusion * Python + Selenium * Page-Object * Gherkin ![](https://i.imgur.com/gnL9x7c.png) ###### tags: `MW20` `維運與測試` `自動化測試`

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully