Google+

417. Using getAttribute("value") method with Text Area field






getAttribute("value") can also be used with Text Area field to retrieve its value.

Test Description:

Now lets use getAttribute("value") method to retrieve the text inside the Text Area text field as explained in the below screenshot:





Lets Implement the Test on Eclipse IDE:

Pre-requisites:

1. Create a new Java Project say 'WebDriver-Project61' in Eclipse IDE
2. Configure the Project to work with Selenium WebDriver
3. Create a package say 'package61' under the newly created project.
4. Create a Java Class file say 'Class61' 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 'retrieveAndVerify()' as shown below:




3. Use Selenium WebDriver  command getAttribute("value") method for retrieving the text from the Text Area text field and also use JUnit method assertEquals( ) to verify whether the text retrieved by the getAttribute("value") method is equal to the text inside the Text Area field as shown below:



4. Save and Run the 'Class61.java' file by selecting the 'JUnit Test' option and ensure that our Automation Test has passed to confirm that the text retrieved from the 'TextArea comment' Text Area field using getAttribute("value") method is equal to the text inside the Text Area field 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 getAttribute("value") method with drop down field  will be explained in the next post.


 

No comments: