Home » 2016 » August » 16

Using JavaScript to Drive Selenium Tests

I’ve written about using Selenium to test web applications before.  But all of those articles have assumed you are using C#.  I’ve realized that Selenium has multiple language bindings which allow me to use any language I want but C# just seemed easier at the time.  But, now I’m in an environment that doesn’t use .NET at all.  They use Java.  I know Java, but I choose not to use it and instead my focus at this shop is all JavaScript.  Which means, if I want to write Selenium tests to verify my work, I need to write my tests in JavaScript.  But Using JavaScript to Drive Selenium is, in my opinion what everyone should be doing.  At least everyone who is writing most of their web application using client side code.

Think about it, the primary language you wrote the client side with is JavaScript, and yet you are going to write your tests using C#, Java, PHP… when you could be writing the tests using JavaScript.  The same language you used to write the bulk of your application.  Further, when you write your tests using C# or Java, you’ll probably either write the tests using a unit testing framework (MSTest, NUnit, JUnit) or you’ll use some sort of BDD adapter like SpecFlow to coerce the unit testing framework into the behavioral pattern you need.

image

Continue reading “Using JavaScript to Drive Selenium Tests”