We have already discussed about the basics of Selenium RC and Selenium IDE. Now today we will be discussing some of the functions which can help us during the test automation using Selenium RC.
In the last Selenium article, we learned almost all Selenium IDE commands. In selenium RC also there are so many such functions available using which we can perform operations on any web application.
One of the very basic and most useful function of Selenium RC – selenium.close();
I hope you got the purpose of this function. Using this function we can close opened web Browser during the automation run. This function does not have any parameters.
Depends on the requirement some time we have to close the Web Browser at the end of each testcase and similar to that there might be a requirement to maximize the web browser before we start executing our automated testcase. To maximize the browser we can use selenium.windowMaximize() function. This function also does not have any parameters.
We know the function which can be used to navigate from one URL to another URL. You are very correct, with the help of selenium.open() functionwecan perform this operation.
On any web application s, we will be having all kinds of web objects / elements. Some of them are Dropdowns, Text fields, Radio buttons, Checkboxes, Buttons, and Images etc. Now to perform operations on each one of them we will be requiring different functions. Let’s go through each one of them one by one.
selenium.select(String obj, String value); Using this function we can select any item available in a Dropdown menu. It has two parameters, “obj” and “value”. Both of them are of type String. “obj” is the XPath of the web object or the name of the web object and “value” is the actual item which we want to select from the Dropdown menu.
In above function we have selected item from the dropdown specifying the exact “value” but we can also select dropdown item using its index number.
selenium.select(String obj, String index); obj and index are of type String.
To type something we can use selenium.type(String obj, String text). Here also “obj” refers to the name of the web object or the XPath of it.
selenium.click(String obj) is a multipurpose function available in selenium. Using this function we can click on any image, we can also select/unselect any checkbox and also click on the buttons as well.
For selecting / unselecting checkboxes we have separate functions as well.
selenium.check(String obj) – it selects the Checkbox
selenium.unCheck(String obj) – it unselects the Checkbox
If we want to find out whether any checkbox is selected or not, don’t worry we have special function available for that also.
selenium.isChecked(String obj) – this function returns true/false based on the checkbox condition.
I think you are familiar with the next functions that I will be describing.
selenium.getText(String obj) – This function retrieves text from the any specified Web Element. It can be a text field or just a text on web.
Similar to above function we have one more function which will help us to retrieve values from the web table and that function is selenium.getTable(obj.row.column);
Also, all discussed commands in selenium IDE are also available in selenium RC.
I hope now you will be able to perform all your web operations very effectively with the help of all above functions.
Similar Articles related to Selenium:
Selenium Automation Tool (Selenium IDE)
Selenium IDE Commands/Functions for Data Verification or to Retrieve Data
How to Run Recorded Script of ‘Selenium IDE’ Using ‘Selenium RC’