【发布时间】:2016-03-18 07:54:57
【问题描述】:
以下代码一周前可以工作,但现在我收到错误:
org.openqa.selenium.support.ui.UnexpectedTagNameException: 元素应该是“选择”但是“输入”
请帮忙。
public analyticsLandingPage verifyReportingProfile() throws InterruptedException{
Select select = new Select(driver.findElement(By.xpath(".//* [@id='reporting_profile_id']")));
select.selectByVisibleText("Arria");
Thread.sleep(1000L);
//reporting_profile.findElement(By.xpath(//[@id='s2id_reporting_profile_id']/a")).isDisplayed();
//reporting_profile.sendKeys("Arria");
//reporting_profile.sendKeys(Keys.TAB);
reporting_profile.isDisplayed();
页面 HTML:
<div class="form-group">
<label class="col-sm-2 control-label" for="reporting_profile_id">Reporting profile</label>
<div class="col-sm-10">
<div id="s2id_reporting_profile_id" class="select2-container select2-allowclear reporting_profile" style="width: 50%;">
<a class="select2-choice" tabindex="-1" href="javascript:void(0)">
<span id="select2-chosen-7" class="select2-chosen">Agency B - No Adwords Cost or Conversions</span>
<abbr class="select2-search-choice-close"></abbr>
<span class="select2-arrow" role="presentation">
</a>
<label class="select2-offscreen" for="s2id_autogen7">Reporting profile</label>
<input id="s2id_autogen7" class="select2-focusser select2-offscreen" type="text" role="button" aria-haspopup="true" aria-labelledby="select2-chosen-7">
</div>
<input id="reporting_profile_id" class="reporting_profile"
type="hidden" name="reporting_profile_id" tabindex="-1
title="Reporting profile" style="display: none;" value="12">
</div>
</div>
【问题讨论】:
-
没有类似的数据:- 您尝试使用代码搜索的 HTML 中的 Arria
-
没有id为“reporting_profile_id”的选择元素