HOW TO SELECT LIST ITEMS FROM SPAN TAG SELENIUM| Element should have been "select" but was "span" SELENIUM

SELECTION OF PARTICULAR MENU FROM DROP DOWN WITH SEARCH BOX SELENIUM


Facing Problem while selecting Menu from Drop down menu made from span tag with search box as an option. Below is the solution for the error Element should have been "select" but was "span".

Code After inspection of the Elements one after the other :

INSPECTING DROP DOWN MENU

 <span class="select2-chosen" id="select2-chosen-5">Select Status</span>

INSPECTING SEARCH BOX

 <input aria-activedescendant="select2-result-label-13" aria-autocomplete="list" aria-expanded="true" aria-owns="select2-results-5" autocapitalize="off" autocomplete="off" autocorrect="off" class="select2-input" id="s2id_autogen5_search" placeholder="" role="combobox" spellcheck="false" type="text" />

INSPECTING OPTION TO SELECT



SELENIUM CODE FOR SELECTION OF MENU FROM DROP DOWN LIST HAVING SEARCH BOX

WebElement click1=driver1.findElement(By.id("select2-chosen-5"));
click1.click();
WebElement statusList=driver1.findElement(By.id("s2id_autogen5_search"));
statusList.sendKeys("Lunch Out");
WebElement click2=driver1.findElement(By.className("select2-match"));
click2.click();
WebElement click3=driver1.findElement(By.id("subPunch"));
click3.click();


Implementation of above tag will resolve your issue and will automate your system.
Share on Google Plus

About Bittu choudhary

A Software Engineer and SEO Expert.Self-Employed and Making Money through google.