highlight in screenshot the control to be clicked
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
highlight in screenshot the control to be clicked
Dear all,
I'm currently working on automating the testing for an web application using Testcomplete's JavaScript. We need small testing reports so I've disabled the Collect Test Visualizer data during test run (and also during recording).
There are situations in which we need to take a screenshot before a control is clicked. Can you share with me some code regarding highlighting in a screenshot the control which will be clicked? I'm aware of the following link, but is there any JavaScript equivalent: https://community.smartbear.com/t5/TestComplete-Functional-Web/Is-there-any-way-to-capture-a-screens...
Thank you!
R
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There is simply "Log.Picture" (https://support.smartbear.com/testcomplete/docs/reference/project-objects/test-log/log/picture.html) which will capture a shot of any componet that you send to it.
For example, if I want a screenshot of Aliases.MyApp.Form1.OKButton, I can do
Log.Picture(Aliases.MyApp.Form1.OKButton, "Screenshot of OK button on Form1")
Alternatively, the Log.Message (https://support.smartbear.com/testcomplete/docs/reference/project-objects/test-log/log/message.html) method includes the ability to include a screenshot as well.
Both of these methods would require you to add code to your existing tests to capture the screenshots on demand.
Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----
Why automate? I do automated testing because there's only so much a human being can do and remain healthy. Sleep is a requirement. So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.
Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Robert!
Thank you for your answer and sorry for the late response.
I've tried your indications, and they work, but ... they create an image only for the selected control. What I was trying to get is to have an image with the entire page, which has the specified control highlighted. I need this, because I have pages where identical controls are present (imagine a table with update/delete buttons in the last column for every entry) and I want to show that the correct control was used/called.
I know TestComplete (TC) does these sort of screenshots (if you allow pictures for every action TC performs, but I had to disable this option because the logs are too big), I only need to call/use it when I really need it, not all the time.
Thank you!
R
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
At the moment, I can't find a way of doing what you're asking. What you're looking for is specifically that Visualizer functionality that you've turned off, but activated on demand. I'm not sure that's possible.
Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----
Why automate? I do automated testing because there's only so much a human being can do and remain healthy. Sleep is a requirement. So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.
Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
/Alex [Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
================================
