Currently employing Selenium with C#
I am working on an automated test scenario that involves a user logging in as 'jonpark2'. Once the user successfully logs in, their username is stored within a span element's text. My task is to locate this element and perform an assertion check on it.
In my attempt to achieve this, I have the following code:
public static void Userloggedin()
{
var userlogedin = Driver.Instance.FindElement(By.ClassName("username"));
var selectelement = new SelectElement(userlogedin);
selectelement.SelectByText("JonPark2");
}
Upon executing this code, I encounter the error message:
OpenQa.Selenium.Support.UI.unexpectedTagNameException: Element should have been select but was div.
The provided HTML snippet offers further insight into the element I am trying to target:
<div class="content-wrapper">
<div class="float-left">
<div class="float-right">
<section id="login">
<p>
<a title="Manage your account" class="username" href="Account/Manage">
Text - Empty Text Node
<span class="username">
Text - JonPark2
Would appreciate any guidance or suggestions on what might be causing this issue?