Selenium with Java 52 - How to get Hidden Field values using JavascriptExecutor interface

preview_player
Показать описание
What is JavaScript?
JavaScript is the preferred language inside the browser to interact with HTML dom.
This means that a Browser has JavaScript implementation in it and understands the JavaScript commands.

What is JavaScriptExecutor? 
JavaScriptExecutor is an Interface that helps to execute JavaScript through Selenium Webdriver.

JavaScriptExecutor provides two methods "executescript" & "executeAsyncScript“ to run JavaScript on the selected window or current page.

Hidden Field:
The input type="hidden" defines a hidden input field.
A hidden field let web developers include data that cannot be seen or modified by users when a form is submitted.
We can not get those values using only selenium but we get those values using JavaScriptExecutor along with selenium

How to get hidden field values using JavaScriptExecutor?
By using this code we will get hidden field values

Possible Interview Questions on hidden field in selenium
How to get hidden field values using JavaScriptExecutor

Code :
@Test
public void HiddenField()
{
WebDriver driver = new FirefoxDriver();
}
Рекомендации по теме
Комментарии
Автор

Hi, I have a dropdown list which contains hidden values, once u select any value from list then that is visible in html. So I wanted to select particular hidden value from dropdown. Can u guide me how that can be done ?

kenchug
Автор

Thank you. Can I have some doubts and need help, please can I have email

granand