具体取决于页面中的用户更改从具有下拉菜单的字段更改为没有下拉菜单的字段,并且我希望我的程序在下拉菜单不可用时忽略该字段。我现在拥有的是(customCoverageCell以Excel中的单元格为目标)
Select dropDown = new Select(driver.findElement(By.xpath("//*[contains(text(), '"+ customCoverageCell +"')]/following::select")));
if((!customValueCell.equals("") && !driver.findElements(By.xpath("//*[contains(text(), '"+ customCoverageCell +"')]/following::select")).isEmpty())){
dropDown.selectByValue(customValueCell);
}
但会尝试更改下拉菜单。 我试过这个
Select dropDown = new Select(driver.findElement(By.xpath("//*[contains(text(), '"+ customCoverageCell +"')]/following::select")));
if((!customValueCell.equals("") && driver.findElements(By.xpath("//*[contains(text(), '"+ customCoverageCell +"')]/following::select")).isEnabled())){//also tried isDisplayed and isSelected just to see if it actually would do anything
dropDown.selectByValue(customValueCell);
}
如果不确保excel中的值为空,我怎么能不尝试输入值?
以下是有问题的HTML: 没有下降
<div class="wrap-padding-sm">
<div class="threeCols">
<div class="colContent">
<div class="sub-colContent">
<span class="checkmark-grey">
</span>
<span class="checkTitle">Third Party (THIS IS WHERE I NEED TO TARGET AND WORK FROM)
</span>
</div>
<div class="sub-colContent">Limit:
<span class="amount-midCol">$$$$$$$$$$$$
</span>
</div><span class="scroogeMsg h7 mobile-show">Some text</span>
</div>
<div class="colContent">
<a data-toggle="collapse" class="margin-R10" data-target="#cust_standard_scrooge_0">
<span>What this covers
</span>
</a>
<a data-toggle="collapse" data-target="#cust_standard_scrooge_0" class="btn-accordian collapsed"> </a>
</div>
</div>
<div id="cust_standard_scrooge_0" class="scrooge-wrap collapse">
<p>Some text
</p>
</div><span class="scroogeMsg h7 mobile-hide">Some text</span>
</div>
&#13;
WITH DROP DOWN
<div class="wrap-padding-sm">
<div class="threeCols">
<div class="colContent">
<div class="sub-colContent">
<span class="checkmark-grey">
</span>
<span class="checkTitle">Third Party (THIS IS WHERE I NEED TO TARGET AND WORK FROM)
</span>
<span class="checkTitle_sub">Some text
</span>
</div>
<div class="sub-colContent">
<div class="select-dropWrap">
<div id="h_abc194" class="form-group form-group-lg "><label for="changeScrooge:h_abc161:0:h_abc194:select-one-menu" class="control-label">Limit: </label>
<div class="select-dropMenu ">
<div class="selector uniform-select fixedWidth" id="uniform-changeScrooges:h_abc161:0:h_abc194:select-one-menu"><span style="user-select: none;">1000000</span><select id="changeScrooges:h_abc161:0:h_abc194:select-one-menu" name="changeScrooges:h_abc161:0:h_abc194:select-one-menu" class="form-control input-lg " size="1" onchange="mojarra.ab(this,event,'valueChange','changeScrooges:custom_standard_scrooges','changeScrooges:custom_standard_scrooges changeScrooges:customAcceptDeclinePNL',{'onevent':recommendedScroogeAfterAJAX})">
<option value="1000000" selected="selected">1000000</option>
<option value="2000000">2000000</option>
</select></div>
</div>
</div>
</div>
</div><span class="scroogeMsg h7 mobile-show">Some text</span>
</div>
<div class="colContent">
<a data-toggle="collapse" class="margin-R10" data-target="#cust_standard_scrooge_0">
<span>What text?
</span>
</a>
<a data-toggle="collapse" data-target="#cust_standard_scrooge_0" class="btn-accordian collapsed"> </a>
</div>
</div>
<div id="cust_standard_scrooge_0" class="scrooge-wrap collapse">
<p>Some text
</p>
</div><span class="scroogeMsg h7 mobile-hide">Sme text</span>
</div>
&#13;
答案 0 :(得分:0)
这是我一直用来找到元素存在的小技巧。
def files = new java.io.File("").listFiles().map(_.getAbsolutePath).to[scala.collection.immutable.Iterable]
Source(files).flatMapConcat( filename => //you could use flatMapMerge if you don't bother about line ordering
FileIO.fromPath(Paths.get(filename))
.via(Framing.delimiter(ByteString("\n"), 256, allowTruncation = true).map(_.utf8String))
).map { csvLine =>
// parse csv here
println(csvLine)
}
希望这会对你有所帮助。感谢。