screenshot场景是我试图将sendkeys发送到模态对话框,但是webdriver无法将焦点切换到对话框。我已经尝试了各种等待条件和切换条件而没有成功
以下是HTML代码
新
<div class="row">
<ul class="nav nav-tabs">
<li role="presentation" class="active"><a data-toggle="tab" href="#ModalAddCampaignsSearchTab">Search</a></li>
<li role="presentation"><a data-toggle="tab" href="#ModalAddCampaignsToAddTab">New ({{DealerFactory.Campaign.NumberOfCampaignsToAdd()}})</a></li>
</ul>
<div class="tab-content">
<div id="ModalAddCampaignsSearchTab" class="tab-pane fade in active">
<br/>
<div class="col-lg-12">
<label for="Select_A_Campaign">Select A Campaign</label>
<div class="form-group">
<div class="input-group">
<div class="input-group-addon">
<i class="fa fa-search" id="icoSearch"></i>
<i class="fa fa-spinner fa-pulse" id="icoSearching" style="display: none;"></i>
</div>
<input class="form-control" id="txtCampaignSearch" name="txtCampaignSearch" ng-change="findDealersToAdd()" ng-model="DealerFactory.Campaign.searchCampaigns.searchTerm" placeholder="Search" type="text" value="" />
</div>
</div>
<div id="divCampaignSearchModalResults" class="well" ng-show="DealerFactory.Campaign.searchCampaigns.campaigns.length>0" >
<div class="row">
<div class="col-lg-12 text-right">
<p>
Campaigns: {{DealerFactory.Campaign.searchCampaigns.campaigns.length}}
</p>
</div>
</div>
<div class="row">
<div class="col-lg-12">
非常感谢任何帮助/更正/建议
我想要定位的元素是id ='txtCampaignSearch'
我正在使用visual studio(IDE)&amp; webdriver
答案 0 :(得分:0)
Bootstrap is creating the modal with javascript and css,它不会创建a new window that you would have to switch between,正如您的问题所暗示的那样。
真正的问题是使用“input-group-addon”会阻止WebDriver因某种原因访问输入字段,这也是我遇到的一个问题。
等待模态动画完成是在清除和发送密钥到txtCampaignSearch之前你应该做的所有事情。
我在input-group-addon上遇到了类似的问题并解决了它using javascript。尝试这样的事情:
JavascriptExecutor js = (JavascriptExecutor)driver;
// later on...
js.executeScript("document.getElementById('txtCampaignSearch').value = 'something';");