无法在下拉列表中选择一个值,当您不放置隐式等待时,将弹出不可交互的元素,如果您将其放置,则会弹出此错误消息
预期条件失败:等待元素的可见性
尝试了类似文本框的方法,您可以在其中选择,单击,然后输入文本,然后尝试选择语句
Select fruits = new Select(driver.findElement(By.xpath("//*[@id=\"drop-down-list-department\"]")));
fruits.selectByValue("2");
fruits.selectByIndex(2);
}
HTML
<div class="content-splitter advance-contents">
<table id="advance-table">
<tbody><tr>
<td colspan="3" style="text-align: left" valign="center">
<input type="checkbox" id="check-status">
<label for="check-status">Active 可交易</label>
<input type="checkbox" id="check-vat">
<label for="check-vat">12% VAT 税</label>
<input type="checkbox" id="check-senior-5">
<label for="check-senior-5">Senior / PWD 5% 年长优惠/残疾人5%</label>
<input type="checkbox" id="check-senior-20">
<label for="check-senior-20">Senior / PWD 20% 年长优惠/残疾人20%</label>
<input type="checkbox" id="check-in-stock">
<label for="check-in-stock">Discontinue In-Stock 货商断货</label>
</td>
</tr>
<tr>
<td style="height: 10px"></td>
</tr>
<tr>
<td class="advance-input-label">Chinese Name 中文名称:</td>
<td class="advance-input-table">
<input type="text" id="text-chinese-name" class="text-input-advance" maxlength="200">
</td>
<td rowspan="10">
<div id="upload-div">
<form id="upload-file-form" method="post" enctype="multipart/form-data" action="">
<input type="hidden" name="wid" value="100000000003088">
<input type="file" name="photoImage" id="input-upload-file" accept=".jpg, .jpeg, .png, .gif">
</form>
<input type="button" class="bttn-imp-create upload-button" value="+ Upload your image 上传照片" onclick="openfileUpload()">
<table id="upload-image-thumbnail-holder">
<tbody><tr>
<td>
<img id="upload-image-thumbnail" src="images/no_image.png">
</td>
</tr>
</tbody></table>
</div>
<div id="upload-div-buttons">
<table>
<tbody><tr>
<td align="left">
<input type="button" class="bttn-imp-create select-another-image-button" value="Upload your image 上传照片" onclick="openfileUpload()">
</td>
<td align="right">
<input type="button" class="bttn-negative remove-image-button" value="Remove 删除">
</td>
</tr>
</tbody></table>
</div>
</td>
</tr>
<tr>
<td class="advance-input-label"> Client Barcode 包装条码:</td>
<td class="advance-input-table">
<input type="text" id="text-client-barcode-1" class="text-input-half" maxlength="20">
<input type="text" id="text-client-barcode-2" class="text-input-half" maxlength="20">
</td>
</tr>
<tr>
<td class="advance-input-label"> Supplier SKU 代码:</td>
<td class="advance-input-table">
<input type="text" id="text-supplier-sku" class="text-input-advance" maxlength="20">
</td>
</tr>
<tr>
<td class="advance-input-label">Description 说明:</td>
<td class="advance-input-table">
<textarea class="text-input-advance" id="text-description" maxlength="1000"></textarea>
</td>
</tr>
<tr>
<td class="advance-input-label">Department 品种:</td>
<td class="advance-input-table">
<select id="drop-down-list-department" class="search-input-bar chzn-done" style="display: none;">
<option value="1">none</option><option value="2">Novelty</option><option value="100000000000024">代购</option><option value="100000000000017">休闲食品</option><option value="100000000000020">冻品</option><option value="100000000000019">厨房用品</option><option value="100000000000004">啤酒</option><option value="100000000000013">桶装面</option><option value="100000000000022">水果</option><option value="100000000000002">洋酒</option><option value="100000000000015">洗发水+沐浴乳</option><option value="100000000000009">火腿肠</option><option value="100000000000001">烟</option><option value="100000000000006">牛奶</option><option value="100000000000021">生活用品</option><option value="100000000000005">白酒</option><option value="100000000000007">糖果</option><option value="100000000000003">红酒</option><option value="100000000000014">自煮火锅</option><option value="100000000000023">药品</option><option value="100000000000012">袋装面</option><option value="100000000000018">面包</option><option value="100000000000016">饮料</option><option value="100000000000008">饼干</option><option value="100000000000011">鸡鸭爪+鸭翅+腿</option> </select><div id="drop_down_list_department_chzn" class="chzn-container chzn-container-single" style="width: 307.979166px;"><a href="javascript:void(0)" class="chzn-single" tabindex="-1"><span>none</span><div><b></b></div></a><div class="chzn-drop" style="left: -9000px; width: 306px; top: 0px;"><div class="chzn-search"><input type="text" autocomplete="off" style="width: 271.021px;"></div><ul class="chzn-results"><li id="drop_down_list_department_chzn_o_0" class="active-result result-selected" style="">none</li><li id="drop_down_list_department_chzn_o_1" class="active-result" style="">Novelty</li><li id="drop_down_list_department_chzn_o_2" class="active-result" style="">代购</li><li id="drop_down_list_department_chzn_o_3" class="active-result" style="">休闲食品</li><li id="drop_down_list_department_chzn_o_4" class="active-result" style="">冻品</li><li id="drop_down_list_department_chzn_o_5" class="active-result" style="">厨房用品</li><li id="drop_down_list_department_chzn_o_6" class="active-result" style="">啤酒</li><li id="drop_down_list_department_chzn_o_7" class="active-result" style="">桶装面</li><li id="drop_down_list_department_chzn_o_8" class="active-result" style="">水果</li><li id="drop_down_list_department_chzn_o_9" class="active-result" style="">洋酒</li><li id="drop_down_list_department_chzn_o_10" class="active-result" style="">洗发水+沐浴乳</li><li id="drop_down_list_department_chzn_o_11" class="active-result" style="">火腿肠</li><li id="drop_down_list_department_chzn_o_12" class="active-result" style="">烟</li><li id="drop_down_list_department_chzn_o_13" class="active-result" style="">牛奶</li><li id="drop_down_list_department_chzn_o_14" class="active-result" style="">生活用品</li><li id="drop_down_list_department_chzn_o_15" class="active-result" style="">白酒</li><li id="drop_down_list_department_chzn_o_16" class="active-result" style="">糖果</li><li id="drop_down_list_department_chzn_o_17" class="active-result" style="">红酒</li><li id="drop_down_list_department_chzn_o_18" class="active-result" style="">自煮火锅</li><li id="drop_down_list_department_chzn_o_19" class="active-result" style="">药品</li><li id="drop_down_list_department_chzn_o_20" class="active-result" style="">袋装面</li><li id="drop_down_list_department_chzn_o_21" class="active-result" style="">面包</li><li id="drop_down_list_department_chzn_o_22" class="active-result" style="">饮料</li><li id="drop_down_list_department_chzn_o_23" class="active-result" style="">饼干</li><li id="drop_down_list_department_chzn_o_24" class="active-result" style="">鸡鸭爪+鸭翅+腿</li></ul></div></div>
</td>
</tr>
<tr>
<td class="advance-input-label">Category 种类:</td>
<td class="advance-input-table">
<select id="drop-down-list-category" class="search-input-bar chzn-done" style="display: none;"><option value="1" selected="selected">none</option></select><div id="drop_down_list_category_chzn" class="chzn-container chzn-container-single" style="width: 307.979166px;"><a href="javascript:void(0)" class="chzn-single" tabindex="-1"><span>none</span><div><b></b></div></a><div class="chzn-drop" style="left: -9000px; width: 306px; top: 0px;"><div class="chzn-search"><input type="text" autocomplete="off" style="width: 271.021px;"></div><ul class="chzn-results"><li id="drop_down_list_category_chzn_o_0" class="active-result result-selected" style="">none</li></ul></div></div>
</td>
</tr>
<tr>
<td class="advance-input-label">Brand 品牌:</td>
<td class="advance-input-table">
<select id="drop-down-list-branch-id" class="search-input-bar chzn-done" style="display: none;">
<option value="1">none</option> </select><div id="drop_down_list_branch_id_chzn" class="chzn-container chzn-container-single" style="width: 307.979166px;"><a href="javascript:void(0)" class="chzn-single" tabindex="-1"><span>none</span><div><b></b></div></a><div class="chzn-drop" style="left: -9000px; width: 306px; top: 0px;"><div class="chzn-search"><input type="text" autocomplete="off" style="width: 271.021px;"></div><ul class="chzn-results"><li id="drop_down_list_branch_id_chzn_o_0" class="active-result result-selected" style="">none</li></ul></div></div>
</td>
</tr>
<tr>
<td class="advance-input-label"> Big Qty 大单位:</td>
<td class="advance-input-table">
<input type="text" id="text-big-quantity" placeholder="Numbers only" class="text-input" maxlength="20">
</td>
</tr>
<tr>
<td></td>
<td>
<input type="checkbox" id="check-sold-in-package">
<span>Product Sold in Package 产品以包装出售</span>
</td>
</tr>
<tr>
<td></td>
</tr>
</tbody></table>
</div>
我希望应该可以选择一个下拉值
答案 0 :(得分:0)
尝试此代码:
$invoice_id = $this->input->post('id');
$desc = $this->input->post('desc[]');
$size = $this->input->post('size[]');
$stock = $this->input->post('stock[]');
$color = $this->input->post('color[]');
$qty = $this->input->post('qty[]');
$price = $this->input->post('price[]');
$linetotal = $this->input->post('linetotal[]');
$invoice_id = $this->input->post('id');
$input_data = array();
for ($i = 0; $i < count($desc); $i++ )
{
$input_data[] = array(
'desc' => $desc[$i],
'size' => $size[$i],
'stock' => $stock[$i],
'color' => $color[$i],
'qty' => $qty[$i],
'price' => $price[$i],
'linetotal' => $linetotal[$i],
);
}
$this->db->where('invoice_id', $invoice_id);
$this->db->update_batch('invoice_data',$input_data, 'invoice_id');
$this->session->set_flashdata('success', 'Data added successfully.');
redirect('invoices');
您也可以使用此方法:
new WebDriverWait(driver, 10).until(ExpectedConditions.elementToBeClickable(By.xpath("//*[@class='advance-input-table' and ./preceding-sibling::*[contains(text(),'Department')]]")));
WebElement department = driver.findElement(By.xpath("//*[@class='advance-input-table' and ./preceding-sibling::*[contains(text(),'Department')]]"));
Actions act = new Actions(driver);
act.moveToElement(department).build().perform();
Thread.sleep(1000);
act.moveToElement(department).click().build().perform();
Thread.sleep(1000);
WebElement dropdown = driver.findElement(By.id("drop-down-list-department"));
//update here
dropdown.submit();
Select fruits = new Select(dropdown);
act.moveToElement(dropdown).click().build().perform();
Thread.sleep(1000);
fruits.selectByValue("2");
答案 1 :(得分:0)
Java
WebElement categorie=driver.findElement(By.xpath("//*[@id=\"gh-cat-box\"]"));
categorie.click();
Select dropdown=new Select(categorie);
dropdown.selectByVisibleText("Art");
Thread.sleep(5000);