Skip to main content

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.

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.


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.