Katalon Studio | How To Get Data From Excel

31
22



Katalon Studio

How to get data from excel | csv files

Today we will learn:
1. How to refer values from excel/csv
2. How to iterate all the data from test data file

Code to get data from data file (findTestData)
Code to loop data source (getRowNumbers)

Step 1 : Create your test case

Step 2 : Create data file (excel/csv) and add your data

Step 3 : Create variables and refer in Test Case

Step 4 : Add your data file in Katalon Studio

Step 5 : Add your test case in a Test Suite

Step 6 : Click on Show Data Binding and add data

Step 7 : Save and Run

for(def rowNum=1; rowNum =findTestData(“data1”).getRowNumbers() ; rowNum++)
{

//WebUI.setText(findTestObject(‘Object Repository/Variables/Page_OrangeHRM/input_txtUsername’), Username)
WebUI.setText(findTestObject(‘Object Repository/Variables/Page_OrangeHRM/input_txtUsername’), findTestData(“data1”).getValue(1,rowNum))

//WebUI.setText(findTestObject(‘Object Repository/Variables/Page_OrangeHRM/input_txtPassword’), Password)
WebUI.setText(findTestObject(‘Object Repository/Variables/Page_OrangeHRM/input_txtPassword’), findTestData(“data1”).getValue(2,rowNum))

Thread.sleep(3000)
}

PLAYLISTS

KATALON STUDIO

SELENIUM BEGINNERS

SELENIUM JAVA FRAMEWORK BEGINNERS

SELENIUM TIPS

SELENIUM PYTHON

SELENIUM BUILDER

JAVA

JAVA TIPS & TRICKS

JENKINS

JENKINS TIPS & TRICKS

JMETER BEGINNER

JMETER INTERMEDIATE

JMETER ADVANCED

JMETER TIPS & TRICKS

SOAPUI

POSTMAN

GIT & GITHUB

DOCKER

ROBOT FRAMEWORK

WEB SERVICES (API)

REDIS BEGINNER TUTORIALS

MAVEN

MISC

TOOLS & TIPS

QnA FRIDAY

SUNDAY SPECIAL

ALL PLAYLISTS

Like on FACEBOOK :

Follow on TWITTER:

Subscribe on YOUTUBE :

_____

Nguồn:https://dothihoa.com/

