Monday, August 8, 2011

Watir Tutorial: Text fields in JD Edwards Enterprise One

Because JD Edwards' Enterprise One system is a web application, it can be easily tested using Watir.  The only issue I found in the most straightforward of testing is when you encounter Javascript in places like grids.  Text fields and most buttons work as expected, although you do have to drill into the HTML a step or two.  Let me give you an example.  (I will assume that EnterpriseOne, and Watir are both installed and functioning properly, as these are beyond the scope of what I intend to do here.  I will also be using Internet Explorer for this, with the Developer toolbar installed, as per the recommendation by the Watir community to locate the correct HTML tags for testing).





Let's start with a nice basic window:  The Word search window, and in our system the Fastpath would be 'P01BDWRD'.  At first glance we have a text field, a check box and a grid.  This shouldn't require any testing really since it is maintained by Oracle as I understand it, but it's an example for how to write scripts, nothing more.

Let's open the Developer Toolbar and click on the 'Search word' text field to find where it is located in the HTML.  A blue box should appear, as shown below (where the red arrow is pointing).  At the bottom, note the id field, and the name field.  Both are similar and in my tests I have used both (probably redundantly), but you may only need to use one, I'll do some testing and update later.  (Ignore the 'LEWIS*' there for now, I was just testing it.)




The other information you need is a little ways back up on the left hand window, the 'tree view', what you are looking for is indicated below, the id "e1menuAppIframe", and this will also be used later in your testing. 


The way that we tell Watir through Ruby to fill in this field is through these parameters we have just discovered using the Developer Toolbar.  Let me show you what we would code up to illustrate: 

  1. require 'rubygems'
  2. require 'watir'
  3. b = Watir::Browser.new
  4. b.goto("http://my.e1site.org")
  5. b.text_field(:name => "User").set("myUserName")
  6. b.text_field(:name => "Password").set("myPassword")
  7. b.button(:type => "submit").click
  8. b.text_field(:id =>"TE_FAST_PATH_BOX").set "P01BDWRD"
  9. b.form(:action => "/jde/E1Menu_FastPath.mafService?e1.state=maximized&e1.mode=view&e1.namespace=&e1.service=E1Menu_FastPath&RENDER_MAFLET=E1Menu").submit
  10. b.frame(:id => "e1menuAppIframe").text_field(:id => "C0_18").set("LEWIS*")

The line that we are concerned with right now is line 15 which sets our text field to the value that we want.

"b.frame(:id => "e1menuAppIframe")" is what we have to drill into to get within the correct frame.  Simply coding up the last part of line 15 I have found is not enough for Watir to find the text field in question.  Just take it as a rule of thumb, that when you are working in a program within JD Edwards, that you need to tell it that you are using that frame, and then from there tell it the text field or the button or check box or whatever.

The other piece of information we got earlier is what we use to tell it which text field.

".text_field(:id => "C0_18")" is what I had to use next, to tell it that we wanted to talk with the "Search Word" field.

Finally, ".set("LEWIS*")" is used to set the text field to the value in question.

Don't forget, that we could have used ".set("#{variabledata}")" and a for loop to cycle through an array called variabledata to get through a while set of data that we want to test.  If you are following along, and haven't successfully made a call to your database to get that data, then we will cover that later.

I hope that this has been helpful!

No comments:

Post a Comment