admin管理员组文章数量:1328037
Currently am working on selenium webdriver. I have many drop downs like visualization, Period, Type etc,. In the drop down many options are there. I want to select an option from the drop down and my target is to find element is through ID.
But in the HTML tag the element is not visible to select the option. I verified so many question in that they are mentioning use javascript exceutor.
Can any one please help me the java script for the html tag:
<select id="periodId" name="period" style="display: none;">
<option value="l4w">Last 4 Weeks</option>
<option value="l52w">Last 52 Weeks</option>
<option value="daterange">Date Range</option>
<option value="weekrange">Week Range</option>
<option selected="" value="monthrange">Month Range</option>
<option value="yeartodate">Year To Date</option>
</select>
Currently am working on selenium webdriver. I have many drop downs like visualization, Period, Type etc,. In the drop down many options are there. I want to select an option from the drop down and my target is to find element is through ID.
But in the HTML tag the element is not visible to select the option. I verified so many question in that they are mentioning use javascript exceutor.
Can any one please help me the java script for the html tag:
<select id="periodId" name="period" style="display: none;">
<option value="l4w">Last 4 Weeks</option>
<option value="l52w">Last 52 Weeks</option>
<option value="daterange">Date Range</option>
<option value="weekrange">Week Range</option>
<option selected="" value="monthrange">Month Range</option>
<option value="yeartodate">Year To Date</option>
</select>
Share
Improve this question
edited Dec 4, 2013 at 9:24
testing
asked Dec 4, 2013 at 9:07
testingtesting
1,79615 gold badges46 silver badges75 bronze badges
1
- Is there any solution please suggest me some ideas to implement in the code. – testing Commented Dec 4, 2013 at 10:34
1 Answer
Reset to default 4You can try to use the following script to make element visible: document.getElementById('periodId').style.display='block';
In java code this script can be executed with the following code:
JavascriptExecutor executor = (JavascriptExecutor)driver;
executor.executeScript("document.getElementById('periodId').style.display='block';");
If you just want to select an option in drop down you can use the following java code:
Select select = new Select(driver.findElement(By.id("periodId")));
select.deselectAll();
select.selectByVisibleText("Last 4 Weeks");
本文标签: jqueryHow to create javascript executor to make element visible in selenium webdriverStack Overflow
版权声明:本文标题:jquery - How to create javascript executor to make element visible in selenium webdriver - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742241474a2438861.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论