CST Popup Windows/Lookup Fields/New Windows Handling and Switching

Updated 1 month ago by Copado Solutions

"Popup" windows (we are not referring to javascript dialogs, the ones with yes/no or ok buttons, or open/save file dialogs) are sometimes troublesome to handle, because when there is more than a window, we need to specify in the test case which of the several windows open should receive the clicks and be typed on.

For that, CST has a special command, copadoPopup, to supplement the standard Selenium commands selectPopUp/selectWindow.

The perfect example of a popup window is a Salesforce Lookup field, when clicking on the magnifying glass to search for a record.

In order to open a popup, the command "copadoPopup copado=popup:Account Name" will do the following:

  • Search for the magnifying glass related to the Account Name field.
  • Click on it.
  • Wait for and select the newly opened popup, so that subsequent commands are executed there.

After searching for an account and clicking on the name, the attention needs to be switched back to the main window. This is done with the "copadoPopup" command, without any other parameters. 

A typical fragment of a test case dealing with Lookup windows would be the following: 

command

parameter 1

parameter 2

result

click

copado=popup:Account Name

[success]

type

copado=field:Search

Account#10

[success]

click

copado=button: Go!

[success]

click

copado=link:Account#10

[success]

copadoPopup

[success]

comment

... continue in the main window


For Salesforce Classic Lookup fields and values that we can rely on and that are unique (Account#10), you can simply use a single command, and Copado will run almost like executing all those steps:

command

parameter 1

parameter 2

result

type

copado=field:Account Name

Account#10

[success]

Similar results can be achieved in a more general fashion with the standard Selenium commands:

command

parameter 1

parameter 2

result

comment

Click on the locator that points to the magnifying glass

[success]

click

css=TR:nth-of-type(4) > TD.dataCol.col02:nth-of-type(2) > SPAN.lookupInput > A

[success]

waitForPopUp

[success]

selectPopUp

[success]

comment

... other commands here, that affect the popup, but not the main window.

[success]

close

[success]

selectWindow

[success]

comment

... continue in the main screen.

[success]

"close" might not be necessary, since some popups close automatically after performing an action (such as clicking on "done", or choosing an item).


How did we do?