Test Overview
This test checks that the Postman response viewer correctly switches between Pretty, Raw, and Preview views and displays the response content accordingly.
This test checks that the Postman response viewer correctly switches between Pretty, Raw, and Preview views and displays the response content accordingly.
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()
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Open Chrome browser and navigate to Postman web workspace | Postman workspace page is loaded, user is logged in, request ready | - | PASS |
| 2 | Click the Send button to send the API request | Request sent, waiting for response to appear | - | PASS |
| 3 | Wait until response body is present in the UI | Response body is displayed in the response panel | Response body element is present | PASS |
| 4 | Click the Pretty tab to view response in Pretty format | Pretty view tab is active, response formatted and shown prettily | Pretty response content is visible | PASS |
| 5 | Click the Raw tab to view raw response text | Raw view tab is active, raw response text displayed | Raw response content is visible | PASS |
| 6 | Click the Preview tab to view rendered response (e.g., HTML) | Preview view tab is active, rendered response displayed | Preview response content is visible | PASS |
| 7 | Close the browser | Browser closed, test ends | - | PASS |