Knowledge Base Article

Home Page > Knowledge Base > Rapise

Home Page > Knowledge Base > Rapise > Rapise Web

Article Recording Popup JavaScript Confirmation Boxes

by Adam S on Thursday, December 4, 2014

When you are recording a test against a Web application you may have to deal with a popup JavaScript confirm or alert box. This article describes the process for dealing with them.

Sometimes you have a web page that uses the following types of alert box:

alert('some message');

or

confirm("Press a button!");

(see http://www.w3schools.com/jsref/met_win_confirm.asp or http://www.w3schools.com/jsref/met_win_alert.asp)

When you record such a web page, Rapise will automatically record one of the following statements:

a) For an Alert Box

Navigator.DoCheckPrompt(msg, result)

Waits until browser prompt with a given text. Wait timeout is 10 seconds.

b) For a Confirm Box

Navigator.DoCheckConfirmation(msg, result)

Waits until browser confirmation with a given text. Wait timeout is 10 seconds.

You can also write your own code using the built-in Global Navigator object:

Navigator

Top  Previous  Next


 

Navigator object. This is used to provide functions for manipulating the web browser when using the HTML libraries.

 

 

Action Summary

 

Action

Description

Close

Closes browser.

DoCheckAlert

Waits until browser alert with a given text.

DoCheckConfirmation

Waits until browser confirmation with a given text.

DoCheckPrompt

Waits until browser prompt with a given text.

DoSetExpectedConfirmResult

Set boolean value to return as a result of next browser 'confirm' request.

DoSetExpectedPromptResult

Set text to return as a result of next browser 'prompt' request.

ExecJS

Executes given JavaScript statement in a browser and returns results.

Find

Returns HTMLObject wrapping DOM element for a given 'xpath'.

Navigate

Redirects browser to a specified URL.

Open

Opens a browser.

 

Action Detail

 

Close(url)

Closes browser. Finishes session.

 

Parameters:

 

Name

Type

Description

url

String

Not used - can leave empty

 

DoCheckAlert(msg)

Waits until browser alert with a given text. Wait timeout is 10 seconds.

 

Parameters:

 

Name

Type

Description

msg

String

alert text. Can be exact text or regular expression.

 

Returns:

 

'true' if browser alert had occurred, 'false' otherwise.

 

DoCheckConfirmation(msg, result)

Waits until browser confirmation with a given text. Wait timeout is 10 seconds.

 

Parameters:

 

Name

Type

Description

msg

String

confirmation text. Can be exact text or regular expression.

result

String

Not used - can leave empty.

 

Returns:

 

'true' if browser confirmation popup is shown, 'false' otherwise.

 

DoCheckPrompt(msg, result)

Waits until browser prompt with a given text. Wait timeout is 10 seconds.

 

Parameters:

 

Name

Type

Description

msg

String

prompt text. Can be exact text or regular expression.

result

String

Not used - can leave empty.

 

Returns:

 

'true' if browser prompt popup is shown, 'false' otherwise.

 

DoSetExpectedConfirmResult(expectedRes)

Set boolean value to return as a result of next browser 'confirm' request.

 

Parameters:

 

Name

Type

Description

expectedRes

String

The text to be returned in the next request.

 

DoSetExpectedPromptResult(expectedRes)

Set text to return as a result of next browser 'prompt' request.

 

Parameters:

 

Name

Type

Description

expectedRes

String

The text to be returned in the next request.

 

ExecJS(scriptText)

Executes given JavaScript statement in a browser and returns results.

 

Parameters:

 

Name

Type

Description

scriptText

String

JavaScript code.

 

Returns:

 

 

 

Find(xpath, url, title, objInfo)

Returns HTMLObject wrapping DOM element for a given 'xpath'. HTMLObject is a {SeSObject} constructed by matching one of browser rules: IEHTMLObject, MozillaHTMLObject, etc.

 

Parameters:

 

Name

Type

Description

xpath

String

location path of a DOM element.

url

String

URL. If new navigator is launched, the URL is used.
Optional.

title

String

The title of the HTML document that is being searched.

objInfo

SeSObjectInfo

A populated SeSObjectInfo object.

 

Returns:

 

HTMLObject wrapping DOM element for a given 'xpath', 'null' if 'xpath' is invalid.

 

Navigate(url)

Redirects browser to a specified URL.

 

Parameters:

 

Name

Type

Description

url

String

The URL to navigate to.

 

Open(url)

Opens a browser. If URL is specified, goes to URL.

 

Parameters:

 

Name

Type

Description

url

String

start URL for opening browser. Can be 'null'.

 

Attachments
Article Info
Last Updated: 12/4/2014
Article ID: KB97
# Views: 2419
Powered by KronoDesk v1.1.0.15 | © Copyright Inflectra Corporation 2011-2016 | Licensed to Inflectra Corporation.