 A very warm welcome to week 1, day 3 of our session. This is going to be the last class for this week. In today's session, we will be mainly looking at the assessor's commands provided by the Selenium. We will then move on to the topic of how well we can debug our IDE scripts. We will discuss briefly about the other components of Selenium. And the session will end with an assignment on Selenium IDE for you all to submit. The general guidelines for the session remain the same. Please try and ask your questions when I open the forum for questions. Just ensure that your mics are on mute. In case you have a question to ask, kindly just raise your hand and I will hold on the session and we can discuss your question there. I hope my voice is audible to all of you and there are no disturbances. If there is any concern, please let me know right away. So everybody is able to hear my voice. Well, voice breaking has a bit of attachment to the intimate connection as well. Just check it to your end. Words will be unclear at times. I will try and speak as slowly as possible. We could all have a bit of an extent problem but I will try and keep my mode of communication in English. I must say this is quite a varied batch. There are people from US, India, UK, Ireland, Australia and I believe we all have a different English extent so please bear with me at those times and I will try and speak as slowly as possible. Well, I didn't do much of anything. I will look up with my lecture collection. I can't do this right away otherwise this session will disconnect for all of you. So if the administration issues are over, can we start with the today's topic? Okay, thank you everyone. So for much more better test creations, there will be times in your test automation that you might want to use a feature where you can store a variable information and then perform some operation on it or use that variable again in your test scenarios. For those kind of operations, Selenium provides us with excessive types of commands. So we have seen there are action commands, there are resolution commands and now there are these essential types of commands. For example, we have a scenario where we have an amount variable which is used very often. It is a good idea to store the data in one variable and then use this variable across our test scenario so that the chances of error are reduced. To display the value of a variable in the law of the Selenium IDE, we use the eco command. It also helps with your debugging. Some of the important essential commands which we are going to see are store values, store cookie, store body test, store eval, etc. So let us have a look at the store command. The store command takes two parameters that takes value to be stored and a variable. So we have store, target will be the value which we want to store and in the value we will have the variable name in which this data will be stored. To access this value of the variable in close, we have to use two curly braces and proceed it with the dollar sign. So for example, I have stored my user name in a variable user name and now I am going to log in. So for my type command the data instead of call at the rate myside.org I just pass dollar curly brace user name curly brace x. So during the run time, the IDE script is going to take this variable and substitute instead of this variable the data value which is stored here. The second command which is important and will be helpful as well for us is the eco command. The eco command is mainly used to print the value of our variable in the messages of the IDE logs. It is mainly helpful during the debugging process. So the command is eco and in the target we print, we give the value of the variable which we wanted to print it on the IDE logs. So to have a demo of this store command usage, I will be taking up a test scenario in our shopping website. So the test scenario is we have to log into the application giving it the user name and password. We will then move on to my account information. In the my account information we are going to validate whether the email address provided is same as given for the login. So I am going to first perform this flow and then I am going to record it. So I have logged into my system. So once I have logged in, I go on to view or change my account information. In this, I would like to validate whether the email address provided during the login time is same as the email address mentioned here. So this is my scenario. Now let us take a look at the test case which has been created for this scenario. So I have my test scenario which is verify account information. Before my test case starts, I have used two store commands. In the first store command, I have created a variable user name and I have stored the value of my login ID. In the second store command, I have created a variable password and stored the value of the password. Now we go to the type command. The type command is where the user name and the passwords are entered in our web application. So in this type command, in the value field, instead of passing my login ID, I have provided the variable name. So to do so, I have used the correct way of representation as dollar and the variable name inside to curly braces. I have done something similar for the password and then the login happens. The link which says we have changed my my account information is clicked. Now I have used this command called verifyValue which basically verifies the given value on that object. So the value which I want it to verify is same as dollar user name and then once this verification happens, if it is a success, it will show in green color as it will be red and move on to the next set of steps and finally log off from the system. So this is my test scenario. Let us execute it. So it has logged into the system. It has clicked on the my account, verified the value, logged off. So I hope you all can see that the verified value statement has passed and the value provided in the dollar user name is verified with the value available on the web application in the text P. So this was the demo to show you how we can use the store command. Now where the store commands are useful, well in this scenario it is indeed useful because the chances of causing error by your own bio is reduced. We do not have to type the same data value again and again in our test scenarios. These are quite simple and small scenarios which we are creating here. In real time the scenarios could be much more complex and could run to last number of steps. So to reduce the chances of error by some typing mistakes or some other problems, it is a good idea to store the data which is repeatedly used in your test scenario in a variable and then use this variable for the raw. Second advantage is in case the variable value changes, you have to make the change only at one place and not at each and every step of your test scenario. Well this kind of test case creation or this phenomena in test automation is also known as data driving your test scripts. We need to understand that Syllium IDE by default doesn't allow us to attach to a database or to access value from some external file source. If we have to limit ourselves just to IDE creation, this accessor command comes handy to perform a similar behavior in data driving our test scripts. Connecting to external file sources or data sources is possible with the Syllium web driver or RC. So are there any questions? Please let me know. We will then move on to the next demo of stored files. So are there any questions? Please ask. Yes, the use of this variable, so the question is, is the use of the variable restricted to a specific test case? Yes, the use of this variable is restricted to this test case. In Syllium IDE, the test cases in your test suits are independent of each other. So the other question is, store is the only way to declare variables and use them in the script? Yes, store is the accessor command. And we have to use the accessor commands to store information in them and access them later in our script. I'm sorry I didn't get what you have written. Jnt the store one is yesterday's. Not sure what you mean by here. So I will move on to the next topic now. So the question is for verify value, you just click on the text box by creating the new command. Verify value command was inserted in my script. And once I have inserted the command, I have to identify the target. To identify the target, I click on this select button and then click back on the screen on the text box itself because that is the target. And that is how the locator is added. Okay, great. So we will move on to the next topic now. So the second topic is about the stored valves. Stored valves is a map type of data structure inside the Syllium IDE. So before we explain more about stored valves, let us understand what is map? Map is one of the kinds of data structures available in the computer science field and it is a general way of storing element information. The way a map stores data is in the form of a pair of element which are termed as keys and values. Each key has a value to it. A map cannot contain duplicate keys. The key in here refers to the Syllium variable names and the value refers to the actual data inside them. So we created this variable user name. This goes inside the Syllium data structure map called as stored valves and we can also access this variable by using the dollar variable name. What is the use of stored valves is that stored valves is mainly used in situations where we have to perform some data massaging or some JavaScript code on this variable data and again extract or save some value from this massage in some other variable. So for those reasons we use the command of stored valves. So in our second demo for today, yes I can repeat it, let us go through this demo. It will clear the concept more. So in our second demo to see the usage of stored valves, we are going to log into the application search for a product. Once the search page is loaded, we are going to store the body of that search page inside a variable. On this variable I am going to perform an action using a small JavaScript code whether the search body page contains the name of the product which we have inputted or not. So let us first look at the flow and then the test scenario. So the flow is log into the application. So once we have logged into the application, we go to the quick find, I type in a product name, click on the search button. This product page comes. I have to find out whether the search page which has been uploaded has the word unreal in it or not. And then log off from the scenario and come back to my home page. So the test scenario here looks like this. So I have opened the application, logged in towards it. Here is my search happening when I have provided the value unreal. This is the command which I am using, store body text. This command store body text is basically going to store the current page inside the variable search body. So then I have used an eco command just to print in the logs the content of this variable search body. I have then used a command called a store eval. The store eval command takes two inputs. It takes a script and a variable name. So in your first input, I have performed a script operation wherein I have accessed the content of the search body by using the stored wires. I have performed on it a simple JavaScript operation to find a substring. So I have used the command dot index of and I have cast in the value. If the unreal string is available in this whole body data which is stored inside the search body, then my value of the index will come as positive. It will basically provide me the index value from where the string unreal starts. Then I have printed the value of text found on IDE log and moved on to log off and closing my test scenario. So in here we have used two store accessor commands, store body text. Again repeating, it will store the content of the page inside the variable and return it. The store val, this command takes two inputs. First the script name, the second the variable name in which the return of the script will be saved. So I am now going to run this test scenario. So it has opened the page, typed in username, password, click on search, stored the variable information, performed a script operation on it and logged out. Let us take a look at the logs here which are generated. So our operations are performed. Let us look at the statement where it has executed store body text and saved the value in store body. I have equaled the value of search body. The eco command has printed all the information available inside the search body which is effectively the search page which was generated when we have given it a product name. The store val command has executed and in the text found the index of unreal string which has been searched inside this whole body is now available and it is a positive value meaning that this unreal word was found inside this whole search body. And then the scenario has moved over to log off and coming back to the home page. So this is the second test demo which we have for today. So I am now again repeating the test scenario and the kind of commands that we have used. So once we have logged into the application, we want to now come to the command of store body text. In the store body text you insert this command. The store body text does not need you to select any target. In here the target itself is the variable name. You can also refer to the reference available in your selenium IDE to understand it better because the store body text function is itself to store the page on which this command is being executed upon. So once this has been stored, it is stored inside the generic map of our selenium IDE. So this search body becomes a key in here and the value associated with it is the data associated with that key search body. Now we have used the store eval command where the first input is the script and the second input is the variable name. Script is the JavaScript snippet which we want to execute. So on the search body variable, I want to find out whether the unreal word is available or not. So I have used this JavaScript and I have stored the value inside the text prompt. If my text prompt is a positive integer, it means that unreal word was found in that inside the body of that page and my test scenario consists. So let me know if there are any questions from any one of you. So the concern is that instead of opening a test case, show at least one life. I will perform a life test case. It was just in the interest of saving the time of the session. So which one of this you want to see? I'll show you the second one. Fine. I will record again. So are there any questions? So the statement is the positive return value means string was found and not the index of the string in the body. The positive value means that the string was found and the string which was found, the index of that string started return. Please repeat. Please repeat what? Can you please let me know what I'm supposed to repeat? Well I can't repeat the whole thing for the benefit of others in the class. You can go back and refer to the recording later today. So I'm going to record this test scenario. Besides this, are there any questions with the concept? Please let me know. Okay, so let us begin with the recording of the scenario of searching a product in our application and verifying whether its value is available in the search text or not. Shidevi, you have asked me this question in various forms and I've answered again and again the same thing. I'm last time speaking about this thing. When we use the command index of, it means that if the value returned is positive, it means first of all the string is found. Secondly, the value returned is the value from where the string starts in this, the substring starts or it has been found in this whole block of data on which the search was being done on. Okay, I hope I'm ample here, fine. So let us start with the recording. So we capture the body of the searched page. To do so, we have to first go up there. I'm right now login to the system, searching a product. So now I need to insert a new command on the search page of stored body text. Inside the target, I give a variable name. So once this variable information is stored, I need to now evaluate whether this information has the string which we have searched. So I type in another command, store eval. Inside the target value, I give my variable data to access it. I use these stored bars. I create my JavaScript function. I want it to find unreal here. I give it a value text found. I insert another command saying eco. I want the text found to be printed. I move on to completing the remaining test scenario. I've come back to my home page. So I've saved this test scenario as demo stored. And now it is executed. So are there any questions while I have recorded this? Please let me know. Is it not clear to all of you how we have done it? Yeah, you can. I will unmute you. Let me answer the previous question. So the question is, is a certain amount of JavaScript knowledge necessary? Well, but not. It depends upon your test scenario. It is always good to, since we are working in the test automation field, it is a good thing to know what is the language the test underlying test automation tool understands. And if you are aware about any of the programming languages, then knowing the programming language for that specific automation tool is not much of a challenge. Knowing JavaScript will be necessary if you just want to, you know, be bounded by the IDE itself. Otherwise, if we move on to web drive work, we can perform much more operations and get a broader view. Yeah, okay, that is great. If you already know some Java, it will help in your upcoming sessions and it will eventually be discarding the IDE and moving on to web driver where we will be using Java. It is all right if people do not know Java here because that is the, that is kind of expected because we are going to start knowing about Java after this week for next two weeks and then we will again come back to scenario. I am going to unmute you now Shree so that you can talk and say your question. Yeah, please let me know. Hello, Shree, can you please speak up your question? I can't hear you. Shree has asked me to click on the command store eval, yeah, because that is the, yeah, so you are saying that for the commands like as a text or verify text, the value which we use, the data which we input is used to do a version on the actual data received from the website, right? Yeah, because every command, see, in Selenium, all the commands take two kinds of inputs, right? So it depends from command to command what kind of behavior the second variable or the first variable is supposed to do. You could see that in our target, we have not used locator for store body text, but a variable name, okay? So from command to command is the first of this week. The value which we are going to find from this evaluation of this store, this target stored by body data.index of, this evaluation of JavaScript returns a value which is stored in text file, okay? So if there are any more questions, let me know. So the concern is, do you have to learn Java before the session? No, we do not want you to learn Java for the session because you have paid for learning Java in these sessions, okay? You're welcome, Devan. Thanks for asking for it. Is body data a variable? Yes, body data is a variable. Any more questions from anyone? Okay, I'm going to take a five-minute break and after that we will see the topic of how we can debug our ID scripts because it will come handy and a much needed topic and we will then want to know more about the other Selenium components available. Let's meet after five minutes. Okay, so I hope everybody is back on the break. So let us start the next topic. Please hold on your questions. We will take a question so then I will open the forum again. So now the next topic for today's session is that we have to understand how well we can debug the scripts with the Selenium IDE. It will so happen while preparing your test scenarios with Selenium IDE that you will encounter situations where your test scenario will be failing because of some issue with your script or maybe the application. It is kind of hectic and not advisable to run your test scripts again and again from the starting position. You can always pause your test script on the position you think it is going to fail and then move it step by step. So Selenium allows us to add breakpoints in our test scripts. Breakpoints are those well-defined positions inside our test script on which we want the executed test case to stop on hold and then accordingly we can make changes in our test script and move to the next set of steps. So these are a few methodologies by which we can debug our test script. So these buttons are important. So this is the button for playing the current test case. This particular button is for pausing and resuming our test scenario and this one is stepping in to allow us to execute step by step from the breakpoint. To add a breakpoint to any part of your script you have to right-click on that command and insert a breakpoint. So on this particular step once encountered during execution your IDE will pause and allow you to make changes to whatever with your test scenario or application in that case and again resume to the next set of steps. So I am going to execute this test scenario and show you that it does not have to click in wait and we can then how we can resume it. So it has encountered a breakpoint. On this breakpoint my test scenario is halted. The icon of pause and resume has changed from pause to a resume position and this step into icon has become active. So by clicking step into it will move on, it will go inside that step and execute it. If I click on resume my rest of the execution of steps will resume. I can add as many breakpoints as I want in my test script. So these are required to halt your test script on a defined position so that the debugging of your test scripts become easier. The second important information about debugging is available in your logs. These are very crucial and very handy when you want to understand what has actually happened with your executed test script. By using this clear button here you can clear all the logs and you can increase the logging information from just info to debug which is an advanced log information. The error which will just list the error and not all the steps execution. So clear is going to clear the logs so that you can just see the logs of your current test scenario. The reference is like a help for Selenium ID commands. It in general tells you of the command that you have selected or these commands just highlighted what is this command all about and what are its arguments all about. So these are the important sources of debugging and comes in handy in actual real time situations when you are automating your scenarios with Selenium IDE. Now let us move on to the next topic for today. The Selenium components. Is anybody also having a problem with your voice? Please let me know. I am just doing a sound check. Hello, is the voice clear now? For you Shri Devi, is the voice still blurring and words are getting dragged in or unclear? Okay, so let us resume the session. So Selenium Automation tools consist of different components which are mainly the Selenium IDE, the Selenium Remote Control, Selenium Grid and Selenium Web Driver. It is also known as Selenium 2.0. We have already seen about the IDE. Just revisiting it again. We understand that IDE is an integrated development environment for our Selenium test. It provides the feature of allowing us to record and replay our Selenium test scenarios. The IDE is a Firefox extension and it works only with the Firefox browser. It allows us to save tests as HTML and in other supported formats by allowing us to export these test scripts. When we will be moving on to the web driver session, we will see how the IDE script can be exported and stored as a Java file instead of an HTML file. And then we will be working on these Java files with our web driver. It also allows us to add insertion and sensors, etc. commands for advanced test automation scenarios. The Selenium RC is a solution to cross-browser testing. So once we move on from this record replay phenomena of the Selenium IDE for advanced test automation like data-driving our test scripts using conditions like F, S, Y, creating loops for etc. We have to move on to Selenium RC or web driver in our case. Also, the test scenarios which are created in the RC or web driver can be executed in any of the supported browsers. The RC is created in Java and is available for different operating systems. It basically acts as a proxy. We will shortly see a diagrammatic representation of the behavior of RC and web driver which will make it much more clear. And when you come down to Selenium RC you can coordinate any of the supported language whether Java, Ruby, Python, Perl, .NET, C, hash, etc. So for all the supported languages different client libraries are made available for the Selenium people. Selenium Grid allows the Selenium RC solution to scale our test suits to run in multiple environments and in parallel. So tests in the grid are sent to a hub which are then redirected to the different Selenium RCs and on different machines the browsers are launched and the test is executed. We use grid when we want to run test in parallel or we want to execute the same test on different browsers simultaneously so that we could save some time. So when you want to do such an action with Selenium you have to use the Selenium Grid. Selenium Web Driver is the recent addition in the Selenium set of components. The Selenium Web Driver doesn't like Selenium RC that any JavaScript inside the browser rather it directly calls to the browser API and uses each browser's native support for automation. So only for Web Driver you have different browser drivers available. For Firefox it is default. For Internet Explorer you have an I driver for Chrome driver and so on and so forth. So here is a diagrammatic representation of how Selenium RC and Web Driver works. So Selenium RC we basically have our test written in different programming languages. It basically calls the browser by injecting itself or JavaScript inside the browser and through that it writes the application whereas the Web Driver uses the browser native API itself to automate it and write the web application as written in the auto test. So this is the major difference between Selenium RC and Web Driver. Selenium RC is still used by different organizations and it is still powerful but Web Driver is a much better way of using Selenium because of its advanced feature and there is very less dependency on the Selenium part itself as it drives the web browser driver directly making it much more powerful and support for scenarios like exact kind of applications, other complex web technologies it's much more in the web driver. So if there are any questions regarding the Selenium components or any other topic please let me know or if there are any more questions with the Selenium IDE in general we can discuss this right now or if anyone has faced any issues with the recording or the IDE we can discuss them. So the question is Web Driver and RC can do the same thing but Web Driver is better technology, right? Yes, Web Driver and RC are both used to perform similar kind of operations which means that we want to interact with databases we want to use a situation for loops, etc. in our test scripts which the IDE doesn't allow and we want our test scenarios to run on multiple browsers on multiple operating systems. So yes, they very much do the same thing but Web Driver is a much better technology in terms of test transmission per se. Also, a lot many open source tools like water, etc. have also moved on to the Web Driver kind of technology where they are using the default browser API itself to drive the browser. You are welcome. Any more questions? You can ask me any questions from the last two days from today. I hope you all have received the material for today's session I will be mailing the materials after the session finishes. Or should I be going to unmute you now so that you can ask me that question? So please go ahead and let me know. So basically we have a question wherein this is the so we have a question where people have asked whether and how we are able to find out which command does what and what kind of inputs does these two different commands take. So I will try and explain it. So Selenium has three different command types mainly. So we have action commands we have assertions and we have the assessor commands. Now the reference or help for these types of commands is available in the IDE itself in the reference window or one can refer to the Selenium HQ.org website to know in detail about different commands. Having said that let us understand again what the action command does. So action command is used where we want to perform some action on the web application which will mainly change the stage of the web application. For example open click and wait type click itself select etc. All these commands are action commands and they and when they get executed they change the stage of the web application under test. These commands mainly take the target and the value. In here the target is the object of a web application on which the action will take place. The value is the data part of it so if to perform the action value is required or data is required that is provided for the value input of the command. For example we have type command here the target is the text field object on which the action type will take place and data provided by the value field will be filled in. This is the behavior of the action command. Now let's go down to assertion type of commands so we saw that in assertion we mainly have the assert set of commands and the verify set of commands. These commands mainly take input the target on which we have to run the assertion and validate value of and the second parameter is usually the expected value. So they match or assert or verify the actual with the expected and accordingly behave. Assert if will on the script but verify will not. So we decide according to our own test scenario which of these command types will be useful. The third type of command is the Assessor type of commands. This type of command mainly helps us to store the data inside a variable and perform action on it. So different type of Assessor commands are available and their functionality basis is that we can store data and perform some action on it etc. So we have commands like store store eval store body text etc. available to us. So whenever we see a Selenium command we basically have to keep in mind these different type of categories of Selenium available and accordingly understand the kind of input that kind of command will take and behave. So I hope this makes it clear to you why for exertion the value was validation point but the value in here was the variable for an Assessor command or a data to be sent to a website called an action type of a command. So is this clear to all? Okay. Great. Thank you for asking this question. So let me know if there are any more questions. Okay. I will Okay. Great. So I will now explain the maps here. So maps are data structure elements which are made available from Selenium to store information. A map stores data in form of a key value pair okay. So for each key in the map there is a value associated with it. The key has to be unique for a map. So the default map data structure or Selenium is made available in the stored so we have to use stored words. Stored words is a map which contains the variable name as key and the value as the value of that key. For example we created a variable username so in stored words we can have such keys username password then we created a variable called body text to access stored words which means we want to access the data value or the variable calling it like this. Stored words inside square brackets the name of the key will provide this is required for the stored value command on Selenium. Okay so I hope this explains are there any more questions? Yes it is so somebody has said it is like a hash table yes it is like a hash table a map is a hash yes the stored words is the path here so as Bernard has mentioned the link SeleniumHQ.org docs you can find information of the commands in the docs also in the IDE I showed you that there is this help section where you can find the information about the various Selenium commands here so I have a small I have some small work for you all of you please take up some time and do that because it will save a lot of time next week when next week onwards we will begin with the Java classes where we will be learning some basic concepts of Java and some of the object oriented concepts it is important because we will then be moving on to the web driver topic of Selenium and to know web driver we have to know Java and I have chosen Java as the language of for this class we could have chosen any other scripting language as well but Java comes very handy it is very powerful and it will do a lot of work to each one of us to know Java and work with Java so I will be sharing these slides I would request all of you to install on your system the correct Java version depending upon the operating system version etc you have also please download and install the Eclipse Eclipse is an IDE for Java and it is required for programming our files in Java it makes it much more helpful and handy so please do these two things now let us come down to the assignment I want all of you to create a test suit which contains three test scenarios in the first scenario I want you to log into the account verify the account information and log out the second test scenario will be for searching a product and verify the search the third test scenario is buying a product verify the purchase in the order section please use assertion commands wherever applicable and please use accessor commands as applicable so you have to ensure that once you have logged in you have asserted the logged in once you have logged out you have asserted the log out once you have searched for the product you have asserted the search in the page etc so try and complete this assignment and email it to me on stfcellinfo at the regiment.com you will see that when you are doing these assignments you will be touching base on all what we have discussed in the last three days and it will help you grasp your concepts much better and make them as well rest I have received over email some of the questions and I will be emailing the material for this session after the session ends as well as the recording I hope you all have received the day 1 and day 2 presentations and the days you presentation will be shared today so with this our Selenium IDE sessions are over we will now move on to learning Java next two weeks and then we will move on to learning web driver so I would like to thank you all for your time I hope the session was fine for all of you I have taken the feedback regarding my voice I will get my network connection checked so that none of you face this issue again and I hope the speed of the session was ok I have tried to reduce whatever is the feedback please drop an email I will try and improve as it has improved the session and thanks a lot to everybody you all have been quite an interactive audience and that helps keep the session alive ok thanks a lot everyone bye