Over the Moon with Selenium

Over the years, I have become more and more reluctant to write code without good regression tests – 35 years of software development have taught me that it is just too dangerous! Regression testing of user interfaces has always been difficult, but for the last few weeks I have been working with technologies that put user interface testing within easy reach: HTML and the Selenium WebDriver, which star in the following video (if you can wait, read the full story below the video before watching):

This is exciting – I hope you can see why I am “over the moon” (apart from Selene being the Greek Moon Goddess).

Modern Markup Languages

One of the good things about modern User Interfaces based on markup languages like HTML is that logical information about the user interface is available at runtime. For example, a browser displaying HTML maintains a “Document Object Model” of the web page. The content and other attributes of each element within the DOM can be inspected and manipulated at runtime by a testing tool – this is what Selenium does.

Selenium

Selenium is a widely used open-source tool for automating browsers, with growing support from browser vendors. Selenium provides an API that allows you to perform just about any operation that a user could: click on buttons and select items from drop-downs, press keys to enter text, drag and drop items, or perform exact mouse movements and different types of clicks. Over the last few weeks, we have been working on a some thin covers for Selenium to make it easy to drive browsers from Dyalog APL. At the moment we require the Microsoft .NET bindings and can only do the testing from Microsoft Windows. The web server can be running anywhere, and we hope to add other client platforms in the future.

The results of this work are now available in the GitHub Repository Dyalog/Selenium. The following example, included in that repository, shows a simple test which verifies that the TryAPL website is able to execute a simple expression:

 ∇ r←Basic;S;result
 ⍝ Basic test that TryAPL is working - return error message if it isn't
 
 S←##.Selenium
 S.InitBrowser''
 S.GoTo'http://tryapl.org'
 
 'APLedit'S.SendKeys'1 2 3+4 5 6'
 S.('APLedit'SendKeys Keys.Return)
 result←'ClassName'S.Find'result'
 r←result S.WaitFor'5 7 9' '1 2 3+4 5 6 failed'
 ∇

MiServer Regression Testing

The primary motivation for this work has been to create regression test scripts for MiServer version 3.0. The MiServer regression testing mechanism is extremely simple (possibly a bit TOO simple, we’ll cross that bridge later): If a site contains a folder called “QA”, and the folders within mirror the structure of the web site, then a mechanism exists to load each page in turn and run the corresponding test function. You can read more about it on GitHub and see it working in the video at the top of this post.

The Reflex/Commute Operator

The monadic operator is defined and modeled as follows:

     f⍨ ⍵  ←→  ⍵ f ⍵
   ⍺ f⍨ ⍵  ←→  ⍵ f ⍺

   {⍺←⍵ ⋄ ⍵ ⍺⍺ ⍺}

Reflex

Some common well-known functions can be written as f⍨ where f is itself a well-known function:

   +⍨    double
   ×⍨    square
   ?⍨    random permutation
   ⍳⍨    self-index, APL Amuse-Bouche 3

See http://www.jsoftware.com/jwiki/Essays/Reflexive for further examples.

Awareness of the importance of the reflexive case might have led us to avoid the mistake in the definition of the dyadic case of . That is, if

   ⍺⍋⍵ ←→ ⍺⌷⍨⊂⍋⍵

then ⍋⍨⍵ would be sort. Ken Iverson seemed to have had this awareness because that’s how he defined the dyadic case of in J. (I say “seemed” because he expressed surprise when first shown this use of ⍋⍨.)

The monadic case f⍨ came relatively late. It was not in Operators and Functions (1978) nor Rationalized APL (1983), and only introduced in A Dictionary of APL (1987). It came to Ken Iverson when he explicitly looked to natural languages for inspiration, whence it became “obvious”: f⍨⍵ ←→ ⍵ f ⍵ is the reflexive voice (je m’appelle Roger) and ⍺ f⍨ ⍵ ←→ ⍵ f ⍺ is the passive voice (the programming competition was won by a 17-year-old student vs. a 17-year-old student won the programming competition), both having evolved in natural languages for effective communication and elegant expression.

Commute

The alternative definition of ⍺⍋⍵ above, while illustrating the importance of the reflexive case (f⍨ ⍵), also illustrates the passive case (⍺ f⍨ ⍵). ⍺⌷⍨⊂⍋⍵ can be read and understood as “ indexed by the enclosed grade of “, a different (and in my mind a better) emphasis than (⊂⍋⍵)⌷⍺, “the enclosed grade of , indexed into “.

I note that Arianna Locatelli, winner of the 2015 APL Problem Solving Competition but an APL beginner, used twenty-one times in her presentation at Dyalog ’15. For example, was used in the computation of the standard deviation (slide 13):

   sol5←{a←,⍵ ⋄ ⊃0.5*⍨(⍴a)÷⍨+/2*⍨a-(⍴a)÷⍨+/a}

