<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Pisuna on Medium]]></title>
        <description><![CDATA[Stories by Pisuna on Medium]]></description>
        <link>https://medium.com/@pisuna.put?source=rss-38b85ff5b4e4------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*qwx73PhozI4cxIuWouo2cQ.jpeg</url>
            <title>Stories by Pisuna on Medium</title>
            <link>https://medium.com/@pisuna.put?source=rss-38b85ff5b4e4------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 18:08:20 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@pisuna.put/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[ทำ Responsive automation testing ด้วย Galen Framework (#1 ทำความรู้จัก)]]></title>
            <link>https://medium.com/@pisuna.put/%E0%B8%97%E0%B8%B3-responsive-automation-testing-%E0%B8%94%E0%B9%89%E0%B8%A7%E0%B8%A2-galen-framework-1-%E0%B8%97%E0%B8%B3%E0%B8%84%E0%B8%A7%E0%B8%B2%E0%B8%A1%E0%B8%A3%E0%B8%B9%E0%B9%89%E0%B8%88%E0%B8%B1%E0%B8%81-5d80833552f6?source=rss-38b85ff5b4e4------2</link>
            <guid isPermaLink="false">https://medium.com/p/5d80833552f6</guid>
            <dc:creator><![CDATA[Pisuna]]></dc:creator>
            <pubDate>Thu, 28 Sep 2017 18:17:27 GMT</pubDate>
            <atom:updated>2017-09-28T18:17:27.327Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ax8XxI69yAfAoxrgcOpG7w.png" /></figure><p>เมื่อพูดถึงการเทส Layout โดยเฉพาะ Responsive website ดูเป็นเรื่องที่ยุ่งยากมาก บางทีแค่แก้ CSS นิดเดียวก็กระทบไปซะหมด ถ้าต้องมานั่งแมนนวลเทส Layout ใหม่ทุก Device แบบนี้ทุกทีคงไม่ดีแน่</p><h3>แต่มันจะดีขึ้นถ้าวันนี้เรารู้จัก Galen Framework</h3><p>จริงๆแล้ว Galen Framework ไม่ใช่ของใหม่แต่มันมีมานานแล้ว โดยสิ่งที่เป็นจุดขายของ Galen Framework เลยนั่นก็คือ Responsive automation testing</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/260/1*y1hlET74fKqvT7D2nu99bw.png" /></figure><blockquote>Galen Framework — Automated testing of look and feel for your responsive websites</blockquote><p><strong>Galen Framework</strong> มีไฟล์อยู่สองประเภท คือ ไฟล์ .test และ .gspec</p><ol><li>File.test เป็นไฟล์ที่เขียนโปรแกรมเพื่อสั่งรันเทส ซึ่งไฟล์นี้สามารถเขียน Javascript เพื่อสั่งให้ทำงานบางอย่างบนหน้าเว็บก่อน Verify expected result ได้เช่น สั่งให้ login , click element , input element เป็นต้น</li><li>File.gspec เป็นไฟล์ที่เขียนโปรแกรมเพื่อ Verify expected result ซึ่งเขียนด้วยภาษา Galen Spec ไฟล์นี้สามารถสั่งรันตัวเองโดยไม่ต้องผ่าน File.test ได้ด้วย</li></ol><p>และในบทความนี้เราจะพูดถึง File.gspec กันก่อนค่ะ และ File.test เราจะมาพูดถึงในบทความหน้านะคะ</p><h3>Galen Framework ดียังไง?</h3><ol><li>Galen is open source</li><li>Easy to setup a test for different browser sizes.</li><li>Use human readable syntax</li><li>Error reporting with screenshot</li><li>Support CICD</li></ol><h3>มาเริ่ม Install Galen กัน</h3><ol><li>ติดตั้ง Java version 1.8 or greater <a href="https://www.java.com/en/download/help/download_options.xml">ดาวน์โหลด</a></li><li><a href="http://galenframework.com/download/">ดาวน์โหลด</a> Galen-2.3.5.zip หลังจากนั้นก็ทำการ Unzip folder ให้เรียบร้อย</li><li>Install Galen โดย OS X และ Linux สามารถติดตั้งผ่าน Terminal ด้วยคำสั่ง</li></ol><p><strong>sudo {path to folder Galen-2.3.5}/install.sh</strong></p><p>(<a href="http://mindengine.net/post/2014-01-08-configuring-galen-framework-for-windows/#.WbrEPNMjE3E">คลิกเพื่อดูขั้นตอนการ Install Galen สำหรับ window</a>)</p><h3>มาทำความรู้จักกับภาษา Galen Specs กันก่อน</h3><p>Galen Specs เป็นภาษาเฉพาะที่ใช้ใน Galen Framework เพื่อตรวจสอบการจัดวาง Layout บน Website ในขนาดหน้าจอต่างๆ โดยจะเขียนโค้ดไว้ภายใต้ไฟล์ .gspec</p><p>ซึ่งภายในไฟล์ .gspec จะประกอบไปด้วย 2 ส่วนหลักๆ คือ</p><ol><li><strong>object definitions </strong>เป็นส่วนของการกำหนด Locator ให้กับ Object ที่เราต้องการจะตรวจสอบ โดยจะเขียนไว้ภายใต้ @objects จะเขียนเป็น Object เดี่ยวๆ หรือเขียนเป็น Object correction, Object group ก็ได้ แต่เราจะพูดถึงเรื่องนี้กันในบทความต่อไปกันค่ะ</li></ol><p>ตัวอย่าง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/811/1*NIsPQXBaASs-_rPKJ5dBzA.png" /></figure><p>หรือ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/812/1*ZFnG544RiZYe6sJ269mu8g.png" /></figure><p><strong>2. object specs </strong>เป็นส่วนที่ใช้ ​Verify ว่า Object ที่ต้องการจะตรวจสอบนั้น มีการจัดวาง Layout ถูกต้องตามที่ Expect ไว้หรือไม่ ด้วยคำสั่งใน Galen Specs Language ซึ่งการใช้คำสั่งต่างๆเราจะมาอธิบายให้ละเอียดขึ้นในบทความต่อไปเช่นกันค่ะ</p><p>ตอนนี้เรามาดู Pattern และตัวอย่าง ในส่วนของ Object specs ตามรูปข้างล่างนี้เลย</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/807/1*JrjH4-L__7Ro70ZW7YJuAA.png" /></figure><p>อธิบายง่ายๆก็คือ ภายใต้ Main section เราต้องการตรวจสอบ Objects ที่ชือว่า Header ว่ามีความสูงเท่ากับ 40 pixels จริงหรือไม่</p><ul><li><em>Section Name (เขียนไว้ภายในเครื่องหมาย “= =”) เรากำหนดชื่อได้เอง มีไว้เพื่อแบ่งขอบเขตในการเทส Object แต่ละชุด</em></li><li><em>Object name ที่นำมาตรวจสอบ (name ที่ตามด้วยเครื่องหมาย “:”) ต้องตรงกับชื่อ Object ที่เราประกาศไว้ภายใต้ @objects เสมอ</em></li></ul><h3><strong>มาสร้าง First Project กัน</strong></h3><ol><li>สร้างโฟลเดอร์ Project ขึ้นมา</li><li>สร้างไฟล์ galen.config ไว้ภายใต้โฟลเดอร์ Project ของเรา โดยไปที่โฟลเดอร์ Project และรันคำสั่ง $ galen config</li><li>สร้างไฟล์ home-page.gspec และพิมพ์โค้ดสำหรับเทสด้านล่างนี้ลงไปเลย</li></ol><pre>@objects<br>    header      id      header<br><br>= Main section =<br>    header:<br>        height 40px</pre><p>4. เปิด terminal ขึ้นมา และรันคำสั่งดังนี้</p><pre>$ galen check {path_to_file_test}/home-page.gspec <br>--url http://samples.galenframework.com/tutorial1/tutorial1.html <br>--size 640x480 --htmlreport report</pre><ul><li><em>คำสั่ง galen check home-page.gspec หมายถึงให้รันไฟล์ home-page.gspec</em></li><li><em>parameter — url “url” หมายถึงให้เปิด “url” นั้นขึ้นมาเพื่อตรวจ Layout</em></li><li><em>parameter — size “size” หมายถึงให้เปิดหน้าจอตาม size ที่กำหนด</em></li><li><em>parameter — htmlreport “path to report folder” หมายถึงเมื่อรันเสร็จให้พ่น log ต่างๆไว้ใน folder นั้น</em></li></ul><p>5. แต่หลังจากรันแล้วเราก็พบว่า Test Fail ดังนี้</p><blockquote>Suite status: FAIL<br>Total tests: 1<br>Total failed tests: 1<br>Total failures: 1<br>There were failures in galen tests</blockquote><p>แต่อย่าเพิ่งตกใจ ให้ไปยัง folder report และเปิดไฟล์ report.html ขึ้นมาเพื่อดูว่า Fail เพราะอะไร</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bygHeVgANbMv2dKyUZfsUg.png" /></figure><p>จาก Log ที่ปรากฎทำให้เรารู้ว่า จริงๆแล้ว Header มีความสูง 100px ไม่ใช่ 40 px จึงเป็นเหตุผลให้ Test Fail</p><p>งั้นเราลองไปแก้โค้ดเป็น</p><pre>@objects<br>    header              id      header<br><br>= Main section =<br>    header:<br>        height 100px</pre><p>และลองรันใหม่อีกครั้ง คราวนี้ก็จะ Test Pass แล้ว</p><blockquote>========================================<br> — — — — — — — — — — — — — — — — — — — — <br>========================================<br>Suite status: PASS<br>Total tests: 1<br>Total failed tests: 0<br>Total failures: 0</blockquote><p>เป็นยังไงบ้างคะ พอจะเห็นถึงความสนุกของ Galen Framework กันหรือยัง จริงๆแล้ว Galen ไม่ได้ทำได้เพียงเท่านี้ มีอีกหลายอย่างที่ทำให้ Galen น่าสนใจขึ้น เช่น Galen สามารถทำ Image Comparison ได้ด้วย เอาไว้จะมาเล่าให้ฟังใหม่นะคะ</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5d80833552f6" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>