Google+

416. Using getAttribute("value") method with Password field






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

Test Description:

Now lets use getAttribute("value") method to retrieve the Password text value entered into the Password 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-Project60' in Eclipse IDE
2. Configure the Project to work with Selenium WebDriver
3. Create a package say 'package60' under the newly created project.
4. Create a Java Class file say 'Class60' 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 'typeRetrieveAndVerify()' as shown below:




3. Use Selenium WebDriver  command sendKeys( ) for entering the Password value say '143143'  into the 'Password' password field as shown below:




4. Use Selenium WebDriver  command getAttribute("value") method for retrieving the password  value from the Password password field and also use JUnit method assertEquals( ) to verify whether the password value retrieved by the getAttribute("value") method is equal to the password text entered by the sendKeys( ) command as shown below:




5. Save and Run the 'Class60.java' file by selecting the 'JUnit Test' option and ensure that our Automation Test has passed to confirm that the text retrieved from the 'Password' password field using getAttribute("value") is equal to the password text entered into the  'Password' password field using sendKeys( ) 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 Text Area field  will be explained in the next post.


 

No comments: