How to test canvas selenium c# project - c#

My Project has been using selenium to run it frontend regression tests for quite a while now. Due to a shift in Dev tools, an area of the screen that was using jquery to display some front-end stuff, has now shifted to using canvas element (HTML5?). This is causing me a bit of a headache as I have no idea how to go about testing something in selenium c# that has no tags, XPaths or identifiable factors with which to interact in the usual way.
The canvas effectively creates an entire hierarchy tree of different boxes, which depending on the text in the box, changes size and location(X and Y).
What is 'recommended' best way of interacting with a canvas element?

Talk to the dev team and have them write/expose the APIs that you need to do the desired testing. You can then call them using JS in your script.
My company converted a personalization page from Flash to HTML5 canvas a couple years ago and this is what I did and it's worked out fine. I generally use the UI like a user would to set up the scenario and then call the internal APIs to query the CANVAS on if an image was added, if the text displayed is correctly, etc.

Related

Xamarin Forms Catalog Thumbnail View

I have built a Xamarin Forms app for Android and iOS for the company that I work for. This is my first exposure to Xamarin and while I really like the ability to write native apps for these platforms in C#, there are some details that I'm still working on.
One of the pages that I create is a thumbnail view of all products of a particular type. I was creating the page by dynamically generating a Grid where I would create a stack panel with an image, price and name of the product, and insert it into the appropriate row/cell combination. Problem is, on large catalogs, this would cause the page to crash because it is using too much memory with the Image control. I solved this by using a WebView for the image/price/name combination, which works but I know is not the best way.
I've researched using bindings but I can't for the life of me figure it out. I'm not using XAML but rather generating the UI dynamically from the code. If anyone would be willing to give me a sample of how to do this the right way I would really appreciate it!! There are a fair amount of examples out there, but I can't find anything on how to display essentially a gallery of products.

Best way of drawing a chart in a web page

I'm new in web programming and just want to ask for an opinion. I want to develop a web page and in the home page, I want to display a kind of chart. With nodes connected with arrows and the arrows will be hyperlinked. In a window based application, I understand there are tools like Visual Basic Power Tools in which you can drag and drop shapes like lines and oval or arrows and using there, it is fairly easy to make a chart.
But in a web application, I can't find any tools or anything that can help me draw a chart. Is there any recommendation on some kind of tools or something so that I can draw a chart in a web page? :)
You can do it either client side or server side.
Client side
There are some javascript libraries which will render charts to your web page(Client side) upon feeding it with the data in JSON format. Checkout chart.js and d3.js. Chart.js uses HTML5 canvas elements to draw the chart where d3 uses SVG for drawing charts.
Server side
ASP.NET has some charting libraries/server controls which renders charts for you. Check out this blogpost which has sample code to get started.

Rotate Windows form upside down

I have a C# application that has an existing WinForm that I now need to display upside down.
The application will be displayed on a touchscreen Windows 7 device. If two people are using the device, one person is viewing it right-side-up while another user will be simultaneously viewing it upside-down. I will need to have one control displayed right-side-up while another control is displayed upside-down, each duplicate forms. Both need to be functional. It is not necessary for the title bar and Windows close, maximize, and minimize to be rotated.
Is there a way to easily rotate this Form and all of its contents without having to rewrite it from scratch?
Unfortunately, rotating controls is not directly possible in WinForms.
At least, not if you want them to retain their functionality. It would be relatively simple to draw the control into a bitmap, rotate the bitmap, and then draw that back to the desired location on the form. But you would obviously lose the ability to interact with the controls. They would just be static representatives of their original selves.
But making functional upside-down controls just isn't going to happen. I mean, you could try to write a bunch of custom drawing code for owner-drawn controls, but you'll still run into a bunch of bugs, corner cases, and compatibility problems. The Win32 controls that WinForms is based on just don't support this. No big surprise, really, considering they were invented some 20–25 years before anyone thought of computer screens that you could carry around in your pocket and rotate in any direction. There is a good reason that UI technologies like WPF came out around the time that touch screens and tablets did.
There are some possibilities that can be explored when it comes to flipping the entire screen, but that's not going to help when you want different controls going different directions. (And I guess it betrays my vantage point as a desktop app guy when I say this, but that just sounds like an incredibly confusing UI.)
If you absolutely have to have this, someone else is going to have to give you another route to hack it, perhaps along the lines of Dhawalk's comment: hosting the WinForms control inside of a WPF app that does provide built-in support for rotated controls. I don't know enough about this to make any concrete suggestions down that path. From a few minutes of searching, it appears that WindowsFormsHost does not actually support rotation transforms, so this may be a non-starter anyway.

Square pattern in google maps circles

I'm working on a .Net application which has a Google map in it. It is simply done by using the .Net WebBrowser component showing a web page.
It works really good except for one thing:
When I draw circles they have an ugly looking square pattern. At first I just noticed lines, vertical or horisontal but when doing editable circles and made them large enough, a square pattern appers. I does not matter which zoom factor I use, it is always the same amount of pixels between the lines.
If I show the exact same web page in a standard web browser (IE, Chrome or FF) it looks fine so it seems to have something to do with the WebBrowser component. But isn't that using the installed IE version?
Any help will be appreciated!
A picture says more than a thousand words but since I'm a new user at stackoverflow I'm not allowed to post the screenshot....
Best regards,
Mattias

Upside down browser in WPF application

I am writing a WPF application using Csharp. Its a touch application that has four browser windows displayed. Two upside down. The screen will be built into a table and lie flat. Four people will use the table - two on one side and two on the other. Thus the need for the upside down (or 180 degree rotation) browsers. I have tried using SilverLight and its Browser Brush. This works to display the browser content upside down BUT to interact with the browser you have to make the browser control active (instead of the Brush) and this turns the content back the right way up. I guess what I need is a Browser control that can be rotated in the normal way and work rotated. IE in Dot Net wont work.
Sascha Barber and Chris Cavanagh have blog posts about an alternative WebBrowser Control based on Chromium that behaves like a real WPF control. Check out http://sachabarber.net/?p=597 and http://chriscavanagh.wordpress.com/2009/08/25/a-real-wpf-webbrowser/
If it is WPF application you can use a simple RotateTransform to rotate controls any degree you want. So upside down should be no problem.
Sample/Tutorial

Categories

Resources