Skip to main content

PDF Utility integration

The PDF Utility plugin provides 14 custom keywords that allow testers to work with PDF documents in various ways. You can extract and compare content, save pages as images, and perform other tasks within automated test cases.

Here's how to perform PDF testing in Katalon Studio using the PDF Utility plugin:
  1. Open Katalon Studio and create a new project. See Create a test project in Katalon Studio.
  2. Place the PDF files you want to test in the Data Files directory of your project.
    For example, you can put your PDF files in the following location: <Your Project Folder>/Data Files/
  3. Create a new test case. See Create a new test case in Katalon Studio.
  4. In the new test case, switch to the Script tab, use the sample code below to enable the plugin:
    import com.kms.katalon.core.util.KeywordUtil as KeywordUtil
    import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
    import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mobile
    import com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords as CucumberKW
    import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS
    import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
    import static com.kms.katalon.core.testdata.TestDataFactory.findTestData
    import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase
    import static com.kms.katalon.core.checkpoint.CheckpointFactory.findCheckpoint
    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.checkpoint.Checkpoint as Checkpoint
    import internal.GlobalVariable as GlobalVariable
    import com.kms.katalon.core.configuration.RunConfiguration as RunConfiguration

    // To specify the path to data files
    String path = RunConfiguration.getProjectDir() + '/Data Files/'
  5. Apply custom keywords to work with PDF files in your test cases.

    In the example below, we use the getPageNumber custom keyword to get the total number of pages in a PDF document.

    import com.kms.katalon.core.util.KeywordUtil as KeywordUtil
    import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
    import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mobile
    import com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords as CucumberKW
    import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS
    import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
    import static com.kms.katalon.core.testdata.TestDataFactory.findTestData
    import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase
    import static com.kms.katalon.core.checkpoint.CheckpointFactory.findCheckpoint
    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.checkpoint.Checkpoint as Checkpoint
    import internal.GlobalVariable as GlobalVariable
    import com.kms.katalon.core.configuration.RunConfiguration as RunConfiguration

    // To specify the path to data files
    String path = RunConfiguration.getProjectDir() + '/Data Files/'

    // Get the total number of pages in a PDF document
    CustomKeywords.'com.kms.katalon.keyword.pdf.PDF.getPageNumber'(path + 'test_text1.pdf')
    Tip:
    • For detailed descriptions and sample codes of all available keywords, please refer to our GitHub: Use the PDF keywords.

  6. Run the test case by selecting the Run button in the toolbar.
In the Log Viewer tab, you can see the PDF-related actions and the outcomes generated by the custom keywords in your test case.

Was this page helpful?