Continuous Delivery – OPA and Selenium, NodeJS and Jenkins #6

Continuous Delivery – OPA and Selenium, NodeJS and Jenkins #6

Previous parts to this series (part one, part two, part three, part four, part five) have spoken about the different tools to test Web Services and HTML Interviews for Oracle Intelligent Advisor. In this post, we will see how a more complex tool can allow the team to perform larger-scale and more sophisticated tests when coupled with Jenkins. In this case the learning curve is more challenging, but often there are already resources available to help the process.

In common with other chapters in this series, the platform includes NodeJS, and this time we have added selenium as well as (for demonstration purposes) the Mozilla driver (also known as gecko driver). The preferred choice of scripting tool is very much up to each developer, however the screenshot below shows a simple piece of NodeJS code to implement something similar to our previous examples.

Working with Selenium WebDriver in this way has a number of challenges in respect of Oracle Intelligent Advisor, the most commonly cited being the dynamic nature of classes and identifiers in the HTML page. As a result, simple selectors such as the following are not advisable since they are not reliable and will change as you make modifications to your Screen:

So instead, as highlighted in the example video above, you end up working with XPath identifiers which are long and laborious to write (of course you can use tools to help you find them):
driver.findElement(By.xpath("//label/span[contains(text(),  'Where are you travelling from' )]/../../../div/div/select/option[text() = '" + myJourneys[journey].origin + "']"));
This is doubly frustrating because obviously this is language specific, and if you need to test the Interview in several languages then you will need different identifiers. There are a few things that can help, including the good news that Google Chrome Console accepts XPath selectors so you can test them to see if you have “found” what you are looking for:

In the screenshot above, an XPath selector (note the $x(“”) syntax) has been entered and the response is an option from the array of options in the Select control “Where are you travelling from”. So I can use this selector to be sure I am populating the Origin attribute on the Screen. There are other tools of course, such as the Selector Gadget Chrome plugin, that can help make it easier. You might also think about using JavaScript Extensions to add a custom style to elements of your page to make them easier to find in Selenium. But I do think this is an area where improvement is needed.

Working with this platform has the  added benefit of being easy to integrate into Jenkins, as we saw earlier in the series as well. Since we previously organized running Newman as a NodeJS Build Step in our Jenkins Project, we can do the same with our Selenium code, in a quick and dirty example.

Jenkins Job Running Gecko

A Jenkins job is running our tests…

Jenkins Job Output Gecko
And the console output in Jenkins is telling us the details. Now that Jenkins and NodeJS are playing nicely, you are ready to set up your environment further (with multiple nodes, ChromeDriver, IEDriver and all the other browser drivers. But for now, we say goodbye to this series of overviews of how Oracle Intelligent Advisor can be part of the big bad world of CICD!

Richard Napier

Author: Richard Napier

Richard Napier joined Siebel Systems in 1999 and took up the role of managing the nascent Siebel University in Southern Europe. He subsequently was Director of Business Development and Education for InFact Group (now part of Business & Decisions) for 8 years. He now runs his Consulting and mentoring company, On Demand Consulting & Education Ltd and has run ODCE since 2010. Owner of the OPA Hub, he also is Co-Founder of the Siebel Hub.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Logo by Southpaw Projects LLC