0
0
Postmantesting~10 mins

Duplicating and moving requests in Postman - Test Execution Trace

Choose your learning style9 modes available
Test Overview

This test verifies that a user can duplicate an existing request in Postman and move the duplicated request to a different collection. It checks that the duplicated request exists in the target collection and retains the original request's details.

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

class TestDuplicateAndMoveRequest(unittest.TestCase):
    def setUp(self):
        self.driver = webdriver.Chrome()
        self.driver.get('https://web.postman.co')
        # Assume user is already logged in or login steps here

    def test_duplicate_and_move_request(self):
        driver = self.driver
        wait = WebDriverWait(driver, 10)

        # Navigate to the source collection
        source_collection = wait.until(EC.element_to_be_clickable((By.XPATH, "//span[text()='Source Collection']")))
        source_collection.click()

        # Find the request to duplicate
        request = wait.until(EC.element_to_be_clickable((By.XPATH, "//div[contains(@class, 'request-item') and .//span[text()='Test Request']]")))
        request.click()

        # Open request options menu
        options_button = wait.until(EC.element_to_be_clickable((By.XPATH, "//button[@aria-label='Request options']")))
        options_button.click()

        # Click 'Duplicate' option
        duplicate_option = wait.until(EC.element_to_be_clickable((By.XPATH, "//button[text()='Duplicate']")))
        duplicate_option.click()

        # Wait for duplicated request to appear in the same collection
        duplicated_request = wait.until(EC.presence_of_element_located((By.XPATH, "//div[contains(@class, 'request-item') and .//span[text()='Test Request Copy']]")))

        # Drag and drop duplicated request to target collection
        target_collection = wait.until(EC.element_to_be_clickable((By.XPATH, "//span[text()='Target Collection']")))

        # Selenium does not support native drag and drop well, so use JS workaround
        driver.execute_script("var source = arguments[0]; var target = arguments[1];\n            var dataTransfer = new DataTransfer();\n            source.dispatchEvent(new DragEvent('dragstart', {dataTransfer: dataTransfer}));\n            target.dispatchEvent(new DragEvent('drop', {dataTransfer: dataTransfer}));\n            source.dispatchEvent(new DragEvent('dragend', {dataTransfer: dataTransfer}));\n            ", duplicated_request, target_collection)

        # Verify duplicated request is now in target collection
        target_collection.click()
        moved_request = wait.until(EC.presence_of_element_located((By.XPATH, "//div[contains(@class, 'request-item') and .//span[text()='Test Request Copy']]")))

        # Verify the duplicated request retains original details (e.g., method and URL)
        moved_request.click()
        method = wait.until(EC.presence_of_element_located((By.XPATH, "//button[@data-testid='request-method']"))).text
        url = wait.until(EC.presence_of_element_located((By.XPATH, "//input[@data-testid='url-input']"))).get_attribute('value')

        self.assertEqual(method, 'GET')
        self.assertEqual(url, 'https://api.example.com/data')

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

if __name__ == '__main__':
    unittest.main()
Execution Trace - 7 Steps
StepActionSystem StateAssertionResult
1Test starts and browser opens Postman web appBrowser shows Postman web app login or main page-PASS
2Navigates to 'Source Collection' in sidebar'Source Collection' is expanded showing requestsCheck 'Source Collection' is visible and clickablePASS
3Finds and clicks on 'Test Request' in source collection'Test Request' details panel opensVerify 'Test Request' is selectedPASS
4Clicks on request options buttonOptions menu for 'Test Request' is visibleOptions menu contains 'Duplicate' optionPASS
5Clicks 'Duplicate' to create a copy of the requestDuplicated request named 'Test Request Copy' appears in source collectionDuplicated request is present in source collectionPASS
6Drags and drops duplicated request to 'Target Collection''Test Request Copy' is moved under 'Target Collection'Duplicated request is no longer in source collection but in target collectionPASS
7Clicks 'Target Collection' and verifies duplicated request details'Test Request Copy' details panel is openRequest method is 'GET' and URL is 'https://api.example.com/data'PASS
Failure Scenario
Failing Condition: Duplicated request does not appear or cannot be moved to target collection
Execution Trace Quiz - 3 Questions
Test your understanding
What action confirms that the request was duplicated successfully?
AOpening the options menu
BPresence of 'Test Request Copy' in the source collection
CClicking the 'Duplicate' button
DNavigating to the target collection
Key Result
Always verify that duplicated test data retains key attributes and that UI actions like drag-and-drop are confirmed by checking the new location and content.