How to Get and Set TextBox Value from form using Selenium C#

时间:2016-04-15 11:04:27

标签: c# selenium

I am getting text box value but its not getting here is my form code.

@using (Html.BeginForm(new { id = "RegistrationForm" })){<div class="PageContent" style="margin-left: 10px; float: left; color: #656565; font-weight: bold">
    <table border="0" cellpadding="0" cellspacing="0" width="800px">
        <tr height="15px">
            <td>
            </td>
        </tr>
        <tr>
            <td width="700px">
                <table border="0" cellpadding="0" cellspacing="0" style="width: 700px" class="PageContent">
                    <tr>
                        <td width="10px">
                        </td>
                        <td width="60px">
                        </td>
                        <td width="5px">
                        </td>
                        </tr>
                         <tr>

                        <td>
                            <input type="hidden" id="upStudentID" name="upStudentID" value="@ViewBag.StudentID" />
                        </td>
                        <td>@Html.LabelFor(m => m.vFirstName) <span class="required" style="color:red">*</span>
                        </td>
                        <td>
                        </td>
                        <td>@Html.TextBoxFor(m => m.vFirstName, new { @maxlength = 30, @class = "mandatory commonControls", @TabIndex = 1 })
                       </td>

                          <td>
                        </td>
                        <td>@Html.LabelFor(m => m.vLastName)
                        </td>
                        <td>
                        </td>
                        <td>@Html.TextBoxFor(m => m.vLastName, new { maxlength = 30, @class = "commonControls", @TabIndex = 7 })
                        </td>

                    </tr>
                    </table> 
                    </td>
                    </tr>
                    </table>
                    </div>}

and here is selenium code which i am using to get and set text box values

var FirstNameKey = driver.FindElement(By.CssSelector("#vFirstName"));

i also tried -

var FirstNameKey = driver.FindElement(By.Id("vFirstName"));

Help Required.

0 个答案:

没有答案