135. Using isSomethingSelected command with multi-select field






isSomethingSelected Selenium RC command can also be used to verify whether any option is selected in the multi-select field.

  • Returns Boolean value true when any list option is selected in  field
  • Returns Boolean value false when no list option is selected in the field

Example:

selenium.isSomethingSelected("css path for locating multi-select field");  -> This statement returns either true or false.

Test Description:

Now lets use isSomethingSelected( ) method to find out whether any list option is selected in the multi-select field
  • If the result is true, then type the text 'At least one list option is selected in the multi select field' into the TextArea field 
  • If the result is false, the type the text ' No list option is selected in the multi select field' into the TextArea field
Understand the comments mentioned on the above screenshot to make yourself clear:



Lets Implement the Test on Eclipse IDE:

Pre-requisites:

1. Create a new Project say 'RC-Project51' in Eclipse IDE
2. Configure the Project to work with Selenium RC
3. Configure the Selenium Standalone Server to run from Eclipse IDE
4. Create a package say 'package51' under the newly created project.
5. Create a Java Class file say 'Class51' under the newly created package as shown below:



Actual Steps:

1. Write the following code into the newly created Java Class file as shown below and make sure that you resolve all the errors before going to next step:


2. Create a test method 'isSomethingSelectedDemo()' and  use Selenium RC  command isSomethingSelected as shown below


3. Use Selenium RC command type for
  •  entering the text 'At least one list option is selected' into the Text Area field when the result of the Selenium RC command isSomethingSelected is true.
  • entering the text 'No list option is selected' into the Text Area field when the result of the Selenium RC command isSomethingSelected is false.
As shown below:


4. Start the Selenium Standalone Server
5. Save and Run the 'Class51.java' file by selecting the 'JUnit Test' option and ensure that our Automation Test has entered the text 'At least one list option is selected' as shown in the below video:

Watch the below video:

Click here to watch the video.

Download this Project:


Click here to download this project and import into Eclipse IDE  on your machine.


Please comment below to feedback or ask questions.

Using getSelectedValue command with drop down field  will be explained in the next post.




No comments:

Post a Comment

Followers

Labels