У меня есть пользовательский элемент управления UserInfo
на странице. В пользовательском элементе управления есть выпадающий список с именем cbType
. Как получить доступ к этому списку, чтобы проверить его, если я использую селен? Я не могу получить элемент, используя идентификатор. FindElement
возвращает ошибку null / timeout.
Ниже мой код:
[TestMethod]
public void Test_GoToAddDepositPage()
{
IWebElement el = driver.FindElement(By.Id("ctl00_MainContent_ucDepositMasterInput_rcbAccountNo_Input"));
el.SendKeys("Big"")
}
Это страница, на которой я запускаю тест:
<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="TenantDepositMasterInput.aspx.cs" Inherits="UnionEnergy.Web.DepositModule.TenantDepositMasterInput" %>
<%@ Register Src="~/Control/DepositModule/ucDepositMasterInput.ascx" TagPrefix="uc1" TagName="ucDepositMasterInput" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
<link href="../Content/style/management.css" rel="stylesheet" />
<link href="../Content/style/inputform.css" rel="stylesheet" />
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<telerik:RadCodeBlock ID="codeBlock1" runat="server">
<script type="text/javascript">
function closeWindow() {
window.close();
}
</script>
<style>
.input {
min-width: 250px;
padding-right: 20px;
}
</style>
</telerik:RadCodeBlock>
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
<%--<ClientEvents OnRequestStart="requestStart" OnResponseEnd="responseEnd" />--%>
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="ucDepositMasterInput">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="ucDepositMasterInput" />
<telerik:AjaxUpdatedControl ControlID="lblMessage" UpdatePanelCssClass="errMsg" />
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
</telerik:RadAjaxManager>
<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server">
</telerik:RadAjaxLoadingPanel>
<div id="mainDiv" class="custMgmntMainDiv">
<h2>Add Deposit Request</h2>
<asp:Label ID="lblMessage" runat="server"></asp:Label>
<div class="fullWidthCell" style="background-color: beige;">
<div class="cellHorizontal">
<uc1:ucDepositMasterInput runat="server" ID="ucDepositMasterInput" ValidationGroup="Validation" />
</div>
<div class="cellHorizontal">
</div>
</div>
<div class="fullWidthCell boxSizing" style="background-color: rgb(255,255,225); padding: 10px 30px;">
<asp:ValidationSummary ID="ValidationSummary1" runat="server" ValidationGroup="Validation"
HeaderText='Please correct the following error before proceed:'
ForeColor="Red" />
</div>
<div class="fullWidthCell boxSizing" style="height:22%; background-color: #dddddd; padding: 10px 30px; padding-bottom: 50px;">
<div class="cellHorizontal">
<div class="cell">
<telerik:RadButton ID="rbSave" runat="server" Width="120px" Text="Save"
OnClick="rbSave_Click"
SingleClick="true" SingleClickText="Submitting..."
ValidationGroup="Validation"></telerik:RadButton>
</div>
<div class="cell">
<telerik:RadButton ID="rbClose" runat="server" Width="120px" Text="Close" OnClientClicked="closeWindow"></telerik:RadButton>
</div>
</div>
</div>
</div>
</asp:Content>
Элемент управления пользователя:
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ucDepositMasterInput.ascx.cs" Inherits="UnionEnergy.Web.Control.DepositModule.ucDepositMasterInput" %>
<div style="padding: 5px 5px 5px 5px;">
<div class="fullWidthCell">
<div class="cellHorizontal">
<div class="cell label">Customer Name</div>
<div class="cell separator">:</div>
<div class="cell input">
<asp:Label ID="lbCustomerName" runat="server"></asp:Label>
</div>
</div>
</div>
<div class="fullWidthCell">
<div class="cellHorizontal">
<div class="cell label">Contract Set ID</div>
<div class="cell separator">:</div>
<div class="cell input">
<telerik:RadComboBox ID="rcbAccountNo" runat="server" Height="200px" AutoPostBack="true"
EmptyMessage="Select Account"
EnableLoadOnDemand="true"
ShowMoreResultsBox="true" ItemsPerRequest="20"
EnableVirtualScrolling="true"
OnItemsRequested="rcbAccountNo_ItemsRequested"
OnSelectedIndexChanged="rcbAccountNo_SelectedIndexChanged"
DropDownAutoWidth="Enabled"></telerik:RadComboBox>
<asp:RequiredFieldValidator ID="rfvAccountNo" runat="server"
Text="*"
ErrorMessage="Account No required. "
ControlToValidate="rcbAccountNo" InitialValue=""
ForeColor="red"
Display="Dynamic"></asp:RequiredFieldValidator>
</div>
</div>
<div class="cellHorizontal">
<div class="cell label"></div>
<div class="cell separator"></div>
<div class="cell input">
</div>
</div>
</div>
<div class="fullWidthCell">
<div class="cellHorizontal">
<div class="cell label">Deposit Type</div>
<div class="cell separator">:</div>
<div class="cell input">
<telerik:RadComboBox ID="rcbDepositType" runat="server" AutoPostBack="true"
OnSelectedIndexChanged="rcbDepositType_SelectedIndexChanged"
DropDownAutoWidth="Enabled"></telerik:RadComboBox>
<asp:RequiredFieldValidator ID="rfvDepositType" runat="server"
Text="*"
ErrorMessage="Deposit Type required. "
ControlToValidate="rcbDepositType" InitialValue="NIL"
ForeColor="red"
Display="Dynamic"></asp:RequiredFieldValidator>
</div>
</div>
<div class="cellHorizontal">
<div class="cell label"></div>
<div class="cell separator"></div>
<div class="cell input">
</div>
</div>
</div>
<div class="fullWidthCell">
<div class="cellHorizontal">
<div class="cell label">Requested Amount</div>
<div class="cell separator">:</div>
<div class="cell input">
<telerik:RadNumericTextBox ID="rntbRequested" runat="server">
<NegativeStyle Resize="None"></NegativeStyle>
<NumberFormat ZeroPattern="n" AllowRounding="False" DecimalDigits="2" GroupSeparator=""></NumberFormat>
<EmptyMessageStyle Resize="None"></EmptyMessageStyle>
<ReadOnlyStyle Resize="None"></ReadOnlyStyle>
<FocusedStyle Resize="None"></FocusedStyle>
<DisabledStyle Resize="None"></DisabledStyle>
<InvalidStyle Resize="None"></InvalidStyle>
<HoveredStyle Resize="None"></HoveredStyle>
<EnabledStyle Resize="None"></EnabledStyle>
</telerik:RadNumericTextBox>
<asp:RequiredFieldValidator ID="rfvRequested" runat="server"
Text="*"
ErrorMessage="Requested Amount required. "
ControlToValidate="rntbRequested"
ForeColor="red"
Display="Dynamic"></asp:RequiredFieldValidator>
</div>
</div>
<div class="cellHorizontal">
<div class="cell label">Payment Status</div>
<div class="cell separator">:</div>
<div class="cell input">
<telerik:RadComboBox ID="rcbPaymentStatus" runat="server" Enabled="false"
DropDownAutoWidth="Enabled"></telerik:RadComboBox>
</div>
</div>
</div>
</div>