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.
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.
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()
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Open browser and navigate to Postman web app | Browser shows Postman web app login or main page | - | PASS |
| 2 | Click on 'Import' button | 'Import' button is visible and clickable | Button is clickable | PASS |
| 3 | Upload collection file 'sample_collection.json' | File input accepts the file path | File input contains the file path | PASS |
| 4 | Wait for collection named 'Sample Collection' to appear in sidebar | Sidebar shows 'Sample Collection' entry | Collection element is present | PASS |
| 5 | Click on the collection to select it | 'Sample Collection' is selected and details shown | - | PASS |
| 6 | Open collection menu and click 'Export' | Export modal appears | Export modal is visible | PASS |
| 7 | Confirm export by clicking 'Export' button in modal | Export modal closes, export starts | Export modal disappears | PASS |
| 8 | Verify import and export flow completed | No errors, collection imported and export triggered | Test assertion passes | PASS |