filmov
tv
Selenium with C# 52 - How to get hidden field values using IJavaScriptExecutor in selenium
Показать описание
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();
}
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();
}
Комментарии