Friday, May 17, 2024
 Popular · Latest · Hot · Upcoming
1
rated 0 times [  6] [ 5]  / answers: 1 / hits: 13350  / 11 Years ago, wed, december 4, 2013, 12:00:00

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>

More From » jquery

 Answers
6

You 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);

[#49865] Tuesday, December 3, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
isham

Total Points: 69
Total Questions: 86
Total Answers: 86

Location: Anguilla
Member since Sun, Jan 29, 2023
1 Year ago
;