0
0
Postmantesting~10 mins

Importing and exporting collections in Postman - Test Execution Trace

Choose your learning style9 modes available
Test Overview

This test checks if a user can successfully import a Postman collection file and then export it back. It verifies that the collection is loaded and saved correctly.

Test Code - Selenium
Postman
import unittest
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import os

class TestPostmanCollectionImportExport(unittest.TestCase):
    def setUp(self):
        self.driver = webdriver.Chrome()
        self.driver.get('https://web.postman.co/')
        self.wait = WebDriverWait(self.driver, 15)

    def test_import_export_collection(self):
        driver = self.driver
        wait = self.wait

        # Log in step assumed done manually or session preserved

        # Click on 'Import' button
        import_button = wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, 'button[aria-label="Import"]')))
        import_button.click()

        # Upload collection file
        upload_input = wait.until(EC.presence_of_element_located((By.CSS_SELECTOR, 'input[type="file"]')))
        collection_path = os.path.abspath('sample_collection.json')
        upload_input.send_keys(collection_path)

        # Wait for collection to appear in sidebar
        collection_name = 'Sample Collection'
        collection_element = wait.until(EC.presence_of_element_located((By.XPATH, f"//span[text()='{collection_name}']")))

        # Select the collection
        collection_element.click()

        # Click on 'Export' option from collection menu
        menu_button = wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, 'button[aria-label="Collection actions"]')))
        menu_button.click()

        export_option = wait.until(EC.element_to_be_clickable((By.XPATH, "//button[contains(text(),'Export')]")))
        export_option.click()

        # Wait for export modal and confirm export
        export_confirm = wait.until(EC.element_to_be_clickable((By.XPATH, "//button[contains(text(),'Export')]")))
        export_confirm.click()

        # Assertion: Check export modal disappears
        wait.until(EC.invisibility_of_element(export_confirm))

        self.assertTrue(True, 'Import and export flow completed successfully')

    def tearDown(self):
        self.driver.quit()

if __name__ == '__main__':
    unittest.main()
Execution Trace - 8 Steps
StepActionSystem StateAssertionResult
1Open browser and navigate to Postman web appBrowser shows Postman web app login or main page-PASS
2Click on 'Import' button'Import' button is visible and clickableButton is clickablePASS
3Upload collection file 'sample_collection.json'File input accepts the file pathFile input contains the file pathPASS
4Wait for collection named 'Sample Collection' to appear in sidebarSidebar shows 'Sample Collection' entryCollection element is presentPASS
5Click on the collection to select it'Sample Collection' is selected and details shown-PASS
6Open collection menu and click 'Export'Export modal appearsExport modal is visiblePASS
7Confirm export by clicking 'Export' button in modalExport modal closes, export startsExport modal disappearsPASS
8Verify import and export flow completedNo errors, collection imported and export triggeredTest assertion passesPASS
Failure Scenario
Failing Condition: Collection file not found or upload input not accepting file
Execution Trace Quiz - 3 Questions
Test your understanding
What is the first action performed in the test?
AClick on 'Export' button
BUpload collection file
COpen browser and navigate to Postman web app
DSelect collection from sidebar
Key Result
Always wait explicitly for UI elements to be present and interactable before performing actions to avoid flaky tests.