<?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 Setthapong.Im on Medium]]></title>
        <description><![CDATA[Stories by Setthapong.Im on Medium]]></description>
        <link>https://medium.com/@setthapong-imsuwan?source=rss-cc8c9a201b13------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*PLQmIb5b6Y6Cqq0fckfVrw.jpeg</url>
            <title>Stories by Setthapong.Im on Medium</title>
            <link>https://medium.com/@setthapong-imsuwan?source=rss-cc8c9a201b13------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 16:52:10 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@setthapong-imsuwan/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[Robot Framework Results From Jenkins Pipeline Email Template]]></title>
            <link>https://setthapong-imsuwan.medium.com/robot-framework-results-from-jenkins-pipeline-email-template-10e38a593184?source=rss-cc8c9a201b13------2</link>
            <guid isPermaLink="false">https://medium.com/p/10e38a593184</guid>
            <category><![CDATA[email]]></category>
            <category><![CDATA[robot-framework]]></category>
            <category><![CDATA[jenkins]]></category>
            <dc:creator><![CDATA[Setthapong.Im]]></dc:creator>
            <pubDate>Thu, 11 May 2023 08:23:47 GMT</pubDate>
            <atom:updated>2025-08-22T15:12:55.572Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="https://forum.robotframework.org/" src="https://cdn-images-1.medium.com/max/862/1*2kNMba3lMO4F35JvRo0tQg.png" /><figcaption>credit <a href="https://commons.wikimedia.org/">https://commons.wikimedia.org/</a> <a href="https://homey.app/">https://homey.app/</a> <a href="https://forum.robotframework.org/">https://forum.robotframework.org/</a></figcaption></figure><p>การส่ง Email Robot Framework Summary Report โดนการใช้ Email Template และ Jenkins Pipeline</p><ol><li>ติดตั้ง Jenkins Plugin Email Extension</li><li>ติดตั้ง Jenkins Plugin Robot Framework</li><li>Download Email Template</li><li>ตั้งค่า Jenkins Config File</li><li>Config Jenkins Pipeline</li></ol><h4><strong>ติดตั้ง Jenkins Plugin Email Extension</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/799/1*JlVjy2lV_dRX0u7XeITZbg.png" /><figcaption><a href="https://plugins.jenkins.io/email-ext/">https://plugins.jenkins.io/email-ext/</a></figcaption></figure><h4>ติดตั้ง Jenkins Plugin Robot Framework</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/651/1*r8SP1YaP0HyH9TjDvBxpwg.png" /><figcaption><a href="https://plugins.jenkins.io/robot/">https://plugins.jenkins.io/robot/</a></figcaption></figure><p>ดาวโหลด Jenkins Email Template จาก Git หรือสามารถ Custom ขึ้นมาก็ได้</p><ul><li><a href="https://github.com/mustafa-masetic/robot-framework-email-template">GitHub - mustafa-masetic/robot-framework-email-template: Email template for Robot Frameworks in Jenkins</a></li><li><a href="https://github.com/vladwa/robot-email-template">GitHub - vladwa/robot-email-template: Email template for Robot Framework test results</a></li><li><a href="https://github.com/JMcn/jenkins-email-ext-templates">GitHub - JMcn/jenkins-email-ext-templates: 自定义jenkins邮件扩展插件模板</a></li><li><a href="https://github.com/ironakpatel/jenkins-email-template">GitHub - ironakpatel/jenkins-email-template: jelly template for jenkins email extension plugin</a></li></ul><p>ในกรณีนี้ผมเลือก Template จาก <a href="https://github.com/mustafa-masetic/robot-framework-email-template">robot-framework-email-template</a> โดน Copy Source Code จากไฟล์ <a href="https://github.com/mustafa-masetic/robot-framework-email-template/blob/main/templates/robot_framework_template.groovy">robot_framework_template.groovy</a> วางไว้ที่ Jenkins Config File ตามรูปด้านล่าง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/913/1*RgDom5RGh-4y2srFcL3UqQ.png" /></figure><p>หลังจากทำการสร้าง Config File เสร็จเรียบร้อยจะได้ไฟล์ Config ไฟล์ และไฟล์ ID</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-03N1l9e5puSeGH_aaDH0A.png" /></figure><p>หลังจากทำตามด้านบนครบแล้วสิ่งที่ต้องเตรียมต่อไปคือ</p><ol><li>Robot Framework Script</li><li>Robot Publisher Test Result</li></ol><pre>def publishReportTestCase() {<br>    <br>    step([$class: &quot;RobotPublisher&quot;, <br>      outputPath: &quot;${robot.resultPath}&quot;, <br>      outputFileName: &quot;**\\output.xml&quot;, <br>      reportFileName: &quot;**\\report.html&quot;, <br>      logFileName: &quot;**\\log.html&quot;, <br>      disableArchiveOutput: false, <br>      passThreshold: 0, <br>      unstableThreshold: 0, <br>      onlyCritical: true,<br>      otherFiles: &quot;**\\selenium-screenshot*.png&quot;])<br>}</pre><p>3. Run Step Robot Template โดย</p><p>template จะต้องตรงกับชื่อไฟล์ที่เราสร้างไว้ใน Jenkins Config</p><p>Subject เราสามารถกำหนดชื่อหัวข้อที่จะส่งได้</p><p>to คือ Email ผู้รับ</p><pre>def sendEmailTemplateV3() {<br>    emailext body: &#39;&#39;&#39;${SCRIPT, template=&quot;managed:Groovy Email Template&quot;}&#39;&#39;&#39;,<br>    mimeType: &#39;text/html&#39;,<br>    subject: &quot;SUCCESS: ${env.JOB_NAME} #${env.BUILD_NUMBER}&quot;,<br>    to: &#39;example@gmail.co.th&#39;<br>}</pre><p>หลังจากทำ Code Pipeline จากด้านบนเสร็จเรียบร้อยแล้ว ทดลองรันจะได้ตัวอย่าง Flow Pipeline ตามรูปด้านล่างครับ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/671/1*JvPctZUCSCTTQh9-_jEfaA.png" /></figure><p>ตรวจสอบที่ Email ที่เราระบุไปเราจะได้ รับรายละเอียด Email ตามรูปด้านล่างโดยแสดงเป็น สามส่วนหลักๆคือ BUILD SUCCESS และ ROBOT FRAMEWORK RESULTS</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/689/1*_zieQgKdnOgARjQBgPWBdA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/598/1*R7PD0L7wZLksogvwCfqWUA.png" /></figure><h3>สรุป</h3><p>จากบทความนี้เป็นการส่ง Email Robot Framework Summary ผ่าน Jenkins Pipeline Email Template โดยรูปแบบของ Email เราสามารถเลือกจาก ที่มีคน Provide เป็น Public ไว้ให้หรือว่าจะ Custom Template ขึ้นมาเองได้ตามรูปแบบที่เราต้องการ</p><blockquote><strong><em>Be giving, enjoy sharing. :)</em></strong></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=10e38a593184" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Robot Framework 4.0 New For loops Syntax]]></title>
            <link>https://setthapong-imsuwan.medium.com/robot-framework-4-0-new-for-loops-syntax-62d524729d98?source=rss-cc8c9a201b13------2</link>
            <guid isPermaLink="false">https://medium.com/p/62d524729d98</guid>
            <category><![CDATA[for-loop]]></category>
            <category><![CDATA[automation-testing]]></category>
            <category><![CDATA[robot-framework]]></category>
            <dc:creator><![CDATA[Setthapong.Im]]></dc:creator>
            <pubDate>Thu, 02 Dec 2021 02:35:56 GMT</pubDate>
            <atom:updated>2021-12-02T02:39:48.076Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/519/1*MIc3y13lsMOGRY2lH4jIkA.png" /><figcaption>photo credit :<a href="https://robotframework.org/#/">https://robotframework.org/#/</a></figcaption></figure><p>ใน Robot Framework 4.0 ที่มีการอัพเดท Feature ใหม่เพิ่มเข้ามาหนึ่งในสิ่งที่อัพเดทเข้ามาใหม่คือ New For loops Syntax ที่สามารถเขียน ลูปซ้อนลูปได้แล้ว</p><h4>Old for loop syntax</h4><p>ใน Robot Framework Version ที่ต่ำกว่า 4.0 นั้น จะยังมีการใช้งาน For loops ในรูปแบบของเดิมคือไม่สามารถเขียน ลูปซ้อนลูปได้ จำเป็นต้องเขียนโดนการใช้ For loops ซ้อนอยู่ใน Keyword แทนเพื่อใช้งานลูปซ้อนลูป ตามรูปแบบด้านล่าง</p><pre><strong>*** Test Cases ***</strong><br>Handle Read Excel Cell<br>    Open Excel    Documentfilename=file1.xlsx    doc_id=doc1<br>    FOR    ${row}    IN RANGE    0    10<br>        Handle Row    @{row}<br>    END</pre><pre>*** Keywords ***<br>Handle Row<br>    [Arguments]    ${row}<br>    FOR    ${cell}    IN RANGE    0    10<br>        ${dataCell}    Read Excel Cell    {row}    ${cell}<br>    END</pre><p>ใน Robot Framework Version 3.2 ยังสามารถใช้ For loop ในรูปแบบใหม่และแบบเก่าร่วมกันได้อยู่ และในรูปแบบเก่าจะไม่สามารถใช้งานได้ใน Robot Framework Version 4.0</p><h4>New for loop syntax</h4><p>ใน Robot Framework 4.0 สามารถใช้งาน loop ซ้อน loop โดยเขียนในรูปแบบด้านล่าง</p><pre>Handle Read Excel Cell<br>    Open Excel    Documentfilename=file1.xlsx    doc_id=doc1<br>    FOR    ${row}    IN RANGE    0    10<br>        FOR    ${cell}    IN RANGE    0    10<br>            ${dataCell}    Read Excel Cell    ${row}    ${cell}<br>        END<br>    END</pre><p>สามารถเขียนแบบ ลูปซ้อนกันหลายระดับได้</p><pre>Example<br>    FOR    ${root}    IN    r1    r2<br>        FOR    ${child}    IN    c1   c2    c3<br>            FOR    ${grandchild}    IN    g1    g2<br>                Log Many    ${root}    ${child}    ${grandchild}<br>            END<br>        END<br>        FOR    ${sibling}    IN    s1    s2    s3<br>                Log Many    ${root}    ${sibling}<br>        END<br>    END</pre><h3>สรุป</h3><p>การใช้งาน For loop ในรูปแบบใหม่นี้สามารถเขียนได้ง่ายขึ้น และกำหนดการส่งค่าต่างๆระหว่างลูปได้ โดยไม่จำเป็นต้องสร้าง Keyword เพื่อใช้งานในแบบเดิม</p><blockquote><strong><em>Be giving, enjoy sharing. :)</em></strong></blockquote><p>Reference</p><p><a href="https://robocorp.com/docs/languages-and-frameworks/robot-framework/for-loops">How to use for loops in Robot Framework and Python</a></p><p><a href="https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#for-loops">https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#for-loops</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=62d524729d98" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Robot Framework Execute test cases by tags]]></title>
            <link>https://setthapong-imsuwan.medium.com/robot-framework-execute-test-cases-by-tags-a382490eaa6d?source=rss-cc8c9a201b13------2</link>
            <guid isPermaLink="false">https://medium.com/p/a382490eaa6d</guid>
            <category><![CDATA[robot-framework]]></category>
            <category><![CDATA[automation]]></category>
            <dc:creator><![CDATA[Setthapong.Im]]></dc:creator>
            <pubDate>Tue, 02 Mar 2021 08:22:54 GMT</pubDate>
            <atom:updated>2021-03-02T08:22:54.678Z</atom:updated>
            <content:encoded><![CDATA[<h3>Robot Framework Tags</h3><p>ในการใช้งาน Robot Framework นั้นเราสามารถกำหนดที่จะรัน Test cases และ suites ด้วย tags ได้โดย tags ใน Robot Framework นั้นจะแบ่งออกเป็น 3 ประเภทคือ</p><p>Default Tags คือ การกำหนด Tags ให้กับ Test Cases ที่ไม่มีการกำหนด Tag ใน Case นั้นๆ ใช้งานในระดับ Suite</p><p>Force Tags คือ การกำหนด Tags ให้กับทุก Test Case ที่อยู่ภายใน Suite ใช้งานในระดับ Suite</p><p>Test Case Tags คือ การกำหนด Tags ให้กับ Test Case เป็นข้อๆ สามารถกำหนด Tags ได้ในระดับ Test Case</p><p>การใช้งานตัวอย่างคร่าวๆตามโค้ดด้านล่าง</p><pre>*** Settings ***<br>Force Tags        Force Tags<br>Default Tags      Default Tags</pre><pre>*** Test Cases ***<br>Test Tags<br>    [Tags]    Test Case Tags</pre><h3>การใช้งาน Tags ในการรัน Robot Framework</h3><p>การใช้งาน สามารถใช้งานได้โดย</p><p>--include หรือ -iรวม Tags ที่กำหนดอยู่ใน Include</p><p>--exclude หรือ -eไม่รวม Tags ที่กำหนดอยู่ใน Exclude</p><h3>การใช้งาน Include test cases by tag</h3><pre>*** Settings ***<br>Force Tags        Regression</pre><pre>*** Test Cases ***<br>First Test Case<br>    [Tags]    First<br>    log    First</pre><pre>Second Test Case<br>    [Tags]    Second<br>    log    Second</pre><pre>Third Test Case<br>    [Tags]    Third<br>    log    Third</pre><p>จากโค้ดตัวอย่างด้านบน</p><pre># รัน Test Case ที่มี Tags &quot;First&quot; ทั้งหมดใน Suite<br>    robot --include First.</pre><pre># รัน Test Case ที่มี Tags &quot;First&quot; และ&quot;Second&quot; ทั้งหมดใน Suite<br>    robot --include FirstANDSecond .</pre><pre># รัน Test Case ที่มี Tags &quot;First&quot; หรือ &quot;Second&quot; ทั้งหมดใน Suite<br>    robot --include FirstORSecond .</pre><pre># รัน Test Case ที่มี Tags &quot;First&quot; แต่ไม่รวม &quot;Second&quot; ทั้งหมดใน Suite<br>    robot --include FirstNOTSecond .</pre><pre># รัน Test Case ที่มี Tags &quot;First&quot; และ &quot;Second&quot; หรือ &quot;Third&quot; ทั้งหมดใน Suite<br>    robot --include FirstANDSecondORThird .</pre><pre># รัน Test Case ที่มี Tags ที่ขึ้นต้นด้วย &quot;F&quot; ทั้งหมดใน Suite<br>    robot --include F* .</pre><pre># รัน Test Case ด้วย Tags ที่ลงท้ายด้วย &quot;d&quot; ทั้งหมดใน Suite<br>    robot --include *d .</pre><h3>การใช้งาน Exclude test cases by tag</h3><pre>*** Settings ***<br>Force Tags        Regression</pre><pre>*** Test Cases ***<br>First Test Case<br>    [Tags]    First<br>    log    First</pre><pre>Second Test Case<br>    [Tags]    Second<br>    log    Second</pre><pre>Third Test Case<br>    [Tags]    Third<br>    log    Third</pre><p>จากโค้ดตัวอย่างด้านบน</p><pre># รัน Test Case ที่ไม่มี Tags &quot;First&quot; ทั้งหมดใน Suite<br>    robot --exclude First.</pre><pre># รัน Test Case ที่ไม่มี Tags &quot;First&quot; และ &quot;Second&quot; ทั้งหมดใน Suite<br>    robot --exclude FirstANDSecond .</pre><pre># รัน Test Case ที่ไม่มี Tags &quot;First&quot; หรือ &quot;Second&quot; ทั้งหมดใน Suite<br>    robot --exclude FirstORSecond .</pre><pre># รัน Test Case ด้วย Tags ที่ไม่ขึ้นต้นด้วย &quot;F&quot; ทั้งหมดใน Suite<br>    robot --exclude F* .</pre><pre># รัน Test Case ด้วย Tags ที่ไม่ลงท้ายด้วย &quot;d&quot; ทั้งหมดใน Suite<br>    robot --exclude *d .</pre><h3>สรุป</h3><p>เราสามารถกำหนดการรัน Tags ได้หลายแบบดังนั้นเราควรกำหนด Tags ให้เหมาะสมเพื่อจัด Group ของ Test Case เพื่อให้ง่ายในการรันมากยิ่งขึ้น</p><p>สามาดูเพิ่มเติมได้ที่นี่</p><p><a href="https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#tagging-test-cases">https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#tagging-test-cases</a></p><h3><strong>Be giving, enjoy sharing. :)</strong></h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a382490eaa6d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[เทคนิคการใช้ For loops ใน Robot Framework]]></title>
            <link>https://setthapong-imsuwan.medium.com/%E0%B9%80%E0%B8%97%E0%B8%84%E0%B8%99%E0%B8%B4%E0%B8%84%E0%B8%81%E0%B8%B2%E0%B8%A3%E0%B9%83%E0%B8%8A%E0%B9%89-for-loops-%E0%B9%83%E0%B8%99-robot-framework-79c5926a6f66?source=rss-cc8c9a201b13------2</link>
            <guid isPermaLink="false">https://medium.com/p/79c5926a6f66</guid>
            <category><![CDATA[automation-testing]]></category>
            <category><![CDATA[robot-framework]]></category>
            <category><![CDATA[for-loop]]></category>
            <dc:creator><![CDATA[Setthapong.Im]]></dc:creator>
            <pubDate>Wed, 01 Jul 2020 10:08:48 GMT</pubDate>
            <atom:updated>2021-12-02T02:39:49.860Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/519/1*MIc3y13lsMOGRY2lH4jIkA.png" /><figcaption>photo credit :<a href="https://robotframework.org/#/">https://robotframework.org/#/</a></figcaption></figure><p>ในบทความนี้จะมาอธิบายเรื่องการใช้ For loops ใน Robot Framework รูปแบบต่างๆ</p><p><a href="https://github.com/robotframework/robotframework/blob/master/doc/userguide/src/CreatingTestData/AdvancedFeatures.rst#for-loops">For loops</a></p><ul><li><a href="https://github.com/robotframework/robotframework/blob/master/doc/userguide/src/CreatingTestData/AdvancedFeatures.rst#old-for-loop-syntax">Old for loop syntax</a></li><li><a href="https://github.com/robotframework/robotframework/blob/master/doc/userguide/src/CreatingTestData/AdvancedFeatures.rst#simple-for-loop">Simple for loop</a></li><li><a href="https://github.com/robotframework/robotframework/blob/master/doc/userguide/src/CreatingTestData/AdvancedFeatures.rst#nested-for-loops">Nested for loops</a></li><li><a href="https://github.com/robotframework/robotframework/blob/master/doc/userguide/src/CreatingTestData/AdvancedFeatures.rst#using-several-loop-variables">Using several loop variables</a></li><li><a href="https://github.com/robotframework/robotframework/blob/master/doc/userguide/src/CreatingTestData/AdvancedFeatures.rst#for-in-range-loop">For-in-range loop</a></li><li><a href="https://github.com/robotframework/robotframework/blob/master/doc/userguide/src/CreatingTestData/AdvancedFeatures.rst#for-in-enumerate-loop">For-in-enumerate loop</a></li><li><a href="https://github.com/robotframework/robotframework/blob/master/doc/userguide/src/CreatingTestData/AdvancedFeatures.rst#for-in-zip-loop">For-in-zip loop</a></li><li><a href="https://github.com/robotframework/robotframework/blob/master/doc/userguide/src/CreatingTestData/AdvancedFeatures.rst#exiting-for-loop">Exiting for loop</a></li><li><a href="https://github.com/robotframework/robotframework/blob/master/doc/userguide/src/CreatingTestData/AdvancedFeatures.rst#continuing-for-loop">Continuing for loop</a></li></ul><h4>ใน Robot Framework สามารถใช้ For loop ได้สองรูปแบบดังนี้</h4><p>แบบที่ 1 สามารถใช้งานได้กับ RF Version 3.1 ขึ้นไป</p><p>แบบที่ 2 สามารถใช้งานได้ใน Version 3.0.x ลงมา และใน Version 3.2.x แต่จะมีการแจ้งเตือนเป็น warning ไว้ครับ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/420/1*WIDYlNise9EGflPLC37Seg.png" /></figure><h4>Simple For loop</h4><p>for loop ประเภทนี้จะวนซ้ำทำงานทีละค่า สามารถระบุค่า ภายใน loop หรือ เก็บข้อมูลในรูปแบบของ List ตามตัวอย่างด้านล่าง</p><pre>Example<br>    FOR    ${no}    IN    one    two    three<br>        Log    ${no}<br>    END<br><br>Example In List<br>    @{NO}    Create List    1    2    3    4<br>    FOR    ${no}    IN    @{NO}<br>        log    ${no}<br>    END</pre><h4>Nested for loops</h4><p>ใน Robot Framework นั้นไม่สามารถเขียน Loop ซ้อนกันได้เหมือนในภาษา Java หรือ ภาษาอื่นๆ ถ้าหากจำเป็นใช้ จำเป็นต้องสร้างเป็น Keyword ขึ้นมาเพื่อใช้งาน หรือเขียน Lib Core Python ขึ้นมาเพื่อใช้งานเพิ่มเติมได้</p><pre>*** Keywords ***<br>Handle Table<br>    [Arguments]    @{table}<br>    FOR    ${row}    IN    @{table}<br>        Handle Row    @{row}<br>    END<br>    <br>Handle Row<br>    [Arguments]    @{row}<br>    FOR    ${cell}    IN    @{row}<br>        Handle Cell    ${cell}<br>    END</pre><h4>Using several loop variables</h4><p>เป็นการใช้ For loop ประเภทหลายตัวแปร</p><pre>Three loop variables<br>    FOR    ${index}    ${noenglish}    ${nothai}    IN<br>    ...     1           one           หนึ่ง<br>    ...     2           two           สอง<br>    ...     3           three         สาม<br>        Log    ${index} ${noenglish} ${nothai}<br>    END</pre><pre>Two loop variables in list<br>    @{EMPLOYERS}    Create List    1    one    หนึ่ง    2    two    สอง<br>    FOR    ${index}    ${english}    ${finnish}    IN    @{EMPLOYERS}<br>        Log    ${index} ${english} ${finnish}<br>    END</pre><h4>For-in-range loop</h4><pre>Only upper limit<br>#     For loop จะเริ่มทำงานตั้งแต่ 0-9<br>    FOR    ${index}    IN RANGE    10<br>        Log    ${index}<br>    END</pre><pre>Start and end<br>#    For loop จะเริ่มทำงานที่ตำแหน่ง 5-10<br>#    สามารถใส่ +1 เพิ่มได้ถ้าหากต้องการให้ Loop ทำงานถึง 11 รอบ<br>    FOR    ${index}    IN RANGE    5    11<br>        Log    ${index}<br>    END</pre><pre>Also step given<br>#    เป็นการกำหนดตำแหน่งให้ Loop โดยจะทำงาน 3 รอบ ใน index ที่ 5,26,10<br>#    สามารถกำหนด ให้ตำแหน่งเป็น - ได้โดยใส่ เครื่องหมาย -5 , -26<br>    FOR    ${index}    IN RANGE    5    26    10<br>        Log    ${index}<br>    END</pre><h4>For-in-enumerate loop</h4><p>มีหลักการทำงานเหมือน Simple loop ทั่วไป แต่จะมีการรีเทิร์นค่า index ของ Loop ออกมาด้วย เหมาะสำหรับหากภายในลูป มี Keyword ที่ต้องการตำแหน่งไปใช้ต่อ ทำให้เราสามารถเขียน loop ได้สั้นลง</p><pre>For-in-enumerate<br>    FOR    ${index}    ${item}    IN ENUMERATE    1    2    3    4    <br>        Log    ${index}<br>        Log    ${item}<br>    END</pre><h4>For-in-zip loop</h4><p>เป็นคำสั่งสำหรับใช่รวม 2 lists จับคู่เป็น lists เดียวกันและจะทำงาน วนลูบจำนวนรอบเท่ากับ lists ที่สั้นที่สุด<br>ตัวอย่างเช่น</p><pre>*** Variables ***<br>@{ABC}           a    b    c<br>@{XYZ}           x    y    z<br>@{NUM}           1    2    3    4    5<br><br>*** Test Cases ***<br>For-in-zip with multiple lists<br>    FOR    ${a}    ${x}    ${n}    IN ZIP    ${ABC}    ${XYZ}    ${NUM}<br>        Log Many    ${a}    ${x}    ${n}<br>    END<br><br>For-in-zip with one variable<br>    FOR    ${items}    IN ZIP    ${ABC}    ${XYZ}    ${NUM}<br>        Length Should Be    ${items}    3<br>        Log Many    ${items}[0]    ${items}[1]    ${items}[2]<br>    END</pre><h4>Exiting for loop</h4><p>หลักการทำงานคือ จะมีเงื่อนไขดักอยู่ใน for loop เพื่อให้หลุดลูบก่อนถึงรอบที่จะกำหนด โดยการกำหนดเงื่อนไข ตามตัวอย่างด้านล่าง สามารถออกจาก for loop ได้ 2 Keyword คือ <a href="https://robotframework.org/robotframework/latest/libraries/BuiltIn.html#Exit%20For%20Loop"><strong>Exit For Loop</strong></a><strong> , </strong><a href="https://robotframework.org/robotframework/latest/libraries/BuiltIn.html#Exit%20For%20Loop%20If"><strong>Exit For Loop If</strong></a></p><pre>*** Test Cases ***<br>Exiting for loop<br>    FOR    ${var}    IN    a    b    c<br>        Run Keyword If    &#39;${var}&#39;==&#39;c&#39;    Exit For Loop<br>        Exit For Loop If    &#39;${var}&#39;==&#39;c&#39;<br>        log    ${var}<br>    END</pre><h4>Continuing for loop</h4><p>หลักการทำงานคือ เมื่อ For loop ทำงานถึง Keyword <a href="https://robotframework.org/robotframework/latest/libraries/BuiltIn.html#Continue%20For%20Loop"><strong>Continue For Loop</strong></a><strong> , </strong><a href="https://robotframework.org/robotframework/latest/libraries/BuiltIn.html#Continue%20For%20Loop%20If"><strong>Continue For Loop If</strong></a><strong> </strong>For loop จะข้ามไปทำงาน รอบถัดไปทันทีหากเข้าเงื่อนไข ตามตัวอย่างด้านล่างนี้ การทดสอบจะไม่ Fail เพราะว่า เราใส่ Continue For Loop ให้ทำงานในรอบถัดไปก่อนที่จะถึงคำสั่ง Fail และจะหยุดทำงานเมื่อรันครบ 1000 รอบ</p><pre>Continue Example<br>    FOR    ${index}    IN RANGE    1000<br>        Continue For Loop<br>        Fail<br>    END</pre><p>หากต้องการดูข้อมูลเพิ่มเติมสามารถดูได้ที ลิ้งด้านล่างครับ</p><p><a href="https://github.com/robotframework/robotframework/blob/master/doc/userguide/src/CreatingTestData/AdvancedFeatures.rst#id70">robotframework/robotframework</a></p><h3>สรุป</h3><p>ใน Robot Framework นั้นจะมี For loop ทั้งแบบใหม่และแบบเก่า ควรใช้ Robot Framework ในเวอชั่นที่เหมาะสมกับการใช้งาน และใน Robot Framework V 4.0 จะสามารถใช้ ลูป ซ้อน ลูป ได้ตามลิ้งด้านล่าง</p><h3><a href="https://setthapong-imsuwan.medium.com/robot-framework-4-0-new-for-loops-syntax-62d524729d98">Robot Framework 4.0 New For loops Syntax</a></h3><p><strong>Be giving, enjoy sharing. :)</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=79c5926a6f66" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Robot Framework DateTime Library]]></title>
            <link>https://setthapong-imsuwan.medium.com/robot-framework-datetime-library-1ca48b9797b5?source=rss-cc8c9a201b13------2</link>
            <guid isPermaLink="false">https://medium.com/p/1ca48b9797b5</guid>
            <category><![CDATA[date]]></category>
            <category><![CDATA[time]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[automation-testing]]></category>
            <category><![CDATA[robot-framework]]></category>
            <dc:creator><![CDATA[Setthapong.Im]]></dc:creator>
            <pubDate>Tue, 10 Mar 2020 10:51:58 GMT</pubDate>
            <atom:updated>2020-03-10T10:51:58.132Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/853/1*GEmepbm4-PtnWUvS2FkVGw.png" /><figcaption><a href="https://thematter.co/">https://thematter.co</a> ,<a href="https://www.mindphp.com/">https://www.mindphp.com</a>, <a href="https://robotframework.org/">https://robotframework.org/</a></figcaption></figure><p>DateTime เป็น Library สำหรับจัด สำหรับการจัดการค่าวันที่และเวลาใน Robot Framework เริ่มต้นใช้งานโดย</p><p>Import Library</p><pre>*** Settings ***<br>Library    DateTime</pre><p>หลังจาก Import เรียบร้อยแล้ว ก่อนอื่นเราต้องรู้จัก Date Time Format ของ Python ก่อน เพื่อให้เข้าใจรูปแบบการ Convert Date Time มากขึ้นในการแปลงเวลาขาเข้าและขาออก สามารถดูตัวอย่างการใช้งานได้ที่ <a href="https://docs.python.org/2/library/datetime.html">https://docs.python.org/2/library/datetime.html</a></p><p>Example</p><pre>${datetime} = <em>Convert Date</em> 09-03-2020 date_format=%d-%m-%Y result_format=datetime<br><em>Convert Date  20.02.2020 02:20  date_format=%d.%m.%Y %H:%M</em></pre><p>Time String ที่สามารถใช้ได้</p><ul><li>days, day, d</li><li>hours, hour, h</li><li>minutes, minute, mins, min, m</li><li>seconds, second, secs, sec, s</li><li>milliseconds, millisecond, millis, ms</li></ul><p>Example</p><pre>${date} =  Add Time To Date  2020-02-28 12:05:03.111  7 days<br>${time} =  Add Time To Time  3 hours 5 minutes  01:02:03<br>${date} =  Get Current Date  UTC  - 5 hours</pre><p>การดึงค่าจาก Python Date Time</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/497/1*yV0cct6nCHP6MEDq6zfSYQ.png" /><figcaption>photo credit : <a href="https://robotframework.org/robotframework/latest/libraries/DateTime.html#Time%20formats">https://robotframework.org/robotframework/latest/libraries/DateTime.html#Time%20formats</a></figcaption></figure><h4>ในส่วนของ Keywords จะแบ่งเป็น สามกลุ่มคือ</h4><ol><li>การ บวก วันที่และเวลา</li><li>การ ลบ วันที่และเวลา</li><li>การ Convert วันที่และเวลา</li></ol><h4>1. การ บวก วันที่และเวลา</h4><p><a href="https://robotframework.org/robotframework/latest/libraries/DateTime.html#Add%20Time%20To%20Date">Add Time To Date</a> · <a href="https://robotframework.org/robotframework/latest/libraries/DateTime.html#Add%20Time%20To%20Time">Add Time To Time</a></p><p><strong>Add Time </strong>To <strong>Date เพิ่ม เวลาด้วยวันที่ และ return ค่าในรูปแบบ </strong><a href="http://robotframework.org/robotframework/latest/libraries/DateTime.html#Date%20formats">Date formats</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/790/1*AUtDrH1wDRi9kBL_NO3Qug.png" /></figure><pre><br>${DATE}  DateTime.Add Time To Date  09/03/2020  1 days    date_format=%d/%m/%Y    result_format=%d/%m/%Y<br>Should Be Equal    ${DATE}    10/03/2020</pre><p><strong>Add Time </strong>To <strong>Time เพิ่ม เวลาด้วยเวลา และ return ค่าในรูปแบบ </strong><a href="https://robotframework.org/robotframework/latest/libraries/DateTime.html#Time%20formats">Time formats</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*S7iQO_PXMMBeb36dM_oHhQ.png" /></figure><pre>${TIME} DateTime.Add Time To Time 1 hour 3 hours 5 minutes timer exclude_millis=yes <br>Should Be Equal ${TIME} 04:05:00</pre><h4>2. การ ลบ วันที่และเวลา</h4><p><a href="http://robotframework.org/robotframework/latest/libraries/DateTime.html#Subtract%20Date%20From%20Date">Subtract Date From Date</a> · <a href="http://robotframework.org/robotframework/latest/libraries/DateTime.html#Subtract%20Time%20From%20Date">Subtract Time From Date</a> · <a href="http://robotframework.org/robotframework/latest/libraries/DateTime.html#Subtract%20Time%20From%20Time">Subtract Time From Time</a></p><p><strong>Subtract Date From Date ลบวันที่ ด้วยวันที่ หรือ เวลาก็ได้ Keywords Return ค่าออกมาเป็นค่าระหว่าง สองช่วงเวลาที่ลบกัน</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/706/1*wcTkP1hqzbaj6K-eWI5tNQ.png" /></figure><pre>${DATE}    Subtract Date From Date    <em>2020-05-28 12:05:52    2020-02-20 12:05:52    verbose<br></em>Should Be Equal    ${DATE}    <em>98 days<br></em>${TIME}    Subtract Date From Date    <em>2020-02-20 12:00:00    2020-02-20 13:00:00    verbose<br></em>Should Be Equal    ${TIME}    <em>1 hour<br></em>${DATEANDTIME}    Subtract Date From Date    <em>2020-02-20 12:00:00    2020-02-15 13:00:00    verbose<br></em>Should Be Equal    ${DATEANDTIME}    <em>4 days 23 hours</em></pre><p><strong>Subtract Time From Date </strong>ลบเวลาด้วยวันที่ และ return ค่าในรูปแบบ<strong> </strong><a href="http://robotframework.org/robotframework/latest/libraries/DateTime.html#Date%20formats">Date formats</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/528/1*jiThiqSL5Nh-LGWFg5ChdQ.png" /></figure><pre>${DATEANDTIME}    Subtract Time From Date    <em>2020-02-20 12:00:00    7 days<br></em>Should Be Equal    ${DATEANDTIME}    <em>2020-02-13 12:00:00</em></pre><p><strong>Subtract Time From Time </strong>ลบเวลาด้วยเวลา และ return ค่ากลับในรูปแบบ<strong> </strong><a href="https://robotframework.org/robotframework/latest/libraries/DateTime.html#Time%20formats">Time formats</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/496/1*_dTiYxyIY7BhBHNoUrQkQQ.png" /></figure><pre>${TIME}    Subtract Time From Time    <em>01:00:00    100<br></em>Should Be Equal    ${TIME}    ${3500.0}<br>${TIME}    Subtract Time From Time    <em>01:00:00    100    compact<br></em>Should Be Equal    ${TIME}    <em>58min 20s</em></pre><h4>3. การ Convert วันที่และเวลา</h4><p><a href="http://robotframework.org/robotframework/latest/libraries/DateTime.html#Convert%20Date">Convert Date</a> · <a href="http://robotframework.org/robotframework/latest/libraries/DateTime.html#Convert%20Time">Convert Time</a></p><p><strong>Convert Date </strong>แปลงวันที่ อยู่ในรูปแบบของ <a href="http://robotframework.org/robotframework/latest/libraries/DateTime.html#Date%20formats">date formats</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/644/1*LCo3xWpDfrNzulpDNwwGTA.png" /></figure><pre>${DATE}    Convert Date    <em>20/02/2020    date_format=%d/%m/%Y    result_format=%A/%m/%y<br></em>Should Be Equal    ${DATE}    <em>Thursday/02/20<br></em>${DATE}    Convert Date    <em>20/02/2020    date_format=%d/%m/%Y    result_format=%a<br></em>Should Be Equal    ${DATE}    <em>Thu<br></em>${DATE}    Convert Date    <em>20/02/2020    date_format=%d/%m/%Y    result_format=%A/%B/%y<br></em>Should Be Equal    ${DATE}    <em>Thursday/February/20<br></em>${DATE}    Convert Date    <em>20/02/2020    date_format=%d/%m/%Y    result_format=%d-%m-%Y<br></em>Should Be Equal    ${DATE}    <em>20-02-2020</em></pre><p><strong>Convert Time </strong>แปลงเวลาอยู่ในรูปแบบของ<strong> </strong><a href="https://robotframework.org/robotframework/latest/libraries/DateTime.html#Time%20formats">Time formats</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/435/1*GbMMn-IELm-xT40B9KCELw.png" /></figure><pre>${TIME}    Convert Time    <em>01:00:00<br></em>Should Be Equal    ${TIME}    ${3600.0}<br>${TIME}    Convert Time    <em>01:00:00    verbose<br></em>Should Be Equal    ${TIME}    <em>1 hour<br></em>${TIME}    Convert Time    <em>01:10:20    verbose<br></em>Should Be Equal    ${TIME}    <em>1 hour 10 minutes 20 seconds</em></pre><h3>สรุป</h3><p>DateTime เป็น Library สำหรับจัดการค่าวันที่และเวลาใน Robot Framework สำหรับเพิ่ม ลบ แปลงค่า และข้อสำคัญของ Library ตัวนี้คือการเข้าใจในการแปลงค่า date_format และ result_format ให้ตรง หากเราใช้งานผิด format จะทำให้ script ของเรา Error ได้</p><blockquote><strong><em>Be giving, enjoy sharing. :)</em></strong></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1ca48b9797b5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[เทคนิคการใช้ Robot Framework update CSV file by row and column]]></title>
            <link>https://setthapong-imsuwan.medium.com/%E0%B9%80%E0%B8%97%E0%B8%84%E0%B8%99%E0%B8%B4%E0%B8%84%E0%B8%81%E0%B8%B2%E0%B8%A3%E0%B9%83%E0%B8%8A%E0%B9%89-robot-framework-update-csv-file-by-row-and-column-e8036aec4741?source=rss-cc8c9a201b13------2</link>
            <guid isPermaLink="false">https://medium.com/p/e8036aec4741</guid>
            <category><![CDATA[robot-framework]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[automation-testing]]></category>
            <dc:creator><![CDATA[Setthapong.Im]]></dc:creator>
            <pubDate>Fri, 03 Jan 2020 09:44:38 GMT</pubDate>
            <atom:updated>2020-01-03T09:44:38.585Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/741/1*sp8Zx9xmX9k2DDiO2B2FdA.png" /></figure><p>เริ่มจากปัญหาคือ ปกติแล้วถ้าหากเราต้องการจะใส่ข้อมูลลงใน CSV ส่วนใหญ่จะใช้คำสั่ง <a href="https://rawgit.com/s4int/robotframework-CSVLibrary/master/doc/CSVLibrary.html#Append%20To%20Csv%20File"><strong>Append To Csv File</strong></a><strong> </strong>โดยปกติแล้วข้อมูลที่เราเพิ่มเข้าไปจะเข้าไปต่อท้ายสุดของบรรทัด ไม่สามารถใส่ด้วย row และ column แบบ excel ได้ และการใส่ข้อมูลลงใน CSV ต้องใส่ด้วยข้อมูลประเภท list of tuple</p><p>เริ่มต้นการอ่าน CSV นั้นสามารถทำได้ 2 แบบด้วยกันคือ</p><ul><li><a href="https://rawgit.com/s4int/robotframework-CSVLibrary/master/doc/CSVLibrary.html#Read%20Csv%20File%20To%20Associative"><strong>Read Csv File To Associative</strong></a><strong> </strong>อ่าน CSV มาเก็บอยู่ในรูปแบบของ list of dict</li><li><a href="https://rawgit.com/s4int/robotframework-CSVLibrary/master/doc/CSVLibrary.html#Read%20Csv%20File%20To%20List"><strong>Read Csv File To List</strong></a><strong> </strong>อ่าน CSV มาเก็บอยู่ในรูปแบบของ list of tuples</li></ul><p>ในบทความนี้ผู้เขียนจะเลือกใช้วิธี ที่สองคือ <a href="https://rawgit.com/s4int/robotframework-CSVLibrary/master/doc/CSVLibrary.html#Read%20Csv%20File%20To%20List"><strong>Read Csv File To List</strong></a></p><h4>สิ่งที่ต้องเตรียม</h4><p>ติดตั้ง</p><ul><li>robotframework</li><li>robotframework-csvlibrary</li><li>Python 2.xx</li></ul><h4>ข้อมูลใน data.csv</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/429/1*71GGBI6l9qPtionmYrfyrQ.png" /></figure><h4>UpdateCSV.robot</h4><p>รูปแบบของการเขียน Test Case จำเป็นต้องระบุ Parameters ทั้งหมด 4 ตัว</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/696/1*Bygrx_DBTRugyBJEaVqOog.png" /></figure><p>การเขียน Keyword เบื้องต้นจำเป็นต้องรับค่าทั้งหมด 4 ค่า คือ</p><pre>pathFile    =   path สำหรับ CSV File <br>columnName  =   column ที่ต้องการอัพเดท ชื่อจะต้องตรงกับ column ใน CSV<br>rowIndex    =   Index ที่ต้องการจะใส่ค่าใน CSV File <br>value       =   ค่าที่ต้องการจะอัพเดทลงใน csvfile</pre><p>การทำงานของ Keywords เบื้องต้นจะอ่าน Csv File มาเก็บอยู่ในรูปแบบของ List และลบข้อมูลทั้งหมดออกจาก Csv Fileทำการอัพเดทข้อมูลทั้งหมด ลงใน List และทำการ Update ค่าทั้งหมดกลับเข้า Csv File ผ่าน Keyword <a href="https://rawgit.com/s4int/robotframework-CSVLibrary/master/doc/CSVLibrary.html#Append%20To%20Csv%20File"><strong>Append To Csv File</strong></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/698/1*lS2lA2YtzUbRu4Msk-ZpFA.png" /></figure><p>หลังจากทดลองรันดูแล้วจะได้ผลตามรูปด้านล่างครับ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/681/1*3e6ULfXk-D7HqhJ_lrMZNg.png" /></figure><p>เปิดไฟล์ Csv ขึ้นมาดูจะพบว่าค่าทั้งหมดที่เราอัพเดทเข้าไปตามรูปด้านล่างครับ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/436/1*SNQHqvkGhHB6SR3eyPBa3w.png" /></figure><h3>สรุป</h3><p>การใช้งานในเบื้องต้นนั้น สามารถใช้งานได้หลากหลายกว่าการใช้งานผ่าน Keyword <a href="https://rawgit.com/s4int/robotframework-CSVLibrary/master/doc/CSVLibrary.html#Append%20To%20Csv%20File"><strong>Append To Csv File</strong></a><strong> </strong>โดยข้อมูลจะเข้าไปต่อท้ายเท่านั้น โดยการเขียน Keyword นี้จะเข้ามาแก้ไขเรื่องการที่จะต้องการ Update ข้อมูลใน Csv File ที่มีอยู่เดิม และเพิ่มข้อมูลผ่าน row และ column ได้</p><blockquote><strong>Be giving, enjoy sharing. :)</strong></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e8036aec4741" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Robot Framework Parallel run with Pabot]]></title>
            <link>https://setthapong-imsuwan.medium.com/robot-framework-parallel-run-with-pabot-29ed75c0bfe3?source=rss-cc8c9a201b13------2</link>
            <guid isPermaLink="false">https://medium.com/p/29ed75c0bfe3</guid>
            <category><![CDATA[robot-framework]]></category>
            <category><![CDATA[automation-testing]]></category>
            <dc:creator><![CDATA[Setthapong.Im]]></dc:creator>
            <pubDate>Tue, 13 Aug 2019 09:31:07 GMT</pubDate>
            <atom:updated>2019-08-13T09:31:07.797Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/378/0*VYGLhEBWs4SU9srJ.png" /><figcaption>photo credit : <a href="https://github.com/mkorpela/pabot">https://github.com/mkorpela/pabot</a></figcaption></figure><p>Pabot เป็น Tool สำหรับจัดการ parallel run Robot Framework ทำให้รันหลายๆการทดสอบพร้อมกันได้</p><h4>สิ่งที่ควรรู้ก่อนจะใช้งาน Pabot</h4><ol><li>Pabot จะ Default parallel test จาก test suite ของ robot framework</li><li>ใช้คำสั่ง --testlevelsplit กรณีต้องการรันในระดับ test level</li><li>ในแต่ละ test suite ที่ parallel ต้องระวังไม่ให้มี <strong>dependency</strong> ต่อกัน เช่น testsuite1 และ testsuite2 ทำการ Login ด้วย user pass เดียวกัน แต่ระบบนั้น มีการตรวจสอบ ให้ใช้ได้เพียง session เดียวเท่านั้น อาจจะให้ testsuite อันใดอันหนึ่ง fail ได้</li></ol><p>ติดตั้งด้วยคำสั่ง</p><pre>pip install -U robotframework-pabot</pre><p>หลังจากติดตั้งเรียบร้อยแล้ว ลองทำการสร้าง Test suite ขึ้นมา 4 test suite</p><p>Parallel1.robot</p><pre>*** Settings ***<br>Library           SeleniumLibrary</pre><pre>*** Test Cases ***<br>Open Google<br>    Open Browser    <a href="https://www.google.co.th/">https://www.google.co.th/</a><br>    Maximize Browser Window<br>    Capture Page Screenshot<br>    Close Browser</pre><p>Parallel2.robot</p><pre>*** Settings ***<br>Library           SeleniumLibrary</pre><pre>*** Test Cases ***<br>Search Google<br>    Open Browser    <a href="https://www.google.co.th/">https://www.google.co.th/</a><br>    Input Text    //input[<a href="http://twitter.com/name">@name</a>=&#39;q&#39;]    Robot Framework<br>    Press Keys    //input[<a href="http://twitter.com/name">@name</a>=&#39;q&#39;]    ENTER<br>    Capture Page Screenshot<br>    Close Browser</pre><p>Parallel3.robot</p><pre>*** Settings ***<br>Library           SeleniumLibrary</pre><pre>*** Test Cases ***<br>Open Robot Framework<br>    Open Browser    <a href="https://robotframework.org/">https://robotframework.org/</a><br>    Maximize Browser Window<br>    Capture Page Screenshot<br>    Close Browser</pre><p>Parallel4.robot</p><pre>*** Settings ***<br>Library           SeleniumLibrary</pre><pre>*** Test Cases ***<br>Verify Robot Framework<br>    Open Browser    <a href="https://robotframework.org/">https://robotframework.org/</a><br>    Wait Until Page Contains    ROBOT FRAME WORK/<br>    Capture Page Screenshot<br>    Close Browser</pre><p>ทดลองรันด้วยคำสั่ง Robot แบบ ปกติ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/836/1*mSihS5ZePttGnG-H5G8ALg.png" /></figure><p>จากรูปจะเห็นได้ว่า เมื่อ รันทั้ง 4 testsuite พร้อมกันจะใช้เวลาโดยประมาน 45 วินาที หลังจากนั้นลองเปลี่ยนวิธีการรันโดนใช้คำสั่ง Pabot ตามรูปด้านล่าง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/965/1*5h5kqLBHHL1DV4PGlqGbbw.png" /></figure><p>จากรูปจะเห็นได้ว่า หลังจากรันครบทั้ง 4 testsuite Elapsed time ลดลงจาก 45 วินาที เป็น 24 วินาที โดยใช้เวลาลดลง เกือบ 45% แต่เวลาในการรันแต่ละข้อเพิ่มขึ้นเล็กน้อย ทั้งนี้ความเร็วในการรัน Parallel นั้นขึ้นอยู่กับ การประมวลผลของ CPU และ ENV การรัน และควรกำหนดให้เหมาะสม กับ Spec ของเครื่องที่ใช้รันด้วย</p><p><strong>สามารถดูการใช้งานอื่นๆ เพิ่มเติมได้ที่</strong></p><p><a href="https://github.com/mkorpela/pabot">https://github.com/mkorpela/pabot</a></p><blockquote>Be giving, enjoy sharing. :)</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=29ed75c0bfe3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Robot Framework Suite Setup , Teardown and Test Case Setup , Teardown]]></title>
            <link>https://setthapong-imsuwan.medium.com/robot-framework-suite-setup-teardown-and-test-case-setup-teardown-5b9be0414f33?source=rss-cc8c9a201b13------2</link>
            <guid isPermaLink="false">https://medium.com/p/5b9be0414f33</guid>
            <category><![CDATA[automated-testing]]></category>
            <category><![CDATA[robot-framework]]></category>
            <dc:creator><![CDATA[Setthapong.Im]]></dc:creator>
            <pubDate>Mon, 05 Aug 2019 09:05:06 GMT</pubDate>
            <atom:updated>2019-08-05T09:05:06.305Z</atom:updated>
            <content:encoded><![CDATA[<h3>Robot Framework Suite Setup , Teardown and Test Case Setup , Teardown</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*GY4xV95YaYdNBVfq.png" /><figcaption>photo credit : <a href="https://robotframework.org/">https://robotframework.org/</a></figcaption></figure><p>ก่อนอื่นเรามาดูกันก่อนว่า Robot Framework มี Setup และ Tear down แบบไหนกันบ้าง</p><pre>*** Settings ***<br>Suite Setup       Log    <em>Suite Setup<br></em>Suite Teardown    Log    <em>Suite Teardown<br></em>Test Setup        Log    <em>Test Setup<br></em>Test Teardown     Log    <em>Test Teardown<br><br></em>*** Test Cases ***<br>Test<br>    <strong><em>[Setup]    </em></strong>Log    <em>Test Case Setup<br>    </em>log    <em>Test Step<br>    </em><strong><em>[Teardown]    </em></strong>Log    <em>Test Case Teardown</em></pre><p>จากโค้ดด้านบนจะเห็นได้ว่า เรามีทั้ง ในส่วนของ Setting ที่อยู่ในระดับ Suite และ Test Cases ทีนี้เรามาดูกันว่าแต่ละแบบต่างกันยังไง</p><pre>*** Settings ***<br>Suite Setup # ทำงานก่อนที่จะรัน Test Cases ทั้งหมด<em><br></em>Suite Teardown # ทำงานหลังจากรัน Test Cases ทั้งหมด<em><br></em>Test Setup # ทำงานก่อนที่จะรัน Test Cases ทุกครั้งตามจำนวน Testcase<em><br></em>Test Teardown # ทำงานะหลังรัน Test Cases เสร็จทุกครั้งตามจำนวน Testcase</pre><p>ทีนี้เรามาดูในส่วนของ Test Cases กันบ้าง</p><pre>*** Test Cases ***<br>Test<br>    <strong><em>[Setup] # </em></strong>ทำงานก่อนที่จะรัน Test Case ทุกครั้ง<em><br>    </em><strong><em>[Teardown] # </em></strong>ทำงานะหลังรัน Test Case เสร็จทุกครั้ง</pre><p>Test Cases Setup และ Teardown นั้นมีเงื่อนไขอยู่ว่า ถ้าหากเราใส่ Suite Test Setup และ Teardown Robot Framework นั้นจะทำงานเฉพาะในส่วนของ Test Cases Setup และ Teardown เท่านั้น และไม่ทำงานในส่วนของ Suite Test Setup และ Teardown ตัวอย่างจาก โค้ดด้านล่าง</p><pre>*** Settings ***<br>Suite Setup       Log    <em>Suite Setup<br></em>Suite Teardown    Log    <em>Suite Teardown<br></em>Test Setup        Log    <em>Test Setup<br></em>Test Teardown     Log    <em>Test Teardown<br><br></em>*** Test Cases ***<br>Test<br>    <strong><em>[Setup]    </em></strong>Log    <em>Test Case Setup<br>    </em>log    ${EMPTY}<br>    <strong><em>[Teardown]    </em></strong>Log    <em>Test Case Teardown</em></pre><p>ทดสอบการใส่ Test Cases Setup และ Teardown พร้อมกับ Suite Test Setup และ Teardown</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/617/1*g4HAuPlomREfU6F8PeT1gg.png" /></figure><p>จาก ภาพจะเห็นได้ว่า Log ที่ออกมาจะไม่มีในส่วนของ Suite Test Setup และ Teardown ดังนั้นการนำไปใช้ ควรดูรูปแบบให้เหมาะสมกับการใช้งานในแต่ละแบบ</p><h3>ข้อสังเกตุเกี่ยวกับการใช้ Setup And Tear down</h3><ol><li>หากต้องการใช้ หลายๆ Keyword ให้ใช้ Run Keywords หรือ Group เป็น Keyword ใหม่</li><li>Teardown จะสามารถทำงานต่อไปได้จนจบ หากมี Keyword อันใดอันหนึ่ง ภายใน Teardown Fail (setup ไม่สามารถใช้ได้)</li></ol><p>สามารถดูเพิ่มเติมได่ที่นี่ <a href="https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#test-setup-and-teardown">https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#test-setup-and-teardown</a></p><blockquote><em>Be giving, enjoy sharing. :)</em></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5b9be0414f33" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[การสร้าง Firefox Profile ด้วย Robot Framework กรณีทดสอบ Download Files]]></title>
            <link>https://setthapong-imsuwan.medium.com/%E0%B8%81%E0%B8%B2%E0%B8%A3%E0%B8%AA%E0%B8%A3%E0%B9%89%E0%B8%B2%E0%B8%87-firefox-profile-%E0%B8%94%E0%B9%89%E0%B8%A7%E0%B8%A2-robot-framework-%E0%B8%81%E0%B8%A3%E0%B8%93%E0%B8%B5%E0%B8%97%E0%B8%94%E0%B8%AA%E0%B8%AD%E0%B8%9A-download-files-27199eefbd0b?source=rss-cc8c9a201b13------2</link>
            <guid isPermaLink="false">https://medium.com/p/27199eefbd0b</guid>
            <category><![CDATA[firefox]]></category>
            <category><![CDATA[test-automation]]></category>
            <category><![CDATA[robot-framework]]></category>
            <dc:creator><![CDATA[Setthapong.Im]]></dc:creator>
            <pubDate>Tue, 14 May 2019 10:31:31 GMT</pubDate>
            <atom:updated>2019-05-14T10:42:04.570Z</atom:updated>
            <content:encoded><![CDATA[<p>จากการใช้งาน Robot Framework หลายคนอาจจะพบปัญหากับการทดสอบกรณีที่มีการ Download File และไม่สามารถกด Firefox Download Popup ได้ หรือจำเป็นต้องใช้คำสั่งอื่น เช่น AutoItLibrary.Send มาช่วยในการกด Popup Download วันนี้มีทางเลือกสำหรับช่วยในการ Download File ให้ง่ายยิ่งขึ้น ด้วยการสร้าง Firefox Profile</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/435/1*86ZMoW_C_oCPaSM9mnx6Sw.png" /></figure><p>การสร้าง Profile Firefox ด้วย Robot Framework ตามโค้ดด้านล่าง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/748/1*e7nnYuhfESydEjuj4OE_OQ.png" /></figure><p>หลังจากสร้าง Profile ได้แล้ว ให้เราเพิ่ม code ในส่วน Create Profiles สำหรับ การที่จะให้ Profile ของเราทำการ Auto Download File ลงมาให้ ในที่นี้เราสามารถเลือกได้ว่าจะให้ Profiles จะ Download File Type ของเราอย่างไร</p><ul><li><strong>Preview in Filefox-&gt; </strong>จะแสดงตัวอย่างไฟล์บน Firefox ก่อน</li><li><strong>Always ask -&gt; </strong>จะแสดงป๊อบอัพให้เราเลือกว่าจะ เปิดด้วยอะไรหรือ เซฟไฟล์ไปที่ไหน</li><li><strong>Save File -&gt; </strong>ระบบจะ Auto Save File ไปตาม Path ที่ Set ไว้ใน Firefox *** โดยผู้เขียนจะเลือกใชิวิธีนี้ ***</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/341/1*we6OGA2GcLvByoYS2XNhaw.png" /></figure><p>หลังจากเรารู้จักรูปแบบการ Save File ของ Firefox แล้วทีนี้มาดูในส่วนของโค้ดกันบ้าง</p><ul><li>เส้นสีแดง = การกำหนด path download ให้กับ Profile Firefox</li><li>เส้นสีเหลือง = การกำหนดว่าเราจะ Download อัตโนมัติโดยการ Save File ในที่นี้ผู้เขียนกำหนด File Type ดังนี้ .doc .docx .xls .xlsx</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/943/1*kryji27QVe5VPj9N26MKNw.png" /></figure><p>ผลจากการรันทดสอบ Script Robot Framework ทั้ง 4 File ได้ผลตามภาพด้านล่าง โดย Profile จะเซฟไฟล์ลงตาม Path ของเราที่กำหนดไว้ ตามภาพด้านล่าง</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/958/1*21ru2J-pbUJj_wRLhXRZCA.png" /></figure><p>นอกจาก Documents Files แล้วเรายังสามารถกำหนดให้เป็น File Type อื่นๆได้อีกเช่น VDO Files, Audio Files, Image Files โดยเราสามารถดู MIME types ของ File ต่างเพิ่มเติมได้ที่</p><ul><li><a href="https://file-examples.com/">https://file-examples.com/</a></li><li><a href="https://www.freeformatter.com/mime-types-list.html">https://www.freeformatter.com/mime-types-list.html</a></li></ul><p>การกำหนด Firefox Preference เพื่อเซ็ตค่าต่างๆให้กับ Firefox Profile ของเราสามารถดูการตั้งค่าเพิ่มเติมได้ที่</p><ul><li><a href="http://kb.mozillazine.org/About:config_entries">http://kb.mozillazine.org/About:config_entries</a></li></ul><h3>สรุป</h3><p>จากบทความนี้ ก็เป็นทางเลือกหนึ่งสำหรับใช้ Robot Framework สร้างกรณีทดสอบที่มีการ Download File ต่างๆ ลงใน path ที่ทำการ Config ไว้ นอกจากนี้แล้วเรายังสามารถกำหนดค่า ต่างๆให้กับ Firefox Profile ของเราเพิ่มขึ้นได้อีกด้วย</p><blockquote><em>Be giving, enjoy sharing. :)</em></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=27199eefbd0b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[เทคนิคการใช้ Robot Framework Argument]]></title>
            <link>https://setthapong-imsuwan.medium.com/%E0%B9%80%E0%B8%97%E0%B8%84%E0%B8%99%E0%B8%B4%E0%B8%84%E0%B8%81%E0%B8%B2%E0%B8%A3%E0%B9%83%E0%B8%8A%E0%B9%89-robot-framework-argument-5ae58b7f580c?source=rss-cc8c9a201b13------2</link>
            <guid isPermaLink="false">https://medium.com/p/5ae58b7f580c</guid>
            <category><![CDATA[automation-testing]]></category>
            <category><![CDATA[arguments]]></category>
            <category><![CDATA[robot-framework]]></category>
            <dc:creator><![CDATA[Setthapong.Im]]></dc:creator>
            <pubDate>Fri, 03 May 2019 03:18:08 GMT</pubDate>
            <atom:updated>2019-05-03T03:18:08.684Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/745/1*I-LkKE_BHsGLpSB03vgQwg.png" /><figcaption>photo credit : <a href="https://robotframework.org/">https://robotframework.org/</a></figcaption></figure><p>ในการใช้ Arguments ใน Robot Framework นั้นจะแบ่งออกเป็น 4 แบบหลักๆคือ <strong>Positional</strong>, <strong>Named</strong>, <strong><em>Vararg</em></strong>, <strong>Kwargs </strong>ในบทความด้านล่างจะอธิบายการใช้งานและข้อแตกต่างกันระหว่าง การใช้งานทั้ง 4 แบบ</p><p><strong>Positional </strong>การใช้ตัวแปรแบบนี้จะเหมาะกับ การรับค่าที่รู้ตำแหน่งแน่นอนไม่สามารถเปลี่ยนแปลงได้</p><pre>My Keyword<br>    [Arguments]    ${arg1}    ${arg2}    ${arg3}</pre><p><strong>Named </strong>คล้ายๆกับ การกำหนดค่า Default ให้กับ Arguments ของเราเหมาะกับการรับค่าที่ ระบุค่าหรือไม่ระบุก็ได้ ระบบจะ Default ให้ค่าเป็นที่กำหนดไว้</p><pre>My Keyword<br>    [Arguments]    ${arg}=default</pre><p><strong><em>Vararg </em></strong>เหมาะกับการใช้ในกณีที่ไม่รู้จำนวนสิ้นสุดของ Arguments ที่จะรับเข้ามา โดยการใช้งานส่วนใหญ่จะรับ Arguments เข้ามาเป็น lists แล้ว ทำการ For Loop เพื่อนำค่าไปใช้งานภายใน Function หรือ Keyword</p><pre>*** Test Cases ***<br>Test  V<em>ararg</em><br>    My Keyword    arg1    arg2    arg3    arg4    arg5    arg6</pre><pre>*** Keywords ***<br>My Keyword<br>    [Arguments]    @{arg}<br>    :FOR    ${value}    IN    @{arg}<br>    \    log    ${value}</pre><p><strong>Kwargs </strong>เหมาะกับการใช้งานที่ไม่รู้จำนวนสิ้นสุดของ Arguments เหมือนกัน เพียงแต่ว่าจะรับค่าอยู่ในรูปแบบของ <em>Dictionary การนำค่าไปใช้งานสามารถใช้งานผ่าน Key ตัวอย่างการใช้งานตาม โค้ดด้านล่าง</em></p><pre>*** Test Cases ***<br>Test Kwargs<br>    My Keyword    Firstname=Fname    Lastname=Lname</pre><pre>*** Keywords ***<br>My Keyword<br>    [Arguments]    &amp;{arg}<br>    log    &amp;{arg}[Firstname]<br>    log    &amp;{arg}[Lastname]</pre><p>นอกจากนี้แล้วเราสามารถนำ Arguments ที่กล่าวมาข้างต้นมาใช้งานร่วมกันได้ ยกตัวอย่างเช่น</p><pre><strong><em>Positional + Named</em></strong><br>[Arguments]    ${arg1}    ${arg2}=default</pre><pre><strong><em>Positional + </em>Kwargs</strong><br>[Arguments]    ${arg1}    ${arg2}    &amp;{arg}</pre><pre><strong><em>Named + </em>Kwargs</strong><br>[Arguments]    ${arg1}=default    &amp;{arg}</pre><p>สามารถ ดูข้อมูลการใช้งานเพิ่มเติมได้ที่ <a href="http://robotframework.org/robotframework/3.0/RobotFrameworkUserGuide.html#free-keyword-arguments-kwargs">Robot Framework Argument</a></p><h3>สรุป</h3><p>หลังจากบทความนี้หวังว่าเพื่อนๆจะสามารถนำการใช้งาน Arguments ในรูปแบบต่างๆ ของ Robot Framework ไปใช้งานให้เหมาะสมยิ่งขึ้น รวมไปถึงการส่งค่ารับค่าระหว่าง Robot Framework เองกับ Library ที่พัฒนาขึ้นมาเองได้อีกด้วย</p><blockquote>Be giving, enjoy sharing. :)</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5ae58b7f580c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>