SCRIPTING RECIPE Travel site flow(American Express)

Prev Next

Objectives

This article provides an example site flow on the American Express travel website: searching for flights to purchase. The transaction follows these steps:

  • Open American Express Travel homepage
  • Type and select the "From" and "To" cities in the search bar
  • Select the "Start" and "Return" dates
  • Hit the "go/search flight" button

Prerequisites

  • Access to Catchpoint portal with Create/Modify tests permission

Process

  1. Log in to Catchpoint portal and create a Transaction Test
    image.png

  2. Copy the script below into the Script field:

// Step - 1 
open("https://travel.americanexpress.com/travel/home") 
setStepName("1 - Home") 
waitForElementPresent("//div[@id='flight']") 

// Step - 2 // Set up search 
typeAndWait("//*[@id='rhFlightFromField']", "LAX") 
fireEvent("//*[@id='rhFlightFromField']", "keydown") 
fireEvent("//*[@id='rhFlightFromField']", "keypress") 
fireEvent("//*[@id='rhFlightFromField']", "input") 
fireEvent("//*[@id='rhFlightFromField']", "keyup") 
pause("1000") click("//*[@id="ui-id-1"]/li[2]") 
type("//*[@id='rhFlightToField']", "JFK") 
fireEvent("//*[@id='rhFlightToField']", "keydown") 
fireEvent("//*[@id='rhFlightToField']", "keypress") 
fireEvent("//*[@id='rhFlightToField']", "input") 
fireEvent("//*[@id='rhFlightToField']", "keyup") 
pause(1000) 
click("//*[@id="ui-id-2"]/li[2]") // Set outDate 
var outDate = ${Time(MM/DD/YYYY,60,60)}; 
var backDate = ${Time(MM/DD/YYYY,65,65)}; 
type("//*[@id='flightStartDate']", "${Var(outDate)}") 
type("//*[@id='flightReturnDate']", "${Var(backDate)}") 
setStepName("2 - Enter Search Details") 

// Step - 3 
clickAndWait("//*[@id='rhSearchFlight']") 
setStepName("3 - Search") 
var selectIndex = ${Random(1, 4)}; 
waitForElementPresent("(//a[text()='Select'])[${var(selectIndex)}]") `
  1. Modify the settings in the script per your requirements:
    image.png

  2. Save and your Transaction test with login script is ready!
    image.png