I want to get an email string out of an email textbox which was recently entered.
I'm doing automation tests with selenium and to confirm that the correct string was entered into the textbox, I want to recheck it before it goes on to the password textbox.
I saw a lot of examples here but the most are either getText();
(which seems to not work anymore) or getAttribute("Value");
.
I debugged it, and the checkText
gives always Null.
What im currently having is this code:
public static void SendKeysElement(IWebDriver webDriver)
{
IWebElement Field = webDriver.FindElement(By.XPath(selector));
Field.SendKeys("[email protected]");
string checkText = Field.GetAttribute("Value");
if (checkText != "[email protected]")
{
Console.WriteLine("String is wrong");
}
else
{
ConsoleWriteLine("String is correct");
}
}
Here is the inspect of that textbox, while the email string was entered. The first thing I notice is, that the entered string in the email textbox is not displayed in the inspect.
The webpage is being written with .NET using a blazor template.
CodePudding user response:
Instead of
.GetAttribute("Value")
try this :
.GetAttribute("value");
Note that, attribute type is case sensitive.