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...
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
Hi, here after I will send my doubts through post
1) In tab these 2 lines are showing invalid parameters
Sys.Browser(browser[k]).WaitTab(); // Switch to the new tab Sys.Browser(browser[k]).ActivateTab(1);
But I found the solution for tab it navigates to child page and fetched the URL.
2) I regret to say that i am getting invalid number of parameters for the line below
var logoElement = page.FindElement("xpath", "//img[@title='Google']", 10);
Could you please recheck once again and let me know.
Thanks for supporting me.