31 COMMENTS

  1. Great video course, very helpful, but I keep getting an error that says "please set data source for test data" when I try to attribute the value in the variable binding. Can anyone help? I have no idea what to do, all previous steps seem accurate.

  2. Hello raghav, thanks for the awesome tutorial. However, i have a question. I would like to loop within a test suite unfortunately it closes the browser and performs authentication again.

    the process is very slow considering the fact that login requires randomly generated otp. I have done the data binding.

    Below is the script. i would be grateful if i can get an help. Thanks

    import static com.kms.katalon.core.checkpoint.CheckpointFactory.findCheckpoint
    import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase
    import static com.kms.katalon.core.testdata.TestDataFactory.findTestData
    import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
    import static com.kms.katalon.core.testobject.ObjectRepository.findWindowsObject
    import com.kms.katalon.core.checkpoint.Checkpoint as Checkpoint
    import com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords as CucumberKW
    import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mobile
    import com.kms.katalon.core.model.FailureHandling as FailureHandling
    import com.kms.katalon.core.testcase.TestCase as TestCase
    import com.kms.katalon.core.testdata.TestData as TestData
    import com.kms.katalon.core.testobject.TestObject as TestObject
    import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS
    import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
    import com.kms.katalon.core.windows.keyword.WindowsBuiltinKeywords as Windows
    import internal.GlobalVariable as GlobalVariable
    import org.openqa.selenium.Keys as Keys

    WebUI.openBrowser(’’)

    WebUI.navigateToUrl(‘https://www.xxxxxxxxx’)

    WebUI.setText(findTestObject(‘Object Repository/New Folder/Page_Login/input_User Name_txtUserID’), ‘Oxxxxxxxxx’)

    WebUI.setEncryptedText(findTestObject(‘Object Repository/New Folder/Page_Login/input_Password_txtPassword’), ‘****************************************’)

    WebUI.click(findTestObject(‘Object Repository/New Folder/Page_Login/input_Password_btnLogin’))

    WebUI.setText(findTestObject(‘Object Repository/New Folder/Page_Login/input_Please Enter Entrust ID_txtEntrustID’), ‘11100011’)

    WebUI.click(findTestObject(‘Object Repository/New Folder/Page_Login/input_Please Enter Entrust ID_btnEntrust’))

    for(def rowNum=1; rowNum =findTestData(“data1”).getRowNumbers() ; rowNum++)
    {
    WebUI.click(findTestObject(‘Object Repository/New Folder/Page_Untitled Page/a_Admin’))

    WebUI.click(findTestObject('Object Repository/New Folder/Page_Untitled Page/a_User Maintenance'))

    WebUI.click(findTestObject('Object Repository/New Folder/Page_UserMaint/input_User Maintenance_ctl00ContentPlaceHol_2d2a24'))

    WebUI.setText(findTestObject('Object Repository/New Folder/Page_UserMaint/input_User_ctl00ContentPlaceHolder1tbFirstName'),
    variable)

    WebUI.setText(findTestObject('Object Repository/New Folder/Page_UserMaint/input_User_ctl00ContentPlaceHolder1tbLastName'),
    variable_0)

    WebUI.setText(findTestObject('Object Repository/New Folder/Page_UserMaint/input__ctl00ContentPlaceHolder1tbUserName'),
    variable_1)

    WebUI.setText(findTestObject('Object Repository/New Folder/Page_UserMaint/input_Till ID_ctl00ContentPlaceHolder1tbTillID'),
    variable_2)

    WebUI.selectOptionByValue(findTestObject('Object Repository/New Folder/Page_UserMaint/select_No PrivsUBA AuditorUBA AuditorUBA Au_786a2b'),
    '11', true)

    WebUI.selectOptionByValue(findTestObject('Object Repository/New Folder/Page_UserMaint/select_BF6401 DapoyaBF6402 PerequationBF640_6eea31'),
    '278', true)

    WebUI.setText(findTestObject('Object Repository/New Folder/Page_UserMaint/input_User_ctl00ContentPlaceHolder1tbEmail'),
    variable_3)

    WebUI.click(findTestObject('Object Repository/New Folder/Page_UserMaint/input_User Maintenance_ctl00ContentPlaceHol_e2e88f'))
    }

  3. I don't like such automatisation. It takes all the time and it has no sense!

    The programme should read that data authomatically, but not HUMAN would write such many data manually!

    IT'S NOT GOOD.

  4. Hi Raghav,Thanks for the great video. Can you please help me in how to run specific testcases with execute testcase column as 'Yes' in test data excel

  5. Hi Guys,

    I want to send the List variable through the excel instead of the String.
    Not able to do this as data comes in the string format.

    How to do this?

  6. Hello Raghav, after data binding is done at test suite level, I am able to run the suite and get results . But when I close and reopen the project ,the data binding which was done before disappears . I have to do the binding again to run the suite . Is there any way to save the data binding for future use?

  7. Your tutorials are one piece of gem Raghav, hats off for easy to understand tutorials and result driven videos. Cheers from New Zealand 🙂

  8. Thanks a lot Raghav. I have 10 test cases and respective data stored in 10 rows in excel sheet. I need to executed each testcase with 1 row of data from excel sheet. please help.

  9. Hi Raghav, thanks a lot for videos. I have a question for you. I have created two test-cases lets say Login test case and Home page test case(filling a blank form) which also contains previous test case as step1. So I have created a data file and in that created two sheets, one for login and other sheet contains the Home page fields (filling a blank form). At last, I created Suite file for both of the Test cases individually. Added the Test Data file and selected the required variables and now I am trying to run the Suite2 i.e, Homepage. As 2nd test case contains 1st testcase I thought it will take inputs like username and password. But it is not taking.. can you help with this scenario…

  10. Sir,
    It shows me an Error while browsing the Excel file.
    The error message is -> an internal error occurred during: "load excel file". file is unsupported .
    But sir I'm loading a .xlsx file.
    Can you help me out?

  11. Raghav, have you ever encountered the "splash screen never started" issue? The one that's dependant on the manifest of the apk. It's causing inconsistent failures on my tests (sometimes it works, sometimes it fails with the Cannot create remote sessions exception).

    Great videos, just suscribed. Best regards

  12. it seem like only can use encryption password if not it would be error

    would you tell me how to fix it please
    i see ur video on udemy u say can use Menu bar > Help and encrypt your text
    but if i have lot data to key-in might be too slow
    can i ask which version is this in the video please
    i'll try to degrade to fix this
    thank you!

  13. Hi.. Do u know how to get data from different sheets? Let's suppose we have 3 sheets(sheet1 , sheet2, sheet3) in excel file ..

    below code will point to sheet1 bydefault

    findTestData("data1").getRowNumbers()

    How to get data from sheet2?

  14. Hi, i have an problem in variable binding, when i try to add value it shows an error message : "please set data source for the test data: data files excel"

  15. Hello, I would like to know if I can take the values ​​from the web and save it in an excel file?

    How is it done? Is there a video that explains this?

    Thank you.

    Greetings from Argentina.

LEAVE A REPLY

Please enter your comment!
Please enter your name here