How To Make The Hidden Element Visible Using Java Script Executor
Currently am working on Selenium Webdriver with Java Am trying to click on a button but i can't able to click because it is hidden. Please let me know how to make the hidden eleme
Solution 1:
Hmm, your question doesn't make sense for me. But I can exactly answer for your question.
For selenium 2 (webdriver):
WebDriverdriver= ...
JavascriptExecutorjsExecutor= (JavascriptExecutor) driver;
jsExecutor.executeScript("document.getElementById('iskpiFilterAction').type = 'button';");
Result is:
This code causes changing type of element (from hidden to button), but it doesn't make sense for all of us. These two elements have different purpose/use. For more information see:
Solution 2:
I didnt quiet understand the question.. However .. if you have a hidden object which you want to unhide dynamically using JavaScript using some trigger, this is a way you could do that:
<head><script>functionunhide()
{
document.getElementById("iskpiFilterAction").type = "button";
}
</script></head><bodyonload="unhide()"><inputid="iskpiFilterAction"type="hidden"value="1"name="isKpiFilterAction"></body>
I am using body onload event to unhide the object so the moment this page loads you will see the button which u can then click. However if you want it some be triggered at some other event you can use the function accordingly.
Hope it helps.
Solution 3:
Try this:
WebElementelement= driver.findElement(By.id("iskpiFilterAction"));
((JavascriptExecutor) driver).executeScript("arguments[0].style.type = 'button';", element);
Post a Comment for "How To Make The Hidden Element Visible Using Java Script Executor"