วิธีติดตั้ง Chrome For Testing บน Robot Framework Selenium

สำหรับใครที่ใช้ Chrome ตั้งแต่ version 115 ขึ้นไป ทาง Google จะให้เราย้ายไปใช้งาน Chrome For Testing แทนที่จะใช้ Chrome ที่เราติดตั้งอยู่บนเครื่อง โดยเราต้องติดตั้ง Chrome For Testing ซึ่งเปรียบเสมือน Chrome ที่เราใช้งานในการเข้าเว็บ และ Chrome Web Driver สำหรับการ control chrome อีกทีนั่นเอง

ข้อดีของ Chrome For Testing

  • ลดปัญญาเรื่อง browser update อัตโนมัติ แล้ว version ไม่ตรงกับ driver ที่ติดตั้งไว้ ทำให้เทสรันไม่ได้
  • แยก version ของ Test Browser กับ Browser ที่ใช้งานออกจากกัน
  • สามารถเลือก version ของ Chrome ที่ต้องการจะทดสอบได้

ขั้นตอนการติดตั้ง

  • ให้เราไป Download Chrome For Testing จาก link https://googlechromelabs.github.io/chrome-for-testing/
  • ให้เลือกเป็น version Stable
  • Download Chrome binary และ driver ให้ตรงกับ Platform ของเรา ตัวอย่าง Window ตามรูป (สำหรับ mac m1/m2 ก็ให้เลือก Platform mac-arm64) ถ้า mac ให้ใช้ wget <URL> แทนการ download ตรงๆผ่าน browser เพราะจะติดปัญหา Security ทำให้เปิด Chrome For Testing ไม่ได้
  • ทำการ Unzip ทั้ง Chrome For Testing และ Chrome Driver ไว้ใน Folder เดียวกัน
  • เพิ่มใน Environment Variable สำหรับ Window
  • เพิ่มใน Environment Variable สำหรับ Mac ให้ทำการ แก้ไข .zprofile (อย่าลืมแก้ <username> เป็น path ของเครื่องด้วยนะครับ)
PATH="/Users/<username>/Documents/ChromeForTesting:${PATH}"
export PATH
  • อย่าลืมลบ Chrome Driver ตัวเก่าออกด้วยนะ
  • เท่านี้เมื่อเรา Run Test ตัว Robot ก็จะมาใช้งาน Chrome For Testing ให้เราอัตโนมัติแล้ว โดยเช็คได้จาก Popup แสดงข้อความ Chrome for Testing

Ref: https://developer.chrome.com/blog/chrome-for-testing/

Robot Framework Selenium workshop ads
Previous articleแก้ปัญหา Screenshot ไม่เต็มจอบน Robot Framework Selenium
Next articleExecute Robot Framework แบบ Parallel ด้วย Pabot

1 COMMENT