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...
The Log.Picture method allows you to log a picture of an object or a screen region to the test log. You can use this method to log images of controls, windows, web page elements, or any other object that is displayed on the screen.
To log a picture of a web page element using the Log.Picture method, you can use the following code:
var img = page.FindElement("xpath");
// Get the object's rectangle
var rect = img.GetRectangle();
// Log the picture
Log.Picture(rect);
This will log a picture of the web page element specified by the XPath expression to the test log.
Keep in mind that in order for the Log.Picture method to work correctly, the object or screen region that you want to log a picture of must be visible on the screen at the time the method is called. If the object is not visible, the method will not be able to capture a picture of it.
I hope this helps! Let me know if you have any other questions.
Hi KB1,
Thanks for your response
>>No, it's not worked for me. Shows error
unable to find the object rectangle.
Get Rectangle object does not exist
Invalid Parameter
>>code for get google logo
var img=page.FindElement("//img[@class='lnXdpd'");
var rect=img.GetRectangle();
Log.picture(rect);
Let me know
Thanks in Advance