How to compare two images in Robot Framework - html

I am new in automation and want to automate a site whose back-end in HTML5 and containing canvas element.
I want to compare canvas images with my stored image.
For image comparison I need to use robot framework.
I had tried with "robotframework-imagehorizonlibrary" library but still testcases were failed.
Can any one please help me.
Thanks.

I would suggest the RobotAppEyes Library, which is basically an extended version of Selenium2 library, and it actually has a keyword named Compare Images.
Use it as the following:
Compare Image <path, imagename=None, ignore_mismatch=False, includeEyesLog=False, httpDebugLog=False>
see details here: http://navinet.github.io/Robot-AppEyes/RobotAppEyes-KeywordDocumentation.html

Related

SSRS - Accessing System.Drawing.Image.FromStream

I am currently trying to center an image on screen in SSRS. While this functionality is not directly support it is possible to provide custom padding based on the image size. This is an external image provided by a database, so the image changes repeatedly and I cannot hard code a padding. I am trying to retrieve the width of the image using:
=System.Drawing.Image.FromStream(new System.IO.MemoryStream(CType(System.Convert.FromBase64String(Fields!HomeLogoImage.Value), Byte()))).Width
However when this is entered into an expression place holder, "FromStream" is not recognised.
I can confirm that I have added the reference to the system.drawing assembly and I am using version 4.0.0.0.
I am returning to SSRS for the first time in quite a while so any advice on this would be greatfully received. Or even if there is a way to center images without resorting to the System.Drawing method, I would love to hear.
Many thanks.
Try the following. I've tested this against some .png database images I had lying around and it seemed to work.
=System.Drawing.Image.FromStream
(new System.IO.MemoryStream(CType(Fields!Image.Value,Byte())))
.Width
EDIT after OP update
To do the same with an external image you can use the following
=System.Drawing.Image.FromStream
(new System.IO.FileStream(Fields!HomeLogoImage.Value, IO.FileMode.Open))
.Width
This assumes that the HomeLogoImage field contains a valid path and filename to the image.
However You will probably encounter a permissions error. I have not done this myself so I can only point you to a link that discusses the issue with possible solutions. I've not done anything other than a quick search to find this so better solutions may be available
https://social.msdn.microsoft.com/Forums/sqlserver/en-US/31490332-c2f7-48a4-9928-29916ce002b4/request-for-the-permission-of-type-systemsecuritypermissionssecuritypermission-mscorlib?forum=sqlreportingservices

Can I input a variable into HTML and give it to CSS to update a gauge reading?

I am trying to write a bit of code to read a sensor and, with my ESP32 make a webpage that will display the value.
But on a gauge with a "needle" ( think speedometer type of thing ) like output, I can make variables in CSS and I can make the gauge in CSS and display in HTML fine.
I can change the value of the gauge by changing the CSS variable BUT I want to be able to pass this varibale to CSS from my HTML file.
This is so I can process the HTML page on my ESP32, updating the value of the sensor and display it, I can't seem to get an option of updating CSS varible through HTML.
I would like to rather stay away from JavaScript to be hoest, I'm already learning CSS and HTML to make this work, but if need be I will do it.
Or could I do this in PHP perhaps ?
Any advice ?
If you want to make this dynamic, you have no other option rather than to recur to JavaScript in combination with what you are using. From what I understand it's something like either a percentage value or a rotation degree value you are toying around with.
What I can recommend for your specific case is to use an inline style to change the position of your indicator.
Something like:
<div style="width: 99%;"></div>
It would help if you share with us what you have as code till now.
Also, from what I understand you are still new to this sort of coding, but something that would probably work really well for you could be Socket.io you just assign a port that receives information and configure it, and you could configure your ESP32 to send info to that port I suppose, not really familiar with that part though.
If you want really real time value refreshing with esp32 on its own web you have to use websockets.
I don't know what server library you using, but there are a couple of websocket libaries out there.
I recommend ESP32_AsyncWebserver from Me_no_Dev. This is a fully async webserver implementation, and it is containing the async websocket too.
If you succesfully implemented that to your project, and loaded your static html file with the gauge you mentioned, on runtime of the esp32 you can send websocket text messages to the front-end javascript code. Once you received the messages on the javascript side you can easily update anything from there.
If you interested in this more, i will write some code for you in here. Just let me know.

How are DOM/rendered html and Coded-Ui are related, can coded-ui test a web application without even considering how that page is rendered in DOM?

