← Back to list

Robot Framework — ep.5 มารู้จัก Syntax ของ Keywords และ Keywords ที่ใช้บ่อยกันเถอะ

😸 สวัสดีครับ วันนี้จะมาพาทัวร์ทำความรู้จักกับ Syntax ของ Keywords , Keywords ที่ใช้บ่อย และดูความแตกต่างของ Keywords: Wait Until Element…

Chopin Punthanet · 2026-05-31 03:41 · 100 claps · 2.0 min read
#robot-framework #qa #testers #automation-testing
Open on Medium ↗
Wiki topics: PFI · Personal Finance LNG · Linguistics & Language

Robot Framework — ep.5 มารู้จัก Syntax ของ Keywords และ Keywords ที่ใช้บ่อยกันเถอะ

😸 สวัสดีครับ วันนี้จะมาพาทัวร์ทำความรู้จักกับ Syntax ของ Keywords , Keywords ที่ใช้บ่อย และดูความแตกต่างของ Keywords: Wait Until Element Is Enabled กับ Wait Until Element Is Visible กันครับ ก็ถ้าพร้อมแล้วก็มาเริ่มกันดีกว่าครับ

Syntax ของ Keywords 🤔

เราสามารถหา Keywords มาใช้ได้โดยพิมพ์ใน Google เลยว่า Robot framework selenium ก็เข้าเว็บโดยตรงนั้นแหละ แล้วก้พิมพ์ Keywords ที่ต้องการลงไป

https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html

https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html

ซึ่งเราสามารถหา Syntax ของ Keywords ได้ โดยการ Search Keywords ที่ต้องการที่ช่องซ้ายบน แล้วเลือก ตรงส่วนที่เขียนว่า Arguments จะเป็น Syntax ของ Keywords นั้นๆที่เราต้องการ แค่นี้เราก็จะรู้แล้วว่าแต่ละ Keywords มันเขียนยังไง เช่น Input Text ในที่นี้ก็คือ Input Text ตามด้วย Locator และตามด้วย คำที่ให้เขียน

มาลองดู Keywords ที่ใช้บ่อยกันครับ

Keywords

  • Click Element : คลิกที่ Element (เช่น ปุ่ม ลิงก์ หรือกรอบข้อความ)
  • Input text : กรอกข้อมูลลงใน Input field
  • Select Checkbox : ติ๊ก Checkbox
  • Checkbox Should Be Selected : เช็คว่าถูกติ๊กรึยัง
  • Select From List By Value : เลือก Dropdown List
  • Wait For Condition : รอจนกว่าจะตรงกับเงื่อนไขที่กำหนด
  • Wait Until Element Is Enabled : รอจนกว่า Element ที่ระบุจะใช้งานได้
  • Wait Until Element Is Visible : รอจนกว่า Element ที่ระบุจะปรากฏขึ้น

Wait Until Element Is Enabled และ Wait Until Element Is Visible🤔

มาลองดู 2 ตัวนี้กันครับ Keywords คล้ายๆกันเลยแต่ก็ใช้คนละแบบนะWait Until Element Is Enabled และ Wait Until Element Is Visible ใช้บ่อยมากทีเดียว เรามาดูแต่ละอันกันครับ

- Wait Until Element Is Enabled 🤠

  • ใช้ตรวจสอบว่า Element ที่กำหนดนั้น สามารถใช้งานได้ หรือไม่ (Enabled)
  • มักใช้กับ ปุ่ม (<button>), ฟอร์ม (<input>), หรือ Checkbox ที่อาจจะถูก Disabled อยู่ ซึ่งจะต้องการรอให้มันพร้อมใช้งาน
  • เงื่อนไขคือ รอจนกว่า Element จะสามารถทำงานได้ (เช่น ปุ่มที่ถูก Disabled อยู่ กลายเป็น Enabled) ถ้าทำงานไม่ได้ก็จะแจ้ง Error กลับ