I believe this formulation comes naturally because can be used to write functions in the order that they are applied. Another way to put it is that reduces the need for long-scope parentheses. For example:

   (2×a) ÷⍨ (-b) (+,-) 0.5 *⍨ (b*2)-4×a×c
   ((-b) (+,-) ((b*2)-4×a×c)*0.5) ÷ 2×a

That is easy to implement, {⍺←⍵ ⋄ ⍵ ⍺⍺ ⍺}, is neither here nor there; its value as a tool of thought is easily demonstrated.

News from Causeway – SharpLeaf (Alpha Preview Now Available)

For more than 20 years, Causeway has been developing APL tools to produce automated publication-quality graphics and typesetting. They differ from most modern technologies on mainly two points:

  • The API philosophy is to keep it simple and clean rather than complex and dirty, so that neat output can be generated with the bare minimum of coding
  • The implementation is a forward-going state machine, so that arbitrarily complex inclusions can be created instead of having the engine restricted by the object hierarchy

Following the emergence of the .NET platform in the 2000s, these products were fully refactored into a single package called SharpPlot; this is delivered both as a cross-platform APL workspace and as a stand-alone .NET assembly that can be used outside the APL world. The major benefit of doing this was that 20 years of patched-in functionality could be incorporated into a more consistent and better documented API (see http://www.sharpplot.com) – a side-effect is that the .NET assembly generally performs an order of magnitude faster than its APL counterpart.

SharpPlot, which has until now only comprised the chart generation engine (refactored RainPro product) now also includes SharpLeaf (refactored NewLeaf product).

Page from a sample report

Sample report page (click to enlarge)

The main features of SharpLeaf are:

  • Document Layout: a set of master pages defining paper size and rules for and color, boxes, images, fixed or parameterised text (for example, page number and date) etc.
  • Paragraph Styles (word processing): fine typesetting control over the text flow (font, alignment, spacing, indents, bullets, etc.)
  • Tables (spreadsheet processing): fine control over tabular presentation of data, including multi-page tables
  • Inclusions: text flow around objects such as images, charts, tables, dropped capitals or blank space

SharpPlot version 2.70 includes the first (alpha) version of SharpLeaf. SharpLeaf should be considered as being in its alpha stage (its API could change) with a GA release scheduled to be included with SharpPlot version 3.00 (due Q3 2015). Users are encouraged to try this alpha product and not only report any bugs but also provide feedback on the API and request enhancements. Please note that the SharpPlot engine is not expected to suffer any bugs with the addition of SharpLeaf as it is an independent product.

The alpha version can be requested by sending an email to support@dyalog.com

Dyalog ’15 – An Unexpected Viking Challenge

etnaAfter many months of planning and preparation it was finally time to head from the UK to Sicily for Dyalog ’15. Sun, sea and an excellent conference facility were awaiting us at the Atahotel Naxos Beach in Giardini Naxos and this year, because it would be very hot, we had decided to forgo the traditional Viking Challenge team activity for a more relaxed excursion by coach to see the craters at the top of Mount Etna – Europe’s largest active volcano.

water_everywhereDyalog ’15 kicked off on Sunday morning and by Tuesday everything was going to plan and we were stubbornly ignoring the forecast for storms and rain on Wednesday – after all, the forecasters always over-exaggerate don’t they?
In this case it seems not as we woke up Wednesday morning to torrential rain and had to wade from our rooms (sometime through water up to our knees) to the conference centre.

flood_collageThere we were greeted by more floods and rain only this time it was inside the main conference room and perilously close to the desk with all our AV equipment on it. Time for an emergency change of room but where do you fit 80+ people at short notice? A room was found, the projectors and microphones were set up ready for the start of the day – and we were only 15 minutes behind schedule! OK, so maybe it was a tight squeeze but by then everyone was bonding over flood stories and determined not to beaten by a “bit of weather”.

banquetJust when we thought it couldn’t get worse, we then found out that the beautiful seaside terrace restaurant, where the Dyalog ’15 banquet was due to take place that evening, was also flooded so Banquet Plan C (Banquet Plan B was also under water) was implemented and the whole event moved indoors – not such a stunning location but at least we would all be dry.

During the morning the rain eased off, the floods subsided and our planned excursion to Etna during the afternoon was looking more and more likely. We finally got the go ahead and 69 brave souls set off after lunch to battle with the elements, optimistically hoping the weather would improve as the afternoon went on. However, once we reached 1900m we were greeted by yet more torrential rain and a pretty bad thunderstorm. Were we deterred? Oh no, we just headed off into the storm to stomp around the Silvestri Craters for a bit – although one delegate did, rather hysterically, point out that it probably wasn’t very sensible to be waving an umbrella around in a thunderstorm at that height. Eventually a very wet, cold and bedraggled bunch got back on the coaches but we all survived the adventure, made it back to the hotel and most agreed we had had a lot of fun!
etna_collage
And the moral of the story? It was beautifully summed up by Gitte Christensen in her closing speech: “If you don’t have a Viking Challenge at a Dyalog User Meeting then one will be provided for you!”

Tuesday at Dyalog ’15

IMG_5010MiServer UI Controls

Dan Baronet and Adám Brudzewsky continued yesterday’s presentation by Morten Kromberg on Cross-platform User Interfaces by demonstrating a lot of varied interface elements that are available when creating front-ends in MiServer. Especially encouraging were the special controls designed by Dyalog. These make it possible to have arrays render as complete super-elements (e.g. a table). No need to worry about the many underlying HTML elements making up the super-structure (e.g. table rows and their table cells).

IMG_4970The Dyalog Project Project

Morten Kromberg outlined his plans for a brand new tool to ease development and getting started with APL: An online repository for APL code – software packages that may be retrieved and installed on a computer. This is a significant step in ensuring the future, as a newcomer to programming (if ignoring all the other advantages to APL) often looks at amount of easily available pre-existing code when choosing a language.

IMG_5123Data Binding – The Matrix / Waste Time with John Daintree

Light-hearted as always, John Daintree introduced us all to Dyalog’s already implemented capabilities in making user interfaces automatically update when values the datatable are changed. Obviously this is best described in a video, which will be available soon on video.dyalog.com. Meanwhile, there is an excellent demo on APL Wiki. After John’s presentation, a user demonstrated how he with minimal time effort set up a modern-looking dashboard for presenting numerous varied data.

External Workspaces

Morten Kromberg introduced a new facility by which you can save your code and access it as a memory mapped file which can be shared by the users. This is an advantage when you have to watch how much of the workspace is consumed by the code-base. Stig Nielsen from SimCorp told us how they have applied these external workspaces with much success. Not only can many users access the same workspace, but even users on a Citrix farm can access the file simultaneously. Using this facility, enables SimCorp to start using futures and isolates that would otherwise exhaust the memory available on their costumers’ server farms.

TamStat, a Statistical Package

Blog post from presentation by Stephen M Mansour PhD, The Carlisle Group as well as the University of Scranton,  and Jerry Brennan PhD, A former teacher of Statistics in Hawaii, who has now moved being a fulltime Psycologist.

By Vibeke Ulmann #Dyalog15

Last year I managed to squeeze in a mention of TamStat in a blog post. This year we will do a bit more on this new application which has been developed by Stephen Mansour. The name TamStat stems from ‘Taming Statistics’ and Stephen willingly admitted that he stole the paradigm from Ken Iversson who once talked about ‘Taming Maths’.

Stephen teaches Statistics at the University of Scranton – outside as working at the Carlisle Group. The basis for the development of TamStat was that he wanted to create a one or two semester stats course at the University. In order to create what he considers to be an easy to use, APL based statistics programme, he has included a seamless interface to R.

TamStats functionality can be divided into four different groups:
Summary statistics
Probability Distributions – based on theoretical models,
Relations and
Logic

The underlying implementation is a set of operators representing the different distributions with operands specifying the conditions and the Relations, or Logical conditions which apply

As an example Stephen then conducted a comparison of a Movie Theatre with 130 seats, with an average of 100 attendees  and a 20 seat deviation. He ran the comparison in Excel, Minitab, R and TamStat to show the audience how easy it was to create a close to normal English language expression in TamStat to get the statistical result.

Since last year Stephen has been adding a lot of new features and not least documentation. There is now a 60 page user guide both in print and as a PDF download, a Reference Card  in fold out hardcopy, based on the same structure as the Dyalog APL reference card. The reference card is also available as a download. There is an Excel import functions, and operational R interface. It is now possible to work with Bayesian statistics – a request from last year.

TamStat is now available in 3 versions (almost 4) namely

  • A Dyalog workspace for APL users
  • A downloadable standalone App for students and non-APL users (with ASCII input).No set-up required just get it and start.
  • A Web application  – similar to TryAPL – using MiServer for casual users
  • A Computer programme for professional users (currently under development in Carlisle Group)

Jerry Brennan then took over demonstrating his JMB.APLcloud.com, which is an educational site teaching APL. Implemented in APL of course and using MiServer as the vehicle to bring the content to the web.

Jerry is currently running on MiServer 2.1 and he is in the process of moving to MiServer 3.0.

As Stephen, Jerry has made available documentation, and examples, in the form of games and other ‘fun’ examples to attract the attention of a young audience. He has included drag and drop facilities, to make it even easier for people who have no prior knowledge of Dyalog APL to get going.

Jerry has included TamStat on his website including all the examples from Stephen’s User Guide allowing the users to interactively experiment with the statistics.

Outside of this, he is working with ‘Hacker Highschool’ who work with security awareness for teens and have 1.4 Million subscribers. Hacker Highschool takes an extremely ethical approach, so he is not concerned about making the application available to students.

Stephen Mansour would like to run a workshop on his “Statistical Language” at the Dyalog User meeting next year if there is sufficient interest, so asked delegates and blog readers to let Dyalog know if we should include this in the next User Meeting.