{"id":3391,"date":"2015-10-30T07:43:17","date_gmt":"2015-10-30T07:43:17","guid":{"rendered":"http:\/\/www.dyalog.com\/blog\/?p=3391"},"modified":"2018-05-21T12:29:44","modified_gmt":"2018-05-21T12:29:44","slug":"over-the-moon-with-selenium","status":"publish","type":"post","link":"https:\/\/www.dyalog.com\/blog\/2015\/10\/over-the-moon-with-selenium\/","title":{"rendered":"Over the Moon with Selenium"},"content":{"rendered":"<p>Over the years, I have become more and more reluctant to write code without good regression tests &#8211; 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 <a title=\"http:\/\/www.seleniumhq.org\/\" href=\"http:\/\/www.seleniumhq.org\/\" target=\"_blank\" rel=\"noopener\">Selenium WebDriver<\/a>, which star in the following video (if you can wait, read the full story below the video before watching):<\/p>\n<div style=\"width: 584px;\" class=\"wp-video\"><video class=\"wp-video-shortcode\" id=\"video-3391-1\" width=\"584\" height=\"438\" preload=\"metadata\" controls=\"controls\"><source type=\"video\/mp4\" src=\"http:\/\/www.dyalog.com\/blog\/wp-content\/uploads\/2015\/10\/Selenium_and_MiServer.mp4?_=1\" \/><a href=\"http:\/\/www.dyalog.com\/blog\/wp-content\/uploads\/2015\/10\/Selenium_and_MiServer.mp4\">http:\/\/www.dyalog.com\/blog\/wp-content\/uploads\/2015\/10\/Selenium_and_MiServer.mp4<\/a><\/video><\/div>\n<p>This is exciting &#8211; I hope you can see why I am &#8220;over the moon&#8221; (apart from Selene being the Greek Moon Goddess).<\/p>\n<h2>Modern Markup Languages<\/h2>\n<p>One of the good things about modern User Interfaces based on markup languages like\u00a0HTML is that logical information about the user interface is available\u00a0at runtime. For example, a browser displaying HTML maintains a \u201cDocument Object Model\u201d 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 \u2013 this is what Selenium does.<\/p>\n<h2>Selenium<\/h2>\n<p><a title=\"Selenium Home Page\" href=\"http:\/\/www.seleniumhq.org\/\" target=\"_blank\" rel=\"noopener\">Selenium<\/a>\u00a0is a widely\u00a0used 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.<\/p>\n<p>The results of this work are now available in the\u00a0<a href=\"https:\/\/github.com\/Dyalog\/Selenium\">GitHub Repository Dyalog\/Selenium<\/a>. The following example, included in that repository, shows a simple test which verifies that the TryAPL website is able to execute a simple expression:<\/p>\n<pre> \u2207 r\u2190Basic;S;result\r\n \u235d Basic test that TryAPL is working - return error message if it isn't\r\n \r\n S\u2190##.Selenium\r\n S.InitBrowser''\r\n S.GoTo'http:\/\/tryapl.org'\r\n \r\n 'APLedit'S.SendKeys'1 2 3+4 5 6'\r\n S.('APLedit'SendKeys Keys.Return)\r\n result\u2190'ClassName'S.Find'result'\r\n r\u2190result S.WaitFor'5 7 9' '1 2 3+4 5 6 failed'\r\n \u2207<\/pre>\n<h2>MiServer Regression Testing<\/h2>\n<p>The primary motivation for this work has been to create regression test scripts for <a title=\"Dyalog '14 MiServer 3.0 video\" href=\"https:\/\/dyalog.tv\/Dyalog14\/?v=eLUaLIuKxk8\" target=\"_blank\" rel=\"noopener\">MiServer version 3.0<\/a>. The MiServer regression testing mechanism is extremely simple (possibly a bit TOO simple, we&#8217;ll cross that bridge later): If a site contains a folder called &#8220;QA&#8221;, 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\u00a0<a title=\"Testing with Selenium.pdf\" href=\"https:\/\/github.com\/Dyalog\/MiServer\/blob\/development\/MS3\/Documentation\/Testing%20with%20Selenium.pdf\" target=\"_blank\" rel=\"noopener\">on GitHub<\/a> and see it working in the video at the top of this post.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Over the years, I have become more and more reluctant to write code without good regression tests &#8211; 35 years of software development have taught me that it is just too dangerous! Regression testing of user interfaces has always been &hellip; <a href=\"https:\/\/www.dyalog.com\/blog\/2015\/10\/over-the-moon-with-selenium\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,11,19],"tags":[],"class_list":["post-3391","post","type-post","status-publish","format-standard","hentry","category-cto","category-miserver","category-tools"],"_links":{"self":[{"href":"https:\/\/www.dyalog.com\/blog\/wp-json\/wp\/v2\/posts\/3391","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dyalog.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dyalog.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dyalog.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dyalog.com\/blog\/wp-json\/wp\/v2\/comments?post=3391"}],"version-history":[{"count":33,"href":"https:\/\/www.dyalog.com\/blog\/wp-json\/wp\/v2\/posts\/3391\/revisions"}],"predecessor-version":[{"id":5167,"href":"https:\/\/www.dyalog.com\/blog\/wp-json\/wp\/v2\/posts\/3391\/revisions\/5167"}],"wp:attachment":[{"href":"https:\/\/www.dyalog.com\/blog\/wp-json\/wp\/v2\/media?parent=3391"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dyalog.com\/blog\/wp-json\/wp\/v2\/categories?post=3391"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dyalog.com\/blog\/wp-json\/wp\/v2\/tags?post=3391"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}