 My name is Bichram and I work on a product called Mericom and their commercial is called Mericonite. Basically products what they do is they allow you to test Java applications. Earlier we used to support the swing, now recently we add the effects also. So, one of the byproducts of working on Mericom is that few years back when we were working on Mericom, we used to have our own API. At some point of time we realized that everybody knows Selenium API, right? Most of us know Selenium API or most of the business knows Selenium API. So, we thought that since once we find the company, whether it is a Java component or a web component, we should be able to use the same API to work on that component. So, then we started working on modifying Mericom so that we will use a Selenium web driver. So, over a period of time what happened, it is ready. But then we went into Microsoft's problem, backward compatibility. We have people who are using Mericom and we have a problem of if we use Selenium API and then record our test cases. We are always worried that some test cases that are recorded with the earlier version won't be working with the new version. So, it took long time but recently we have released it. So, the byproduct of releasing Mericom and Mericomite with Selenium. One of the major advantages is that the flexibility that allows. The Selenium API is much more flexible than whatever API we can generate. The second one is that people don't need to learn another API. So, that's where we are. So, the byproduct is that we have a Java driver which we don't need to use it with Mericom or Mericomite. We can use regular Selenium test cases we will be able to develop. That's what I would like to demonstrate. How many of you know about Mericom? Does anybody know about Mericom? Mericom and Mericomite. So, what does Mericom provide? What does Mericom provide? It provides a Java driver which provides you the web driver API by which you can access components of your Java scene and Java effect applications. The way it works is that we have a Java agent which hooks onto the AUT when we launch the AUT. And then it provides the facilities by which it implements the JSON-wide protocol. Selenium JSON-wide protocol is implemented and using that protocol will be accessed. So, what we require is that we require a mechanism by which we can get a web driver instance. We require a mechanism by which we can find elements, web elements with that. That's what the JSON-wide protocol is implemented in Java as a Java agent that runs along with the AUT provides. So, how does the API look like? Like I said, there are only two differences. How do we create a Java driver? Basically because for a web application, if you want to create a Firefox driver, Firefox is launched and then done. But for Java applications, Java applications can be launched in multiple fashion. It can be a web start application, it can be an applet or it can be a regular batch file or somebody bundled it as an executable and give it to us. So, one of the ways... So, there is a mechanism by which we should provide it, right? So, this is what it is. What we do is that web driver driver is equal to new Java driver. This creates Java driver with default interfaces. Sorry, default profile. Default profile is something that is embedded. Embedded basically means this is useful for doing a good testing. This is one request we always had. There are people who were using marathon and marathonite. They come back and say that, KD, can you use it for doing unit testing? Our developers are also looking for it. So, I always used to say that, no, no, no, we can't do unit testing because this is a too high-level API at that point of time. So, we cannot use it for unit testing and I always used to point people to Abbott. Abbott is another of the unit testing tool. Java, swing and so forth, Java is a ability. But it's a pretty good tool. So, I used to always tell people that if you want to do unit testing, go for Abbott. But if you want to do application testing and functional testing, go for marathon. But with the Java driver interface, now I can confidently say that if you want to do unit testing, use marathon. We will provide the interface. So, this is how we create. Embedded launch mode, if you want to create, we just create a new Java driver. And then, how does Java driver work? We create a Java profile and pass it to you. So, what I will do is that I will just give you the concept as far as these two parts goes and then we will go into the code and have a look at it, how it works. So, there are two types, right? We said that the application can be a Fx application, Java Fx application or a JavaScript application. So, we have a concept of a launch type. What we do is that when we create a profile, we have to create set launch type. By default, it goes to swing because marathon was always supporting swing. So, that is the default value. But if you want to test a Fx application, we will do a profile dot set launch type Fx application. Besides that, we also have to tell marathon how the application is going to be launched and for that particular launch mode, we need to provide mechanisms where it can pick up the information. Suppose, if we are running executable, we need to have the path for the executable. If we are running a executable JAR file, like the application which we launched with Java minus JAR, some JAR file, if you are going to give it, then we have to specify that we are going to use a JAR file and specify the path to that. That is what it provides. So, these are the multiple ways in which we can create the outcome. The first one we have seen already, it is just launch mode dot embedded. That basically means that the application is not going to be launched separately. It is expected that you will launch your dialog box or a frame, a frame or one of those and then ask him to test it. The second part of it is Java command line. This is useful in the cases where we have a main class name and then we have a class path and we are going to execute our program with the syntax goes like something like Java minus CT and give multiple JAR files and followed by the main class name. So, profile dot set command class and add class path. There are other things also like you can set properties and then which goes as a VM arguments and all those you can create. But these are the main parts of it. Similarly, we can launch it as a command line. So, basically you can, your application is shipped as a batch file or a executable. In that case, what we do is that we can launch mode command line and give him the set command and give the path to the executable. And the next one is the executable JAR. It is the case where we use Java minus JAR and I give an executable JAR which launches the application. In this case, what we have to do is that set it as a executable JAR and give the path to the application JAR. And then the next mode is applet. In this particular case, a marathon launches applet viewer and test viewer application. It doesn't go to the, it is not going to launch the browser and within the browser it is going to test. This is the applet viewer for this purpose. So, you just give the path viewer HTML file, index.html or application.html. Besides that, the final one is one minute. I think I missed out one of them. There is one more call to web start. This is where we have a JNLP file which is posted on a server. And then we go there and then click on it. And then either application is launched or we go to the JAR, JAR, WES, JAR, WES is the command and then we do the web start. In that case, what we are going to do is that you give a JAR profile, launch mode, web start. And then we have to do set JNLP file and do path to the JNLP file. In all these cases, what marathon does is that except for the embedded case, in all the cases, all these parameters are gathered together. And when we actually create a JAR driver with this profile, it launches the application. Launches the application along with a small add-on to it using a Java agent. What the add-on format is this? JSON-wide protocol using T2P-EP, communicate with our application. So once we do that part of it, so now we have to find a component. We have application running. We have web driver instance with us. But we have to find the component from the application. There can be text fields, there can be drop-down boxes, etc. So what it does is that the Java driver, the marathon's Java driver, what it does is that it re-implements the find-by-comps. So when you do a buy-dot class name, you provide the fully full part name, including the package name. And what it finds is that on the current screen, whatever current window, whatever we have, it finds all the components that are instance of the text field. Similarly, we can have the J component, the component, AWT component, provide instance mechanism by which we can do a set name. This is similar to setID of HTML. On the HTML tag, we will provide ID, right? Similarly, we have a concept of setting a name to a component. If we have set the component name using component name, our Java effects provide setID. So if you have a Java effects in node, setID and then setID, then either buy-dot name or buy-dot ID, both of them we can use to actually access the component which is given that name, all right? And almost all the components, all the swing components or AWT components are used, the class names are used to create the tags. So what we can do is the tag name, if the text field is there, the tag name of it is going to be text-type and field because there are few chapters. Similarly, T view is in the effects. Java effects has a T view. If you want to use review, T view. So then we can use the buy-dot name T view and it gives you all the T view components that are existing in the connection. Once we have these components, we can use the way the normal web element API. You can click on it, you can do a get text on it and if it has a text, it gives you back the text. If not, it gives you null. Or you can right click on it. The rest of the API is going to be exactly as the regular normal web element will be like. And finally, this is the most powerful one is CSS. What marathon Java driver does is the JSON-wide protocol, along with the JSON-wide protocol, it also implements the CSS process. So using the CSS process, it implements the CSS. But this is much more useful basically because in a HTML page, if you look at the table, table has T, R, T, D, T, R, T, D, right. So we have multiple rows, multiple columns. So at any point of time, if I want to access one of them, I have a physical component that is available on the screen. On the HTML page or the web page, I have a physical component that is available. But Java string, Java effects use something called renderers and editors. So if we draw a screen with a table in it, the table cells, for each table cell, we do not have a physical component. There is no way I can access a single cell because this is my physical component for this cell. What it does? It does something called a renderer. Renderer is a single object it creates and it uses it to draw it on the table. So there should be another mechanism by which we can find out these components. So what we use is that we use pseudo elements for it. You know the pseudo elements in the CSS selectors, right. CSS selectors, colon, colon, nth index. Especially nth index is what we use. If you want to say that a list is there, the second element of the list, you can say that colon, colon, nth index. The same thing what we use here. So if I will come back to the table again in the next, right. But at this point of time, have a look at it. This is exactly the same thing. The first CSS selector is saying that a text field that has a set name or set ID set as user name. The second CSS selector tells us that in all the text fields, get me the second one. The index starts with one. Not like the Java for loops or C for loops where it starts with zero. It starts with one. So first is called one. The second is second. Second text field in the screen. And one thing you need to notice that this text field nth index of two need not be the second text field in your screen. It is dependent upon how the panel is created. In the panel, somebody might add a text field into the third row. Then you do get it there. You won't get that. So this is what we use for accessing all those components for which we do not have a physical component on the screen. We use pseudo elements. In this particular case, I have talked about the table. But the same thing is available for leaves. We, you can use by the path and then you can get it and all the other components. Like a combo box. You can get all the options. There is all options. And then the documentation is available and I'll show you that. So basically the first one is what it does is that find elements by CSS selected table column column all cells. What it does is it gives you web elements for each one of the cells. These are pseudo elements. The element itself doesn't exist. But whenever you access this element, the Java driver, what it is going to is going to translate the coordinates, et cetera, et cetera, to that particular element. Similarly, the next one gets all the elements that has text is equal to going. Suppose if you have a table with multiple values, you want to find out all the table cells which has some text in it. So in that case, that's what we are going to do. Table all cells. The next one is going to get a table within the row and column. So 3 comma 2. So third rows at the column are salivating back. And then, like I said, we have renderers. These are all used by pseudo elements that are pointed to your renderers. But there is another concept of filter. How do we do inline edit of a table? In swing or the JWT or Java effects when you do inline edit of it. Basically what happens is that when you double click on a table cell, a editor component is created and it is added into the hierarchy and you do the edit and come back. So using Java driver, when we want to get the we want to modify a cell value. Suppose a cell value, there is an existing value, we want to overwrite it. Then in that particular case, what we need to do? We need to ask you to give back the editor of it and then work on the editor. So in typical cases, what we will do is the point elements here is a selector mn cell 3,2, editor and web element we get and web element dot send keys to send whatever text we want to replace it. So with this one, I will just go into the demo and then show you how we can actually create a Eclipse project and then see to that how we can write one of the test cases. So this is the sample application which we will be using. So basically it is a simple login application. It is a test application. It doesn't do anything. Let me just execute it and then let's have a look at it. So we have a user name field and we have a password field. There is a checkbox called revampurmi and then we have cancel and login. Once we enter any data into so the login screen is going to be in a login button is going to be enabled only when the user name and password is checked. So I am creating a JUnit test case and we just create another sort folder for this. It is a good idea to always be the tests and so forth separate. So JUnit 4 we just run the test case and check it out once. It fails. So using Java driver obviously whenever you write Selium test cases you write you add all the Selium drivers Selium jars. But at the same way when we are using the Java driver what we need to do is you need to add Java driver as well as we need to add the Selium driver because Java driver is nothing but one of the Selium driver. You use the WebDriver interface. So that is what we are going to do for this project the properties take the Java build part and in the library and add external jar what do we require? We require Java driver and since we are I am planning to use a embedded mode I need to add another one called Java agent also. If you are testing Fx application for unit testing Fx application you will be adding Fx agent. In this particular case we have to use the Java agent to combine Fx on the screen So I am using as adding Java driver Java agent and I also need to add all the support libraries that is Selium driver So now that we have added this for me it is available for me to use the Java driver So as a first case what I am going to do is that I will launch this one what you call our login screen and check whether all the elements are working So that is what I am going to do So that is the first thing I require is that before the test So I want to open the login dialog So I am going to just create this I am just doing it so that it comes in the middle of the screen Since we are not passing any parameter it is going to create a embedded Java driver itself it can be just a web driver I just want to check that screen is coming up But we don't If it is the external application that has been launched the private dot post actually closes that application But when we launch the embedded mode it doesn't do a system dot exit etc So it is still running And then I just want to ensure that the login window is also closed so that I would not have because I want to access it here I need to make it a which closes the data Just run the test case and see it Hopefully I won't have any problems there You can see some output there This is the log messages that are coming from the Java driver Basically it is saying that when we did it to close a delete message has gone When we did it itself it got the session idea you can ignore Now that we have the driver it is the expert value we have done the test case essentially So the same thing we can do for all other programs also we have one as well So let's go for a regular test One of the things is that whenever we start an application whenever this login window is coming up the login button is supposed to have been disabled and it gets enabled only when a text is entered into the username and the password So that's what we will try We already have a driver so we don't need to get the driver We get obviously this is a bad way of doing it it goes off let's have a look at the using by ID etc also little bit So I get the username here and similarly but in this particular case we have two J buttons there login print as well as the cancel there are two buttons So we need to ensure that we get only the login button The first thing is that before we do anything we want to check that login print is disabled So I do look at it there is nothing here just because we are running a string application we are not changing any API it is still using the standard web element API or web driver API we are using here So ease enabled is the part of the web element so that's same to we do and then now we want to use the names but the same thing is we can use instead of writing the code and making everybody bold let me just show you a project which I have created for the same application but which is the page of the of the of the of the of the of the of the of the of the of the of the of the of the of the of the of the of the of the of the of the of the of the of the of the of the of the of the of the of the of the of the of the of the of the of the of the of the of the of the of the of the of the of the of the If it is a model dialog at any point of time you can access only that model dialog to behind once you can attach this but there can be non-model dialog so there can be multiple windows right. So we will be using the switch 2 to change it and then figure down just dispose of the login and then driver it does it goes and look at the check elements what is the test case what we have done. So basically get the text field stick that the number of text field the same password field and check box windows we have and the same test what we wrote the one here couple of more things and I have both of them but I removed the password then logins play login button will be disabled or not if I do not give you the name but only give the password because the login button is disabled or not those sort of test and then when we actually do the login button what will happen in this particular case what it does is that it opens up the joption pane and there is a window saying that you have logged in that is all it does nothing more no checking nothing else. So the same test case using a page of the model how does it work basically the same selectors what I used in our test case I am using it here we have a find by tag name text field use the name etc and then we have obviously a web driver and instance we are going to create use and then we are going to do a page factory dot unique elements and then we create our domain object domain methods like saying that login user name and password or set the user name or set the password and obviously you want to check out whether login button is enabled or not so I could have written a function saying that is login enabled instead of that I am giving you a login web element itself I am using this but one more test case looks much much more simpler obviously basically we do not have two access okay driver dot find by each one of those so we are doing it now the test case look at this here page login pl is equal to new page login of driver and from then onwards pl dot set gives a pl dot set password okay we are not going to do a driver dot find and regular web applications it is pretty useful and for if you want to use Java driver for the testing of a Java string and effect application it is very very useful okay similarly it has the page update model has one more row facility right if you have IDs and names are given then what it does is it automatically selects by ID or name the same thing we can use it basically because it is also you know what Java driver is being is nothing but implementing a JSON web protocol and a driver for Java applications so anything that you can do with Selenium we will be able to do it so let us look at the page login page when I created the login page okay I have given set user name set name for each one of the company so what I need to do is that I need to just create web element use the name password remember me login and cancel and then I do a init and then that my standard domain application and then using this the test doesn't play test is going to do it the same this is using the second page login actually we just did a command c control c control v and then created the same login except for changing the page login to page login 2 we do it this way I would like to just show one more example I am talking about table right how are you going to work with tables basically because we don't have physical components for the cells we use the pseudo element and if you use the pseudo element this is one of the examples from swing itself along with the swing examples when from Boracal when you pick it up we will get this so the example looks like this and the test rather than the example so this is all the examples basically we have first name favorite color or again sport number of years and a check box and then in one of these this is readable so we can do all of us like to get so this is the application for this application we wrote the test set up is exactly the same this is where we are creating the table and just showing it and since in the panel I have to create a claim and add it because of the application so this is where I am taking the other initial content is proper or not basically what do I have driver dot find elements by table so it gets me the table and basically what it does is that when you do a get it to put of content of a table or a tree it creates a json object and it is a json array so it is a json array so I create a json array with the table dot get it to put content and take out whether the content is the same or not this is what I am going to do so how do we edit the text mean the css selector is going to be m n cell you got it and then we get the editor from there and then for the editor we are going to send it whatever we want to enter and then we have to pass it keys dot enter basically because the enter key has to be tested whenever we are editing a table in swing like after editing it we have to press enter so we have to press that and then we are checking out whether it is same or not so how do we edit the checkbox field we are getting the m n cell again and then getting the text and then checking out whether it is true or not we are clicking on it and checking out whether it is false and the complicated one is this there is a color field if you have seen that application we have shown the application right the second column is a color field so when you click on it actually what it does is that it opens up a color shows a diagram and you select a color from there and then once you select a color that color is set to the that particular column so how do we check that out so this is what it is so color shows itself is considered as a element a component like marathon so I can use say that okay fine give me the color choose a component but I do not know where the buttons are where the color that patch where it shows multiple colors etc so I would not be knowing about it so basically what I do is that I do a execute script on it look at the set color and I am setting it to black color and then once I press ok on it okay once it goes back and checking it out whether it is same color that is the black is set up basically I got a table I get the cell okay I checked its pseudo component got that ground whether it is whatever current values are not and I click on it and it opens up the window pick a color so I switch to that window I get the color choose a component and using the color choose a component I am setting the color to it and then I again click on ok and then come back to the table dialog in the table dialog goes off okay and then I check whether the particular cell the color has been turned on run the test so this is what is the demo I wanted to show you today any questions from this or anything extra you want to see there are couple of things actually the first thing is that I have this marathon what I have shown you is the open source project which you can use it for testing your application itself it records your scripts in Ruby that actually jruby and that does all the work okay it records the scripts you can run the test on the top of it and if you want to use Java and then use Java driver to do it okay one of the reasons why I am showing it is that basically for looking at the developer side saying that for unit testing it is going to be good we have a plan for we have an assertion window in marathon we have time can I 15 minutes we have I can just show you that how it looks like basically we can go here right click and then it shows the assertion window from there you can see the properties of the component on which we did the right click okay the same thing we are planning to bring it out onto this so that we can use it for the data so the only thing what you are going to do is that profile your Java profile you are going to set a another option saying that I want to look at the properties so when it is running the application you will be able to right click control right click and this is the problem and since we have it I will just show you though how it looks like whether I have a working system hopefully yes instantly marathon test scripts okay allows you to access Selenium again but you need to use the Ruby when you use it because better than test scripts are in Ruby this is the driver dot whatever it is so I am doing a command right click so this is the what sort of window we have a plan but because of some deadlines and some other issues I could never bring it out the idea was that the Java profile you just set a variable saying that I want to bring out this window from then on what this window is going to come up whenever you do it control command right click from here you can see all the properties of it see currently I think that accessible name is jdialog because that is the command we write command right click on the jdialog command swing set tree is nothing but a demo of swing application this is a given based on this is an application swing set tree is open source but currently I do not think anybody is there who is maintaining it but it shows all the functionality of swing which one the marathon it has been released you have you can go to our website marathon testing dot com for java swing application it is a regular functional testing tool it allows you to record it allows you to playback our commercial version supports refactoring creating data devices all that is all I do not want to come to a conference on Selenium at lineback there are two parts to it marathon is open source it is the host on github I will show you then you can go to the github and then get it and then marathonite is a commercial version where we have the refactoring support we have the data driven support marathon grid there is Selenium grid implemented for java application all the best of it like I said we have been working on it for three years almost one and a half years back this product is ready we could have developed really great at the point of time but our major problem is that we have quite a few customers who are using it and we were not sure whether once I put it on to marathon so that what compatibility is based on so that testing itself took long time for that almost nine to ten months we worked on it for creating government thing that what all incompatibility is taking between these questions mostly it is compatible but there are couple of incompatibility and we use so these are the resources this is the marathon website marathon testing dot com where you can see the details about marathon as well as marathonite and if you want to look at the marathon itself including the java driver source and all it is there in the github and the demo what I have shown you today including a effects demo also I said it supports effects but I never talked about effects so there is a marathon demo project folder in github another repository where you can pick up the current whatever demo I have shown you as well as for a effects application and including using marathon itself regular marathon recording application and if you want to download marathon itself we generally release it on source board not project flash marathon