Multiple browser screenshot with Selenium - c#

I'm completely new to Selenium but I'm aware it's capable of taking browser screenshots. Though, I was wondering if it's able to take screenshots of multiple browsers, specifically chrome, firefox and IE.
Thanks
PS: I'm working with c#

While it is possible to take screenshots with Selenium for multiple browsers, there are some things that you might want to consider before choosing it as your implementation:
As emd mentioned, you will need to create a driver for each type of browser that you wish to take screenshots of as each has a different (internal) implementation for taking screenshots,
Currently the ChromeDriver is not capable of taking a full-screen screenshot (it will only take a screenshot of the current viewport, see here for more details),
Selenium is unable to take screenshots when a dialog box is present. If you are trying to take a screenshot of an unexpected dialog, this can be quite annoying.
As an alternative, you could implement a generic screenshot method in .Net. Have a look into Graphics.CopyFromScreen() method from System.Drawing. This implementation will be browser independent. See here for more details, or Google search some examples of its use for full screen screenshots =]

Related

How to render top of page to png via headless browser?

I'm trying to dynamically generate images for the og:image preview for a particular urls.
Given the designs/stack the easiest option for layout seems to be html/css/reactjs, so just trying to render out to an image using a headless browser of some kind.
Ideal would be js libraries or npm packages, but happy to use any stack to do the rendering (c#, java, anything). If I can't find something thinking maybe have to adapt something used in ux testing?
(That is, I guess I sort of need something like browsershots but only for one browser, only the top section of the page, and ideally running on my server).
Any ideas or suggestions greatly appreciated πŸ™‚ thank you.

Capture a screenshot of Google Map Programmatically

I need to take a screenshot of a Google Map without using a static map in asp.net.
The features I need are not in the static map API, including rotation of the map, traffic, and so on.
I've used several libraries, including the C# web browser, CEFSharp, but none of the ability to take screenshots from the Google map.
For example, my problem with the C# web browser is to load the Google map after the DocumentCompleted event.
The resulting image was displayed as gray content.
How can I get a screenshot of Google Map Programmatically?
Selenium works very well for browser automation in C#. Without knowing your use case not sure if launching a full chrome / Firefox instance will suffice however you can definitely use it launch the browser, navigate to the map, and screenshot.
How to screenshot in Selenium / C# has been nicely answered in another question here .

Render page as a picture

I have question to Java or C# programmers. I want to render some pages in various browsers mainly Firefox and IE and save it as a picture. I have not any serious experience in Java/.Net. Is there any libs/tools for such tasks? I thought about some FF extensions for example but I don't know how to do it in IE. Is the in .Net some libs for dealing with it? Maybe some ActiveX? Any sugestions?
http://www.vesic.org/english/blog/winforms/render-html-to-quality-jpeg/
I'm not sure what your end goal is, but perhaps http://browsershots.org/ offers the functionality you're looking for? It would appear they offer both an XML-RPC interface and also the source code freely.
Edit: It looks like the source code link isn't properly hooked up currently.
You can use the FireFox Screengrab extension - it's very handy!
"Screengrab! is an extension that
makes it easy to save a web-page as an
image – it’s a screen capture tool for
Firefox!
With it, you can save anything that
you can see in a browser window – from
a small selection, to a complete
page."

How to get HTML element coordinates using C#?

This is related to (How to get HTML element coordinates using C#?)
The answer given here is quite good. However, opening up a full instance of Internet Explorer seems like overkill if you're trying to process a good deal of information from within your own spider.
Has anyone found/encountered/thought of a way to to do this using the underlying interface structures of IE (Like IHTMLDocument2 and it's brethren).
Thanks in advance.
Most browsers don't agree on per-pixel rendering in every situation. CSS Compliance, rounded corners, transparency support and padding bugs (I'm looking at you, IE6) are just a few.
The only way to reliably do this is to open a browser like the question you linked and figure it out that way. Even then, know that your results may not be the same as another browser will see it.
Site note: Different DPI & zoom settings for accessibility also will affect this, there are tons of variables in what people see. Mac font rendering also differs, so those users will usually see things slightly different as well.

Building an Internet Explorer Extension/Add-On?

I would like to build a browser extension for IE 7/8. I would like to do it using .NET. Do you know of any resources or tutorials that I could reference to do this? I haven't found much.
Thanks!
JP,
One of the main issues that makes IE extensions hard to develop is the need to develop with C, or .NET.
On the other side, FF and Chrome use (to some extent) JS, which is easier, and has a much lower entrance barrier (How many C "web developers" do you know?).
This is one of the issues / obstacle Crossrider is here to solve.
You can create your first IE plugin within minutes. It will save you a lot of research and development time, and you can write your code with Javascript.
On top of that, if you plan this plugin/extension to also work for browsers other than IE then you can develop a cross browser extension once, using an extensive unified API, and we will make it work for Chrome and Firefox.
Chrome and Firefox each one gets a a native extension file (CRX and XPI respectively) while IE a special EXE engine to run your app.
(Disclaimer: I'm a co-founder of Crossrider)
The same question that was asked two years later has the necessary answer. Everyone should refer to this question now:
How to get started with developing Internet Explorer extensions?

Categories

Resources