Selenium with C# 52 - How to get hidden field values using IJavaScriptExecutor in selenium

preview_player
Показать описание
How to get hidden field values using IJavaScriptExecutor

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 IJavaScriptExecutor? 
IJavaScriptExecutor is an Interface that helps to execute JavaScript through Selenium Webdriver.

IJavaScriptExecutor 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 IJavaScriptExecutor along with selenium

How to get hidden field values using IJavaScriptExecutor?
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 IJavaScriptExecutor

Code :
[TestMethod]
public void HiddenField()
{
IWebDriver driver = new FirefoxDriver();
driver.FindElement(By.XPath("//tbody//tr[2]//td[4]//button[1]")).Click();
Console.WriteLine(s);
driver.Quit();
}
Рекомендации по теме
Комментарии
Автор

Hello madam, thank you for explaining about hidden elements and how to automate it. Very useful video.

sv
Автор

Can you do video on How to locate dynamically generating fields

riyaann
Автор

Hi,
How do I get control on Console Issue tab

amdtaeeb
Автор

PLEASE UPLOAD more video's on data driven, cucumber framework

pavankumar-qcdg