0
0
Postmantesting~10 mins

Pretty, raw, and preview views in Postman - Test Execution Trace

Choose your learning style9 modes available
Test Overview

This test checks that the Postman response viewer correctly switches between Pretty, Raw, and Preview views and displays the response content accordingly.

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 TestPostmanResponseViews(unittest.TestCase):
    def setUp(self):
        self.driver = webdriver.Chrome()
        self.driver.get('https://web.postman.co/workspace')
        # Assume user is logged in and a request is ready to send

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

        # Click Send button to get response
        send_button = wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, 'button[data-testid="send-button"]')))
        send_button.click()

        # Wait for response to appear
        wait.until(EC.presence_of_element_located((By.CSS_SELECTOR, 'div.response-body')))

        # Select Pretty view
        pretty_tab = driver.find_element(By.CSS_SELECTOR, 'button[aria-label="Pretty"]')
        pretty_tab.click()
        # Assert Pretty view content is visible
        pretty_content = wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR, 'div.response-body.pretty')))
        self.assertTrue(pretty_content.is_displayed())

        # Select Raw view
        raw_tab = driver.find_element(By.CSS_SELECTOR, 'button[aria-label="Raw"]')
        raw_tab.click()
        # Assert Raw view content is visible
        raw_content = wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR, 'div.response-body.raw')))
        self.assertTrue(raw_content.is_displayed())

        # Select Preview view
        preview_tab = driver.find_element(By.CSS_SELECTOR, 'button[aria-label="Preview"]')
        preview_tab.click()
        # Assert Preview view content is visible
        preview_content = wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR, 'div.response-body.preview')))
        self.assertTrue(preview_content.is_displayed())

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

if __name__ == '__main__':
    unittest.main()
Execution Trace - 7 Steps
StepActionSystem StateAssertionResult
1Open Chrome browser and navigate to Postman web workspacePostman workspace page is loaded, user is logged in, request ready-PASS
2Click the Send button to send the API requestRequest sent, waiting for response to appear-PASS
3Wait until response body is present in the UIResponse body is displayed in the response panelResponse body element is presentPASS
4Click the Pretty tab to view response in Pretty formatPretty view tab is active, response formatted and shown prettilyPretty response content is visiblePASS
5Click the Raw tab to view raw response textRaw view tab is active, raw response text displayedRaw response content is visiblePASS
6Click the Preview tab to view rendered response (e.g., HTML)Preview view tab is active, rendered response displayedPreview response content is visiblePASS
7Close the browserBrowser closed, test ends-PASS
Failure Scenario
Failing Condition: Response body does not appear after sending request or view tabs do not switch correctly
Execution Trace Quiz - 3 Questions
Test your understanding
What does the test verify after clicking the Pretty tab?
AThat the raw response text is shown
BThat the response is formatted and displayed prettily
CThat the response is rendered as HTML
DThat the request is sent again
Key Result
Always wait explicitly for UI elements to appear before interacting or asserting, especially in dynamic web apps like Postman.