I get the error message when I try to select an item from a menu in a webpage. In the code below, I used the Id of the element. When I tried using the XPath instead of the Id, I got a similar error messsage.
Here is the error in full:
An unhandled exception of type 'OpenQA.Selenium.Support.UI.UnexpectedTagNameException' occurred in WebDriver.Support.dll
Additional information: Element should have been select but was div
And, here is the code:
//Select "Perday" for Salary Type
var salType = driver.FindElement(By.Id("adv-search-mobile"));
var selectSalType = new SelectElement(salType);
selectSalType.SelectByText("Per day");
}
}
HTML:
<select class="adv-search-select sal-type-select" name="salarytype" tabindex="6">
<option value="annum">Per annum</option>
<option value="month">Per month</option>
<option value="week">Per week</option>
<option value="day">Per day</option>
<option value="hour">Per hour</option>
</select>