Hi,
While TestComplete provides Sys.HighlightObject() method, I am not sure if it works for web elements. Also, you might be not able to take a screenshot until the method completes.
With this in mind, I got another idea that is more complex in implementation but has more chances for success.
The points are like this:
a) It is possible with TestComplete to inject and execute some JScript code into web page (see "Executing JavaScript on Web Pages" help topic for more details);
b) Injected script will draw a border around web element, then you will take a screenshot and execute the script one more time to remove the border.
I don't have script example for TestComplete, but below is a sample for Selenium and I hope that you will manage to adopt it to your code.
public void setUp() throws Exception {
driver = new FirefoxDriver();
js = (JavascriptExecutor) driver;
}
private void highlightElement(WebElement element, int duration) throws InterruptedException {
String original_style = element.getAttribute("style");
js.executeScript(
"arguments[0].setAttribute(arguments[1], arguments[2])",
element,
"style",
"border: 2px solid red; border-style: dashed;");
if (duration > 0) {
Thread.sleep(duration * 1000);
js.executeScript(
"arguments[0].setAttribute(arguments[1], arguments[2])",
element,
"style",
original_style);
}
}
Hope, this will help...
P.S. Actually... It even might be enough just to call .getAtribute()/.setAttribute() methods of web element directly from TestComplete without any necessity to inject any code into web page. If this guess is correct, then the implementation will be really simple.