Skip to main content
Solved

Color identification on web page or any application

  • July 8, 2025
  • 2 replies
  • 68 views

Forum|alt.badge.img+1

Request for Suggestion:
Is it feasible to identify the color of an object so that the bot can take appropriate actions based on the detected color? For example, if the object is red, one type of bot action is triggered, whereas a green object would initiate a different activity.

Best answer by Padmakumar

Hi ​@Nirajknir ,

 

You can make use of the Browser - Run Javascript action for this. Inject JavaScript to fetch the CSS color property of the web element. Return this value to the bot and use conditional logic.

 

That is,

  • Identify the web element selector (e.g., by ID, class).

  • Run JavaScript like:

    return window.getComputedStyle(document.querySelector('your-selector')).backgroundColor;

  • The returned color (e.g., rgb(255, 0, 0) for red) can be parsed by the bot and used in conditionals.

2 replies

Padmakumar
Premier Pathfinder | Tier 7
Forum|alt.badge.img+15
  • Premier Pathfinder | Tier 7
  • Answer
  • July 8, 2025

Hi ​@Nirajknir ,

 

You can make use of the Browser - Run Javascript action for this. Inject JavaScript to fetch the CSS color property of the web element. Return this value to the bot and use conditional logic.

 

That is,

  • Identify the web element selector (e.g., by ID, class).

  • Run JavaScript like:

    return window.getComputedStyle(document.querySelector('your-selector')).backgroundColor;

  • The returned color (e.g., rgb(255, 0, 0) for red) can be parsed by the bot and used in conditionals.


Aaron.Gleason
Automation Anywhere Team
Forum|alt.badge.img+14
  • Automation Anywhere Team
  • July 8, 2025

Great suggestion ​@Padmakumar . If you have a site that won't allow JavaScript injection, you can always use a Recorder: Capture and use Get Property get the Outer HTML properties of the object. This way, you can receive the CSS styling of the object and use If actions based on known CSS styles for each color. Or, for older sites, the <font color="red"> if they're not using CSS. 

Example: <div class="data-source category-high">Account out of balance</div> where the "category-high" is known to be styled in red.