如何使用Java脚本执行程序使隐藏元素可见 [英] How to make the hidden element visible using java script executor
问题描述
我试图点击一个按钮,但因为隐藏而无法点击。请让我知道如何让隐藏的元素可见1,然后如何点击按钮。
请给我一些例子,我的HTML标签是:
< input id =iskpiFilterActiontype =hiddenvalue =1name =isKpiFilterAction>
嗯,你的问题对我没有意义。但我完全可以回答你的问题。
对于selenium 2(webdriver):
WebDriver driver = ...
JavascriptExecutor jsExecutor =(JavascriptExecutor)驱动程序;
jsExecutor.executeScript(document.getElementById('iskpiFilterAction')。type ='button';);
结果是:
此代码会导致元素类型发生变化(从隐藏到按钮),但它对我们所有人都没有意义。这两个元素有不同的目的/用途。欲了解更多信息,请参阅:
- < input type ="隐藏"的原始目的> ;?
- 在HTML中隐藏输入有什么意义?这有什么常见用途?
- http://www.w3schools.com/jsref/dom_obj_hidden.asp
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 element visible 1st then how can click the button.
Please give me some example and my HTML tag is:
<input id="iskpiFilterAction" type="hidden" value="1" name="isKpiFilterAction">
Hmm, your question doesn't make sense for me. But I can exactly answer for your question.
For selenium 2 (webdriver):
WebDriver driver = ...
JavascriptExecutor jsExecutor = (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:
- Original purpose of <input type="hidden">?
- What's the point of having hidden input in HTML? What are common uses for this?
- http://www.w3schools.com/jsref/dom_obj_hidden.asp
这篇关于如何使用Java脚本执行程序使隐藏元素可见的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!