I want to know how the coded-ui in web application utilizes DOM of that page. Or is it related to that page's rendered html is coming?
Edited: If suppose i have a grid having rows and column and i want to capture any particular column in it, then do coded-ui takes the help of the rendered html in this process (id,tagname etc) ?
you can utilize the htmlcontrols which is listed in below url:
https://msdn.microsoft.com/en-us/library/microsoft.visualstudio.testtools.uitesting.htmlcontrols.aspx
I used codedui jquery extensions available in NuGet here
. Once you will add this dll as a reference you can make use ExecuteScript() method for running a jquery script inside coded-ui. Similary you can make use of other built in members.

Converting d3.js SVG code to a standalone program — Example?

Either with a headless browser, google filesytem API, or some other way.
This question says you can, but not how.
Converting d3.js SVG code to a standalone program -- any suggestions?
google groups has more hints, but no examples.
I've spent a bunch of time playing with the node-canvas example, as well as the phantomJS svg example. I can't figure out how to make them play together. Apparently in Linux, the x-windows Javascript rendering engine isn't very good anyway.
My API reading list of JavaScript, d3.js, SVG, CSS, and other HTML stuff is already mountainous - all I want to do is save a .svg image that I generate with d3.js.
Help, please.
This will neither be easy nor overtly complicated. Main reason being is that a web browser alone cannot save an SVG file from a DOM rendering, unless it's Chrome version 12.
Thing is that an SVG image is just a plain text file with a bunch of rendering instructions. The solution you point to basically says you would have to do this server side. Though they suggest node.js, you can do this in any server-side language you'd like.
Trick is to take your JavaScript/HTML interface, make it either keep track of all objects you create, or otherwise be able to serialize all of them, and then send that data (ex: via ajax) to a server-side program which would reconstitute that to an SVG file and offer it to be downloaded.
The challenge is that both your programs (client-side, javascript and server-side: php/etc.) will more or less have to re-implement SVG specifications to make this work and have common understanding as to how you serialized it for the transmission. There are virtually no stock components that do this for you.
There are some examples of using node().parentNode.innerHTML with 64B encoding, but I couldn't figure out how to use it.
https://groups.google.com/forum/?fromgroups#!topic/d3-js/aQSWnEDFxIc
The easiest solution I've found so far is FileSaver.js demo here:
http://eligrey.com/demos/FileSaver.js/
It uses the HTML5 filesaver interface.
I came across this today, I've not tried it but perhaps someone will find it useful:
https://github.com/d3-node/d3-node
const D3Node = require('d3-node')
const d3n = new D3Node() // initializes D3 with container element
d3n.createSVG(10,20).append('g') // create SVG w/ 'g' tag and width/height
d3n.svgString() // output: <svg width=10 height=20 xmlns="http://www.w3.org/2000/svg"><g></g></svg>

Generating CSS sprites for dynamic images

I have a webpage which contains about 20 - 50 dynamic images (images served from a non-static source). These images are served through a servlet based on the request URL. This results in a request being generated per image, which leads to performance decay.
If these images were static, I would create a CSS sprite and replace the 50 requests with a single one. As they are dynamic this is not that easy of course. I'm looking for a tool/library/method that I can use in order to aggregate these images into a single sprite at runtime. Luckily image size is constant and the same for all, which should make this much easier.
Any suggestions?
You can check and try jawr (https://jawr.dev.java.net/) library for generating/modifying (also compressing, merging) css files on servlet. It has option to change background images dynamically.
You may arrange bundles for switching css file(s) for changing skin(s).
Plus side: You can also manage and arrange your .js files too!
You can append images with the free ImageMagick library, via a call to the system command line, so you have a lot less to code in Java and it is faster.
For appending horizontally, use this command:
convert image1.gif image2.gif image3.gif +append result.gif
For appending vertically, use this command:
convert image1.gif image2.gif image3.gif -append result.gif
For more informations: http://www.imagemagick.org/Usage/layers/#append
So, with CSS you can display the sprites using a single image with a simple offset (you can use the CSS "background" propriety for load the image and set the offset of the single sprite that you want to display). No JavaScript is required if you do only simple things.
Is the processing overhead on the server worth it?
I'm thinking about this now for C#, trading of the added complexity creating the dynamic images and sending them to the client, with the reduction in individual image accesses.
A trade off worthy of a bit of analysis.