TanIlak
2 years agoContributor
Log Functions
Hi I am trying to display the google logo in log file using Log.Picture() method >> var img=page.FindElement("xpath"); Log.Picture(img); In this way but it's not printing in log. Am I did any...
Sorry I was confused with another program. Here is the right solution.
To display the Google logo in the log file using the Log.Picture() method, you need to make sure that you are passing the correct element to the method.
Here is an example of how you can display the Google logo in the log file:
First, use the TestComplete DOM methods to find the Google logo element on the page. For example, you can use the "FindElement" method to search for the element using its xpath or any other attribute.
Once you have found the element, you can use the "GetImage" method to get the image of the element as a bitmap.
Finally, pass the bitmap to the Log.Picture() method to display it in the log file.
Here is an example code snippet that demonstrates how to do this:
// Find the Google logo element
var logoElement = page.FindElement("xpath", "//img[@title='Google']", 10);
// Get the image of the logo element as a bitmap
var logoImage = logoElement.GetImage();
// Display the logo image in the log file
Log.Picture(logoImage);
Hi KB1,
I have tried with GetImage() method also, the same error previous I have posted only am getting. What to do??
Is the logo on the page?
Yeah logo is present in that page
I cannot respond to your private messages.
To capture the URL of a product that has opened in a new tab, you will first need to switch to that tab using the ActivateTab method of the Sys.Browser object. Here's an example of how you can do this:
// Get a reference to the parent tab
var parentTab = Sys.Browser(browser[k]).Page("*");
// Find the element that opens the product in a new tab
var productLink = parentTab.FindElement("xpath");
// Click the element to open the product in a new tab
productLink.Click();
// Wait for the new tab to be opened
Sys.Browser(browser[k]).WaitTab();
// Switch to the new tab
Sys.Browser(browser[k]).ActivateTab(1);
// Get a reference to the page in the new tab
var productPage = Sys.Browser(browser[k]).Page("*");
// Capture the URL of the product page
var productUrl = productPage.URL;
// Log the URL
Log.Message(productUrl);
// Switch back to the parent tab
Sys.Browser(browser[k]).ActivateTab(0);
This code will find the element that opens the product in a new tab, click it to open the product, wait for the new tab to be opened, switch to the new tab, get a reference to the page in the new tab, capture the URL of the product page, and log it. Finally, it will switch back to the parent tab.
To display the image of the Google logo in the log file using the Log.Picture method, you can use the code you have provided.
The GetImage method of the FindElement object returns a bitmap object that represents the image of the element. You can then pass this bitmap object to the Log.Picture method to include the image in the log file.
// Find the Google logo element var logoElement = page.FindElement("xpath", "//img[@title='Google']", 10); // Get the image of the logo element as a bitmap var logoImage = logoElement.GetImage(); // Display the logo image in the log file Log.Picture(logoImage).CaptureWebElement(logoElement, "Google logo", true);
This code will find the element representing the Google logo on the page, get the image of the element as a bitmap, and include the image in the log file with the label "Google logo". The true parameter specifies that the image should be taken even if the element is not visible on the screen.
This will certainly fix this problem, tested it myself