1

Below is the javascript drop down from which I want to select the "All Resume" option via selenium webdriver:

<div id="resume_freshness_container">
<div class="dropdown_small_wrapper">
<div class="left">Last 6 Months</div>
                                <div class="right"><img class="clip_image" src="http://media.monsterindia.com/v2/recruiter/2.1/new_search/newlook_combined.png"></div>
                                <div class="clear_both"></div>
                                </div></div>
<script language="javascript">  
                jQuery(document).ready(function(){  createSingleSelectCombo({id:'selDay',valueVariableName:'day',tabindex:'62',label:"",preSelected:"180",replaceWithId:'resume_freshness_container',width:'216',heightOptions:'height:240px;overflow-y:auto',animateScroll:true,
                options:[{id:'1',values:"in last 1 day"},
                {id:'3',values:"in last 3 days"},               
                {id:'7',values:"in last 7 days"},               
                {id:'15',values:"in last 15 days"},             
                {id:'30',values:"in last 1 month"},             
                {id:'90',values:"in last 3 months"},                
                {id:'180',values:"in last 6 months"},               
                {id:'360',values:"in last 12 months"},              
                {id:'540',values:"in last 18 months"},
                {id:'9999',values:"All Resumes"},
                {id:'4-7',values:"4-7 days"},
                {id:'8-15',values:"8-15 days"},
                {id:'16-30',values:"16-30 days"},
                {id:'31-90',values:"1-3 months"},
                {id:'91-180',values:"3-6 months"},
                {id:'181-360',values:"6-12 months"},
                {id:'361-540',values:"12-18 months"},
                {id:'541-9999',values:"Only older than 18 months"}

                ]});


                borderTopSingleSelect({container:'resume_freshness_container',afterId:'10'});

            });


</script>   

I have used the following code to select the dropdown and then select the required option:

Select select = new Select(driver.findElement(By.id("resume_freshness_container")));
select.deselectAll();
select.selectByVisibleText("All Resumes");

I have also tried selecing it with id "selDay" but both the times it gave me the same exception that I have listed below

Exception in thread "main" org.openqa.selenium.support.ui.UnexpectedTagNameException: Element should have been "select" but was "div"

*I am new to selenium so kindly help me out to know where I am going wrong *

0

1 Answer 1

2

Yeah, you cannot approach it with Select class - it is specifically for select->option HTML structures.

You need to first locate the element with id="selDay", click on it, locate the element with "All Resumes" text and click on it:

WebElement selDay = driver.findElement(By.id("selDay"));
selDay.click();

WebElement allResumes = selDay.findElement(By.xpath("//*[.=\"All Resumes\"]"));
allResumes.click();
Sign up to request clarification or add additional context in comments.

4 Comments

Thanks a lot for the help and by doing it the way you said it works but even after calling "allResumes.click();" the value is not selected. It gets highlighted but on submitting the form the default value which is "in last 6 months" gets passed whereas i want "All Resumes" to be passed
I also checked "allResumes.isSelected()" which is returning "false"
@YatinGrover just a shot in the dark, can you repeat the click two times?
Yeah I tried it the same thing earlier. But it didn't work so changed my approach. Now I was sending "tab" key to reach to the desired element.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.