Reputation: 483
In my sample web page, there have print option. I need to call that,
<a href="https://crim.brib.pk/RenderReport_Version2.aspx??Product_Id=MjgwMQ%3d%3d-J2XNpfmNU8Q%3d&RUID=MTEwMDI0NTAwMTU%3d-rBg0P40kyho%3d&FinalResult=T#" onclick="AlertandPrint();return false" class="three"><b> Print </b></a>
because I need to save above page as PDF(My major requirement is to save that page in PDF format). When I try to do it manually following popup window shows.
I need to do it through chrome C# selenium web driver. How can I do it? Please provide me sample code to solve this problem.
Upvotes: 1
Views: 3649
Reputation: 8479
The print window is os realted component and you cannot automate them with selenium itself. You may need additional library to automate that along with your selenium code.
You are two Nuget package to it. One simply use InputSimulator and do key inputs like
Or
Automate browse window usings AutoITX nuget package.
Upvotes: 0
Reputation: 100
You'd use send keys to CTRL+P on the webpage then use driver find element by and then click
Send keys documentation found here: https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.sendkeys.send?view=netframework-4.7.2
//This should work for clicking the save/print button without seeing your code I cannot test it.
driver.FindElement(By.XPath("//*[@id="button-strip"]/button[1]")).Click();
Upvotes: 1