【发布时间】:2018-11-09 14:08:00
【问题描述】:
我有一个使用 4 个不同凭据进入门户的代码,第一个失败,然后其他的一切正常。
在门户页面上,我有一个名为“cboLocales”的名称:
<form action="?action=envia" method="post" name="frmInventario">
<tr class="texto">
<td width="172" bgcolor="e6e6e6" align="center">Seleccione Locales</td>
<td width="150" bgcolor="#E6E6E6" align="center">Seleccione Formato de local</td>
<td width="157" bgcolor="#E6E6E6">Por grupo de Productos</td>
<td width="126" bgcolor="#E6E6E6">Por grupo de categoría</td>
<td width="121" rowspan="2" valign="bottom">
<input name="Submit" type="submit" class="texto" value="Ir al Reporte >>" >
</td>
</tr>
<tr class="txt8pt">
<td align="center">
<select name="cboLocales" class="texto">
<option value="">Seleccione</option>
<!--<option value="1301a">Total país</option>-->y
<option value="1302b">Solo Región Metropolitana</option>
<option value="1303c">Regiones</option>
<option value="2015">Mall</option>
</select>
</td>
</form>
在识别该选择的代码中,我有以下内容:
driver.get(Config.urlStockSB);
Select select=new Select(driver.findElement(By.name("cboLocales")));
select.selectByValue(locales.get(i)); //locales desde arreglo en config WebElement btnSubmitStock = driver.findElement(By.name("Submit"));
btnSubmitStock.click();
但是在通过select的时候,我得到一个错误,我没有找到select“cboLocales”的名称,但是它是!
如果第一个凭据失败,请尝试更改凭据的输入顺序,即使失败,请帮助,我会非常感谢!
PD:Opera 使用和 Netbeans。
【问题讨论】:
-
尝试按类
class="texto"定位元素。能否提供该页面的链接? -
我无法打开页面,因为它是私有的,但这是表单的代码......我怎么能在类名和类名中包含元素的名称选择?
-
试试这个
driver.findElement(By.xpath("//form[@name='frmInventario']/tr[@class='txt8pt']/td/select")).click();然后driver.findElement(By.xpath("//form[@name='frmInventario']/tr[@class='txt8pt']/td/select[@name='cboLocales']")).click();在这个动作之间添加一个pause(1000); -
或
Select select=new Select(driver.findElement(By.xpath("//form[@name='frmInventario']/tr[@class='txt8pt']/td/select")));然后pause(1000)然后select.selectByValue(locales.get(i)); -
org.openqa.selenium.NoSuchElementException:没有这样的元素:无法找到元素:{"method":"xpath","selector":"//form[@name='frmInventario'] /tr[@class='txt8pt']/td/select"}(会话信息:带有嵌入式 Chromium 61.0.3163.100 的 chrome)(驱动程序信息:OperaDriver=2.32 (cfa164127aab5f93e5e47d9dcf8407380eb42c50),平台=Windows NT 6.1.7601 SP1 x86_64)警告:服务器未提供任何堆栈跟踪信息)
标签: java selenium selenium-webdriver opera