1"use strict";(self.webpackChunkKatalon_Docs=self.webpackChunkKatalon_Docs||[]).push([[10146],{28453:(e,a,n)=>{n.d(a,{R:()=>i,x:()=>l});var t=n(96540);const o={},s=t.createContext(o);function i(e){const a=t.useContext(s);return t.useMemo((function(){return"function"==typeof e?e(a):{...a,...e}}),[a,e])}function l(e){let a;return a=e.disableParentContext?"function"==typeof e.components?e.components(o):e.components||o:i(e.components),t.createElement(s.Provider,{value:a},e.children)}},45514:(e,a,n)=>{n.r(a),n.d(a,{assets:()=>d,contentTitle:()=>r,default:()=>m,frontMatter:()=>l,metadata:()=>t,toc:()=>c});const t=JSON.parse('{"id":"keywords/using-keywords-in-katalon-studio/mobile-testing/handling-drag-and-drop-in-mobile-app-in-katalon-studio","title":"Handling Drag and Drop in Mobile App in Katalon Studio","description":"In this tutorial, we will see how to handle drag and drop action in a mobile application using Katalon Studio. The source code can be downloaded here.","source":"@site/docs/katalon-studio/keywords/using-keywords-in-katalon-studio/mobile-testing/handling-drag-and-drop-in-mobile-app-in-katalon-studio.md","sourceDirName":"keywords/using-keywords-in-katalon-studio/mobile-testing","slug":"/keywords/using-keywords-in-katalon-studio/mobile-testing/handling-drag-and-drop-in-mobile-app-in-katalon-studio","permalink":"/katalon-studio/keywords/using-keywords-in-katalon-studio/mobile-testing/handling-drag-and-drop-in-mobile-app-in-katalon-studio","draft":false,"unlisted":false,"tags":[],"version":"current","lastUpdatedAt":1758935351000,"frontMatter":{"title":"Handling Drag and Drop in Mobile App in Katalon Studio"},"sidebar":"katalon-studio","previous":{"title":"Handling Alert Dialog in Mobile App in Katalon Studio","permalink":"/katalon-studio/keywords/using-keywords-in-katalon-studio/mobile-testing/handling-alert-dialog-in-mobile-app-in-katalon-studio"},"next":{"title":"Using List to Store the Mobile Elements to Validate Data in Katalon Studio","permalink":"/katalon-studio/keywords/using-keywords-in-katalon-studio/mobile-testing/using-list-to-store-the-mobile-elements-to-validate-data-in-katalon-studio"}}');var o=n(74848),s=n(28453),i=n(86025);const l={title:"Handling Drag and Drop in Mobile App in Katalon Studio"},r=void 0,d={},c=[{value:'<a class="anchor_top_offset"></a>Scenario',id:"scenario",level:2},{value:'<a class="anchor_top_offset"></a>Manual Mode',id:"manual-mode",level:2},{value:'<a class="anchor_top_offset"></a>Script Mode',id:"script-mode",level:2}];function p(e){const a={code:"code",h2:"h2",pre:"pre",...(0,s.R)(),...e.components};return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)("p",{xmlns:"http://www.w3.org/1999/xhtml",className:"p",children:["In this tutorial, we will see how to handle drag and drop action in a mobile application using Katalon Studio. The source code can be downloaded ",(0,o.jsx)("a",{className:"xref j-external-link",href:"https://github.com/katalon-studio/katalon-mobile-automation/blob/master/Data%20Files/Drag%20and%20Drop.apk",target:"_blank",children:"here"}),"."]}),"\n",(0,o.jsxs)(a.h2,{id:"scenario",children:[(0,o.jsx)("a",{id:"id_1",class:"anchor_top_offset"}),"Scenario"]}),"\n",(0,o.jsxs)("p",{xmlns:"http://www.w3.org/1999/xhtml",className:"p",children:["The scenario is to ",(0,o.jsx)("strong",{className:"ph b",children:"drag and drop"}),' a draggable object containing the text "',(0,o.jsx)("strong",{className:"ph b",children:"Brad Mehldau"}),'" and a droppable object containing the text "',(0,o.jsx)("strong",{className:"ph b",children:"Kurt Rosenwinkel"}),'".']}),"\n",(0,o.jsxs)("ul",{xmlns:"http://www.w3.org/1999/xhtml",className:"ul",children:[" ",(0,o.jsxs)("li",{className:"li",children:["Step 1: Start the Application (",(0,o.jsx)("strong",{className:"ph b",children:"Drag and Drop.apk"}),")"]})," ",(0,o.jsxs)("li",{className:"li",children:["Step 2: Tap on ",(0,o.jsx)("strong",{className:"ph b",children:"Basic Usage playground"})," text"]})," ",(0,o.jsxs)("li",{className:"li",children:["Step 3: Drag ",(0,o.jsx)("strong",{className:"ph b",children:"Brad Mehldau"})," text to drop at ",(0,o.jsx)("strong",{className:"ph b",children:"Kurt Rosenwinkel"})," text"]})," "]}),"\n",(0,o.jsxs)(a.h2,{id:"manual-mode",children:[(0,o.jsx)("a",{id:"id_2",class:"anchor_top_offset"}),"Manual Mode"]}),"\n",(0,o.jsx)("ul",{xmlns:"http://www.w3.org/1999/xhtml",className:"ul",children:(0,o.jsxs)("li",{className:"li",children:["Step 1: Select ",(0,o.jsx)("strong",{className:"ph b",children:"Start Application"})," from mobile keyword and click on ",(0,o.jsx)("strong",{className:"ph b",children:"Input"})," to open a new dialogue. In ",(0,o.jsx)("strong",{className:"ph b",children:"appFile"}),", select '",(0,o.jsx)("strong",{className:"ph b",children:"Value Type"}),"' as ",(0,o.jsx)("strong",{className:"ph b",children:"Variable"}),". In ",(0,o.jsx)("strong",{className:"ph b",children:"Value"}),", pass the variable name as '",(0,o.jsx)("strong",{className:"ph b",children:"path'"}),"."]})}),"\n",(0,o.jsxs)("p",{xmlns:"http://www.w3.org/1999/xhtml",className:"p",children:[(0,o.jsx)("img",{className:"image",src:(0,i.Ay)("https://github.com/katalon-studio/docs-images/raw/master/katalon-studio/tutorials/handle_drag_drop_mobile_app/Handling-Drag-and-Drop-in-Mobile-App.png"),alt:"Handling Drag and Drop in Mobile App"}),(0,o.jsx)("br",{}),(0,o.jsx)("br",{})]}),"\n",(0,o.jsxs)("ul",{xmlns:"http://www.w3.org/1999/xhtml",className:"ul",children:[(0,o.jsxs)("li",{className:"li",children:["Step 2: Add a ",(0,o.jsx)("strong",{className:"ph b",children:"Wait For Element Present"})," item to wait for Basic Usage playground to pop up."]}),(0,o.jsxs)("li",{className:"li",children:["Step 3: Select ",(0,o.jsx)("strong",{className:"ph b",children:"Tap"})," from mobile keyword and pass the object of Basic Usage playground."]}),(0,o.jsxs)("li",{className:"li",children:["Step 4: Similarly, add a ",(0,o.jsx)("strong",{className:"ph b",children:"Wait For Element Present"})," item to wait for the 'Brad Mehldau' text."]}),(0,o.jsxs)("li",{className:"li",children:["Step 5: Select the ",(0,o.jsx)("strong",{className:"ph b",children:"DragAndDrop"})," ",(0,o.jsx)("strong",{className:"ph b",children:"keyword"})," to perform the drag and drop action."]}),(0,o.jsx)("li",{className:"li",children:"Step 6: The draggable object will be dragged into the droppable object."})]}),"\n",(0,o.jsxs)("p",{xmlns:"http://www.w3.org/1999/xhtml",className:"p",children:[(0,o.jsx)("img",{className:"image",src:(0,i.Ay)("https://github.com/katalon-studio/docs-images/raw/master/katalon-studio/tutorials/handle_drag_drop_mobile_app/Handling-Drag-and-Drop-in-Mobile-App-6.png"),alt:"Handling Drag and Drop in Mobile App"}),(0,o.jsx)("br",{}),(0,o.jsx)("br",{})]}),"\n",(0,o.jsxs)("p",{xmlns:"http://www.w3.org/1999/xhtml",className:"p",children:["You can utilize our ",(0,o.jsx)("strong",{className:"ph b",children:"Script"})," feature to automate the test."]}),"\n",(0,o.jsxs)(a.h2,{id:"script-mode",children:[(0,o.jsx)("a",{id:"id_3",class:"anchor_top_offset"}),"Script Mode"]}),"\n",(0,o.jsx)(a.pre,{children:(0,o.jsx)(a.code,{className:"language-jsx",children:"import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject\nimport com.kms.katalon.core.configuration.RunConfiguration as RunConfiguration\nimport com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mobile\nimport com.kms.katalon.core.model.FailureHandling as FailureHandling\n \n'Path of the Apk File Store in path variable'\ndef path = RunConfiguration.getProjectDir() + '/Data Files/Drag and Drop.apk'\n \n'Start the Application'\nMobile.startApplication(path, false)\n \n'Wait for Element Present of text \"Basic Usage playground\"'\nM
1obile.waitForElementPresent(findTestObject('Drag Sort Demos/Handle Drag and Drop/text_Basic Usage playground'), 30)\n \n'Verify Element visible of \"Basic Usage playground\"'\nMobile.verifyElementVisible(findTestObject('Drag Sort Demos/Handle Drag and Drop/text_Basic Usage playground'), 30)\n \n'Tap on \"Basic Usage playground\"'\nMobile.tap(findTestObject('Drag Sort Demos/Handle Drag and Drop/text_Basic Usage playground'), 30)\n \n'Wait for Element Present of \"Brad Mehldau\"'\nMobile.waitForElementPresent(findTestObject('Drag Sort Demos/Handle Drag and Drop/text_Brad Mehldau'), 30)\n \n'Verify Element visible of \"Brad Mehldau\"'\nMobile.verifyElementVisible(findTestObject('Drag Sort Demos/Handle Drag and Drop/text_Brad Mehldau'), 30)\n \n'Use the dragAndDrop keyword to perform the drag and drop action.'\nMobile.dragAndDrop(findTestObject('Drag Sort Demos/Handle Drag and Drop/text_Brad Mehldau'), findTestObject('Drag Sort Demos/Handle Drag and Drop/text_Kurt Rosenwinkel'), 30)\n\nMobile.delay(50, FailureHandling.STOP_ON_FAILURE)\nMobile.closeApplication()\n"})})]})}function m(e={}){const{wrapper:a}={...(0,s.R)(),...e.components};return a?(0,o.jsx)(a,{...e,children:(0,o.jsx)(p,{...e})}):p(e)}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.