Check If Page Contains

Checks whether the web page contains a certain text or not.

Command availability: IBM RPA SaaS and IBM RPA on premises

Script syntax

IBM RPA's proprietary scripting language has a syntax similar to other programming languages. The script syntax defines the command's syntax in the script file. You can work with this syntax in IBM RPA Studio's Script mode.

ifWebContains --text(String) [--timeout(TimeSpan)] (Boolean)=value

Dependencies

  • Use the Start Browser (webStart) command to start a browser or use the Find Internet Explorer Browser (findBrowser) command to attach to Microsoft™ Internet Explorer before using the Check If Page Contains (ifWebContains) command.
  • This command checks only the inner text of the HTML elements on the page.

Input parameter

The following table displays the list of input parameters available in this command. In the table, you can see the parameter name when working in IBM RPA Studio's Script mode and its Designer mode equivalent label.

Designer mode label Script mode name Required Accepted variable types Description
Text text Required Text Text in the web page.
Timeout timeout Optional Time Span, Number, Text Maximum waiting time for running the command. When blank, the default timeout is 5 seconds.

Output parameter

Designer mode label Script mode name Accepted variable types Description
Success value Boolean Returns true if the web page contains the text, otherwise returns false.

Example

The Check If Page Contains (ifWebContains) command looks for the word "domain" in a web page.

defVar --name verificationResult --type Boolean
webStart --name browser --type "Chrome"
webNavigate --url "www.example.com"
// Search for the word "domain" in the informed site.
ifWebContains --text automation --timeout 00:00:30 verificationResult=value
webClose --name browser --leavebrowseropen
logMessage --message "${verificationResult}" --type "Info"
// The result obtained in the "${verificationResult}" variable after the operation is: True 

Limitations

The search mode of this command is case-insensitive.