ตัวอย่าง: รอให้ปุ่ม “Submit” กลายเป็น Enabled ก่อนจะคลิก

Wait Until Element Is Enabled    xpath=//button[@id="submit"]    5    
Click Element    xpath=//button[@id="submit"]

- Wait Until Element Is Visible 🤠

  • ตรวจสอบว่า Element นั้น สามารถมองเห็นได้ บนหน้าเว็บหรือไม่ (Visible)
  • มักใช้เมื่อต้องการตรวจสอบว่า Element ที่เราสนใจ (เช่น ข้อความ, ปุ่ม, หรือ div) ปรากฏขึ้นในหน้าเว็บหรือไม่ ซึ่งอาจจะซ่อนอยู่ก่อนหน้านี้ เช่น ถูกซ่อนไว้ด้วย CSS หรือยังไม่แสดงผล
  • เงื่อนไขคือ รอจนกว่า Element จะปรากฏและมองเห็นได้ ถ้าทำงานไม่ได้ก็จะแจ้ง Error กลับ

ตัวอย่าง: รอให้ข้อความ “Success” ปรากฏบนหน้าเว็บหลังจากที่ดำเนินการบางอย่าง

Wait Until Element Is Visible    xpath=//div[@id="success-message"]    5
Log    Success message is visible

มาดูตัวอย่างทั้งคู่กันครับ

Input Subscription
    [Arguments]        ${Subscription}      
    Wait Until Element Is Enabled     ${Subscription_ELEMENT}  5   Field susbscribe is disabled
    input text      id=susbscribe     ${Subscription} 

Buy Shirt   
    Wait Until Element Is Visible     ${Shirt_ELEMENT}  5   Ahhh, It is still invisible
    Click element                     ${Shirt_button} 

คร่าวๆก็จะประมาณนี้ครับ อาจจะมีอะไรที่ผมตกหล่นไปหรือมีผิดพลาดบ้าง ก็ขออภัยมา ณ ที่นี้ด้วยครับ

ทิ้งท้าย 😇 มีมที่ใส่มาตอนแรกก็เหมือนกับ Keywords: Wait Until Element Is Enabled/Visible เลยครับ55 รอจนกว่าจะเห็น แต่ตอนนี้ยังไม่เห็น หายตัวอยู่55

🫠 ทั้งหมดก็จะมีประมาณนี้ ถ้าชอบก็อย่าลืมกดตบมือและแชร์เพื่อเป็นกำลังใจให้ผมด้วยนะครับ และอย่าลืมติดตามบทความถัดๆไปของผมด้วย ขอบคุณทุกๆท่านที่อ่านจนจบนะครับ ขอบคุณมากครับ 🥳


메타데이터
post_id
0f79e2cc0e3f
slug
robot-framework-ep-5-มารู้จัก-keywords-wait-until-element-is-enabled-visible-กันเถอะ-0f79e2cc0e3f
url
https://medium.com/@punthanet/robot-framework-ep-5-%E0%B8%A1%E0%B8%B2%E0%B8%A3%E0%B8%B9%E0%B9%89%E0%B8%88%E0%B8%B1%E0%B8%81-keywords-wait-until-element-is-enabled-visible-%E0%B8%81%E0%B8%B1%E0%B8%99%E0%B9%80%E0%B8%96%E0%B8%AD%E0%B8%B0-0f79e2cc0e3f
canonical_url
https://medium.com/@punthanet/robot-framework-ep-5-%E0%B8%A1%E0%B8%B2%E0%B8%A3%E0%B8%B9%E0%B9%89%E0%B8%88%E0%B8%B1%E0%B8%81-keywords-wait-until-element-is-enabled-visible-%E0%B8%81%E0%B8%B1%E0%B8%99%E0%B9%80%E0%B8%96%E0%B8%AD%E0%B8%B0-0f79e2cc0e3f
author_url
https://medium.com/@punthanet
status
ok
fetched_at
2026-06-09 15:37:30