I have added PhantomJS and Selenium to my C# console app and i want to take a screen shot of the browser when it gets to a specific element. The reason is because for some reason when i use the ChromeDriver it works fine, but when i use PhantomJS it fails on a few elements.
I guess i need an introduction on how to take a screenshot in C# using phantomjs. I have looked around on the internet and it looks like everyone is using java scripts to do this. The problem i am having is i don't know how to integrate the java scripts into my C# app and then use that with phantomJS to get the screen shot. If i can get some help on how to do this it would be very nice.
TLDR: I have found http://code.tutsplus.com/tutorials/testing-javascript-with-phantomjs--net-28243 and this is what i want to do but i don't know how to use the javascript in my c# app.
As you mentioned that you have code working for Chrome already, it's better to post it, in order to show what exactly you are after.
However, here is how to take screenshot using PhantomJSDriver
in C# in general:
var driver = new PhantomJSDriver();
driver.Manage().Window.Maximize(); // optional
driver.Navigate().GoToUrl("http://stackoverflow.com");
driver.TakeScreenshot().SaveAsFile("screenshot.png", ImageFormat.Png);
driver.Quit();
Note that you need to reference WebDriver.Support.dll
and System.Drawing
in your project.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With