<?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 Prai Natthakarn on Medium]]></title>
        <description><![CDATA[Stories by Prai Natthakarn on Medium]]></description>
        <link>https://medium.com/@praiNatts?source=rss-22b9a7854cfd------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*TaGrSBR2Tt8h4fiFgdtTXg.png</url>
            <title>Stories by Prai Natthakarn on Medium</title>
            <link>https://medium.com/@praiNatts?source=rss-22b9a7854cfd------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 08:38:40 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@praiNatts/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[หา Locator ยังไง เมื่อแอปไม่มี Element ID มาให้ ]]></title>
            <link>https://medium.com/@praiNatts/%E0%B8%AB%E0%B8%B2-locator-%E0%B8%A2%E0%B8%B1%E0%B8%87%E0%B9%84%E0%B8%87-%E0%B9%80%E0%B8%A1%E0%B8%B7%E0%B9%88%E0%B8%AD%E0%B9%81%E0%B8%AD%E0%B8%9B%E0%B9%84%E0%B8%A1%E0%B9%88%E0%B8%A1%E0%B8%B5-element-id-%E0%B8%A1%E0%B8%B2%E0%B9%83%E0%B8%AB%E0%B9%89-bd4d768e482f?source=rss-22b9a7854cfd------2</link>
            <guid isPermaLink="false">https://medium.com/p/bd4d768e482f</guid>
            <dc:creator><![CDATA[Prai Natthakarn]]></dc:creator>
            <pubDate>Tue, 05 Dec 2023 08:15:43 GMT</pubDate>
            <atom:updated>2023-12-05T08:15:43.018Z</atom:updated>
            <content:encoded><![CDATA[<p>สำหรับคนที่ทำ Mobile Automation Test นั้น มักจะเจอกับปัญหาว่า แอปพลิเคชันที่เราต้องทดสอบ ไม่ค่อยมี element id มาให้ ซึ่งมันทำให้ยากต่อการนำไปใช้งานเพราะถ้าใช้ xpath แบบตรงๆมันก็ดูไม่ค่อยเสถียรเท่าไหร่ เนื่องจากสารมารถเปลี่ยนไปได้ทุกเมื่อ ทีนี้เราจะทำยังไงกันดีละ</p><p>ในกรณีเราจะมาแนะนำวิธีการหา locator ของเรากัน</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/906/1*VuSZMXDlyQd1tp7uJ3vyUA.png" /></figure><p>จากตัวอย่าง เราต้องการที่จะหา locator ของ textfield first name ก็สามารถใช้ locator ได้ตามด้านล่างเลย</p><p>Android</p><pre>xpath=//*android.widget.EditText[@text=&quot;First Name&quot;]<br>ในกรณีที่แอปเป็นสองภาษา<br>xpath=//*android.widget.EditText[@text=&quot;First Name&quot; or @text=&quot;ชื่อจริง&quot;]</pre><p>iOS</p><pre>xpath=//XCUIElementTypeTextField[@label=&quot;First Name&quot;]<br>ในกรณีที่แอปเป็นสองภาษา<br>xpath=//XCUIElementTypeTextField[@label=&quot;First Name&quot; or @label=&quot;ชื่อจริง&quot;]</pre><p>ของ iOS เราสามารถใช้ chain ในการหา locator ได้เช่นกัน</p><pre>chain=**/XCUIElementTypeTextField[`label == &quot;First Name&quot;`]<br>chain=**/XCUIElementTypeTextField[`label == &quot;First Name&quot; OR label == &quot;ชื่อจริง&quot;`]</pre><p>ในกรณีที่ text ที่เราต้องการมันยาวเกินไป ก็สามารถใช้ contains ในการชี้ตัว locator ได้เช่นกัน จากตัวอย่างเราต้องหา locator ของ “I accept the Terms of Use &amp; Privacy Policy” ก็สามารถใช้ locator ด้านล่างได้</p><p>Android</p><pre>xpath=//*[contains(@text,&quot;I accept the Terms&quot;)]</pre><p>iOS</p><pre>xpath=//*[contains(@label,&quot;I accept the Terms&quot;)]<br>chain=**/XCUIElementTypeStaticText[contains(`label CONTAINS &quot;I accept the Terms&quot;`]</pre><p>แล้วถ้าใน textfield นั้นไม่ได้มี text ละต้องทำยังไง 🤔🤔🤔🤔</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/570/1*fWtFx90tDpuQCX2hdamaVA.png" /></figure><p>จากตัวอย่างเราจะเห็นว่า text อยู่เหนือ textfield เราก็สามารถหาด้วย xpath axes ได้</p><p>Android</p><pre>xpath=(//*[@text=&quot;First Name&quot; or @text=&quot;ชื่อจริง&quot;]/following::android.widget.EditText)[1]<br>xpath=(//*[@text=&quot;First Name&quot; or @text=&quot;ชื่อจริง&quot;]/following-sibling::android.widget.EditText)[1]</pre><p>iOS</p><pre>xpath=(//*[@label=&quot;First Name&quot; or @label=&quot;=ชื่อจริง&quot;]//following::XCUIElementTypeTextField)[1]</pre><p>ในกรณีที่ต้องใส่ index [1] เพราะว่าการใช้ following มันจะหาทุก element ที่เป็น type ตามที่เรากำหนดในทั้ง DOM ซึ่งถ้าตัวที่เราต้องการไม่ได้อยู่ที่ index [1] ก็สามารถกำหนดได้ แต่ใน กรณีที่เป็นตัวแรก ไม่ต้องใส่ index ก็ได้</p><blockquote>TIPS กรณีที่ index ที่เราต้องการอยู่ตัวสุดท้าย สามารถใส่ index เป็น [-1] ได้</blockquote><p>เพียงเท่านี้ก็สามารถหา locator ได้ง่ายโดยที่ไม่ต้องใช้ xpath ยาวๆได้แล้ว 🎉</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*3xB-jVEaUutqcSTVN1bqnw.jpeg" /><figcaption>xpath axes diagram</figcaption></figure><blockquote>TIPS เราสามารถ convert locator จากของ Android เป็น iOS ได้ง่ายๆ โดยไม่ต้องไป inspect ให้เสียเวลา โดย ดูจาก type ของ element นั้นๆได้ เช่น</blockquote><pre>Android<br>xpath=//*[@class=&quot;android.widget.Button&quot; and (@text=&quot;Submit&quot;)]<br><br>iOS<br>xpath=//XCUIElementTypeButton[@label=&quot;Submit&quot;]</pre><blockquote>สำหรับใครที่อยากเข้าใจ xpath axes มากขึ้น สามารถดูได้จากที่นี่เลย <a href="https://zvon.org/comp/r/tut-XPath_1.html#Pages~XPath_as_filesystem_addressing">https://zvon.org/comp/r/tut-XPath_1.html#Pages~XPath_as_filesystem_addressing</a></blockquote><blockquote>ขอบคุณ UI สวยๆจาก <a href="https://www.tutorialrepublic.com/snippets/preview.php?topic=bootstrap&amp;file=simple-registration-form">https://www.tutorialrepublic.com/snippets/preview.php?topic=bootstrap&amp;file=simple-registration-form</a></blockquote><blockquote><a href="https://dzone.com/articles/jquery-mobile-tutorial-user">https://dzone.com/articles/jquery-mobile-tutorial-user</a></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bd4d768e482f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to get focus the appPackage and appActivity by ADB]]></title>
            <link>https://medium.com/@praiNatts/how-to-get-focus-the-apppackage-and-appactivity-by-adb-31b5ee5b1d6e?source=rss-22b9a7854cfd------2</link>
            <guid isPermaLink="false">https://medium.com/p/31b5ee5b1d6e</guid>
            <dc:creator><![CDATA[Prai Natthakarn]]></dc:creator>
            <pubDate>Mon, 27 Nov 2023 04:36:49 GMT</pubDate>
            <atom:updated>2023-11-27T04:36:49.276Z</atom:updated>
            <content:encoded><![CDATA[<p>หลายๆคนอาจจะประสบกับปัญหาของการหา appPackage และ appActivity ของ Android ในการทำ Test Automation เรามี command ที่ใช้ในการ get focus package and activity มาแนะนำ</p><p>ก่อนอื่นมาเช็คก่อนว่าเครื่องเราสามาใช้คำสั่ง adb ได้ไหม จาก command นี้</p><pre>adb devices</pre><p>ถ้าเครื่องเรามีคำสั่ง adb จะได้ผลลัพท์ดังภาพด้านล่าง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/872/1*z_DhrNIlofLc0s3ag8qMBw.png" /><figcaption>กรณีที่ยังไม่ได้เชื่อมต่อกับ Device</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/504/1*mM2J4lg933XzrcTwm9EjiQ.png" /><figcaption>กรณีที่เชื่อมต่อกับ device แล้วจะได้ name ของ device เครื่องนั้นๆมา</figcaption></figure><p>เมื่อเราต้องการที่จะหา appPackage และ appActivity นั้นสามารถทำตามขั้นตอนนี้ได้เลย</p><ol><li>เปิด application ที่ต้องการ</li><li>แล้วใช้คำสั่งด้านล่าง</li></ol><pre>adb shell dumpsys window | grep -E &#39;mCurrentFocus&#39;</pre><p>ตัวอย่าง หากเราต้องการหา Package และ Activity ของ Youtube</p><p>ทำการเปิด application Youtube ขึ้นมาจะได้หน้า home ตามภาพ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/630/1*ARcOQVxGkCJdsj24yr6EEA.png" /></figure><p>แล้วใช้คำสั่งเพื่อ get focus Package and activity จะได้ผลลัพท์ตามภาพด้านล่าง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y7vSFDDRuSeZOD27rrqUgw.png" /></figure><ul><li>กรอบสีแดง คือ appPackage</li><li>กรอบสีส้ม คือ appActivity</li></ul><p>เพียงเท่านี้เราก็สามารถ get focus Package และ Acitivity ของ Android ได้แล้ว</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=31b5ee5b1d6e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Katalon Cucumber ]]></title>
            <link>https://medium.com/@praiNatts/katalon-cucumber-76bf3105ce73?source=rss-22b9a7854cfd------2</link>
            <guid isPermaLink="false">https://medium.com/p/76bf3105ce73</guid>
            <dc:creator><![CDATA[Prai Natthakarn]]></dc:creator>
            <pubDate>Tue, 27 Dec 2022 10:17:01 GMT</pubDate>
            <atom:updated>2022-12-27T10:53:19.604Z</atom:updated>
            <content:encoded><![CDATA[<h4>Cucumber คืออะไร?</h4><p><strong>Cucumber</strong> เป็น Behavior Driven Development(BDD) Automated Testing Platform ที่สามารถใช้งานกับ Java, Ruby, Groovy และ Scala ได้ อยู่ในรูปแบบของประโยคภาษาอังกฤษซึ่งสามารถอ่านและเข้าใจได้ทันที ซึ่งในโครงสร้างของ Test Scripts นั้นจะใช้ Gherkin Syntax มาเป็นตัวกำหนดโครงสร้างของ Test Scripts ในการเขียน Test Scripts นั้นเราจะใช้ Requirement ที่ User ได้กำหนดมาเป็น Scenarios ที่อยู่ภายใน Test Scripts และหากทุกๆ Test Scripts มีผลการทดสอบที่ผ่านแล้วก็สามารถมั่นใจได้ว่าโปรแกรมจะทำงานตรงตาม Requirement</p><h4>มาทำความรู้จัก Gherkin Syntax กัน</h4><p>โครงสร้างของ Gherkin Syntax ประกอบไปด้วย</p><pre>Feature: ชื่อ Feature<br>     As a (role เช่น user,ชื่อระบบ หรือประธานอื่นๆ)<br>     I want (คือ Feature หรือ ความต้องการว่าระบบจะทำงานแบบไหน)<br>     So that (เป็นเหตุผลหรือประโยชน์ของระบบจากการทำงานของ Feature)<br><br>Scenario: (title) / Scenario Outline: (title) <br>     Given (Context: คือบริบทหรือการอธิบายที่มาที่ไปของ Scenario)<br>     When (Action: คือสิ่งที่จะกระทำ)<br>     Then (Outcome: คือบอกผลลัพธ์ที่คาดหวัง)<br>     And,But : เป็น action เพิ่มเติม <br>          <br>Examples: <br>     | email                        | password   | coin_amount | <br>     | testcucumber_1@testmail.com  | Test123123 | 3           | <br>     | testcucumber_2@testmail.com  | Test123111 | 0.05        | <br><br>Background: step ก่อนที่จะ run scenaio (before each)<br><br>Tags/ Labels: เพื่อใช้จัดกลุ่ม scenario</pre><h4>มาเริ่มต้นทำ Katalon Cucumber กัน</h4><p>เราสามารถสร้าง Katalon Cucumber ได้ โดยการไปที่<strong> Test Explorer</strong> &gt; <strong>Include</strong> &gt; <strong>features</strong> แล้วคลิกขวา ที่ <strong>features</strong> <strong>folder</strong> แล้วเลือก <strong>New Feature File</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ySNrtK5PcMPAPl5LJfVgDA.png" /></figure><p>จากนั้นให้ตั้งชื่อ Feature file (ระบบจะมีให้เลือก <strong>Generate sample Feature template</strong>. ซึ่งเป็น sample template สามารถติ๊กเลือกได้ หรือไม่เลือกก็ได้)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/824/1*Fbl8aItt4QBsV7RlgXMqCA.png" /></figure><p>เมื่อกดปุ่ม OK จะได้ Feature file และระบบจะทำการ <strong>Generate sample Feature template</strong>. มาให้ตามภาพด้านล่าง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jExUzJNd0GYjq9z1iyYrsg.png" /></figure><p><em>จะเห็นว่ามีการขึ้น warning เตือน ใน step เพราะว่า Katalon ยังไม่สามารถหา Step Definitions ได้</em></p><p>จากนั้นเราจะทำการสร้าง Step Definitions ซึ่ง Step Definitions ก็เปรียบเสมือนกับ keyword ของการทำ step ต่างๆใน scenario นั้นเองค่ะ</p><p>โดยการไปที่ <strong>Include/scripts/groovy</strong> folder. <strong>คลิกขาว</strong> &gt; <strong>New</strong> &gt; <strong>Step Definition</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ozfPL67l1piCUJawPEhM7A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e7K9lt6UIGKlNnx6WIXUZQ.png" /></figure><p><em>ใน step จะเห็นว่ามี Regexr ซึ่งมันคือการส่งค่าตัวแปร มาจาก scenario ซึ่ง type จะใส่ตาม type ที่ส่งมา</em></p><p>เราสามารถเชื่อม Step Definitions กับ Feature File โดยการ <strong>คลิกขาว &gt; Recalculate Steps</strong> หรือ <strong>กด F5</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/550/1*2SVqezzJeMCiHKaaFSECjQ.png" /></figure><p>เมื่อทำงาน Recalculate Steps เสร็จ จะไม่ขึ้น warning เตือน เหมือนตัวอย่างที่เป็น Given, Then</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/846/1*SfnFZHAekU71s5Y6vjP4Lw.png" /></figure><h4>How to run Katalon Cucumber 🏃🏼‍♀️</h4><p>เราสามารถ run cucumber ได้โดยการผ่าน Feature File เท่านั้น ซึ่งวิธีการรันสามารถทำได้ดังนี้</p><p>ไปที่ <strong>Feature File &gt; Execute &gt; เลือก platform ที่ต้องการ &gt; เลือก devices ที่ต้องการ &gt; กด OK</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UbZlB7hCEY_WZTv5mVTIsw.png" /></figure><blockquote>เมื่อ Run ผ่าน Feature File ตัว Cucumber จะไม่สามารถ Run scenario ใด scenario หนึ่งได้ ถึงแม้ว่าจะมีการติด tag แล้วก็ตาม</blockquote><h4>Cucumber Keyword 📚</h4><p>อย่างที่ได้กล่าวไปนะคะ ว่า Cucumber ไม่สามารถ Run เฉพาะ Scenario ได้ แต่ถ้าเราต้องการที่จะทำละ ทำได้ไหม ซึ่งก็สามารถทำได้โดยการใช้ Cucumber keyword ใน testcase ได้</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/724/1*zbl1FZibLMEO2CD8oC62oQ.png" /></figure><p>โดยสามารถใช้ Keyword ตามภาพด้านล่างได้เลย ซึ่งถ้าต้องการที่จะ Run เฉพาะ Scenario นั้นๆ ก็สามารถ ให้ keyword <strong>Run Feature File with Tags</strong> ได้</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yzzYKSx-BtJQTfi1wnqATQ.png" /></figure><h4>Cucumber Report 📑</h4><p>Katalon จะ export Report ให้ต่อเมื่อ Run ผ่าน Test suite เท่านั้น ซึ่งถ้าเราต้องการ Report ของ Cucumber จะต้องไป สร้าง testcase แล้ว นำ testcase นั้นเข้ามาใน test suite อีกที</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2CzI3T7NYnCSMCWrhae7Cw.png" /><figcaption>การเพิ่ม Feature File เข้า Testcase</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hm_zgQ2YcaH4F7b900A4cw.png" /><figcaption>การเพิ่ม Testcase เข้า Testsuite</figcaption></figure><p>ขั้นตอนการ Run Test suite สามารถทำได้เหมือนการรัน Cucumber ได้เลย และเมื่อระบบ Run ตาม Step ครบหมดแล้วจะทำการ Export Report ให้ ตามภาพ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QWhhXL_yt4U3_SnT6y8EyA.png" /></figure><p>Report สามารถดูได้ที่ Folder Report จากนั้นให้ไปหา Folder ชื่อเป็น วัน/เวลา ตาม วัน/เวลา ที่ทำการรัน(default) (ซึ่งสามารถตั้งชื่อตาม Feature ที่ต้องการได้)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/644/1*_PVv12RAsUfBV609nDcH5w.png" /></figure><p>เมื่อเข้าไปดูใน Folder Report ก็จะมีไฟล์ดังภาพ ซึ่งตัว Report ที่จะดูหลักๆคือ ไฟล์ .html เป็นไฟล์ที่สามารถอ่าน Report เข้าใจได้ง่าย</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YA70w7J3n2PHFQJgz8EjJw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kAO7h3iHlQ9flNwgLnr7WA.png" /><figcaption>File report HTML</figcaption></figure><blockquote>สามารถดูเนื้อหาเพิ่มเติมได้ที่ <a href="https://docs.katalon.com/docs/legacy/katalon-studio-enterprise/test-design/bdd-testing-framework-cucumber-integration/bdd-testing-framework-cucumber-integration-in-katalon-studio">https://docs.katalon.com/docs/legacy/katalon-studio-enterprise/test-design/bdd-testing-framework-cucumber-integration/bdd-testing-framework-cucumber-integration-in-katalon-studio</a></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=76bf3105ce73" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>