当我将数据插入第二个文本框中时,插入到第一个文本框中的所有数据都会被清除

时间:2018-07-04 09:46:40

标签: html selenium selenium-webdriver xpath css-selectors

下面的代码使文本框为空白。一旦控件进入第二个文本框,第一个文本框将为空白。

{
    WebDriverWait wait34 = new WebDriverWait(d, 30);
    WebElement element34 = wait34.until(ExpectedConditions.elementToBeClickable(By.id("fisnInstrTypeDescriptionLabel")));
    element34.sendKeys(e.getCellData("ISIN", 19, i));

    WebDriverWait wait35 = new WebDriverWait(d, 30);
        WebElement element35 = wait35.until(ExpectedConditions.elementToBeClickable(By.id("fisnRestrictionsLabel")));
    element35.sendKeys(e.getCellData("ISIN", 20, i)); 

    d.findElement(By.xpath("//input[@onclick='return submit_FISN();']")).click();
}

两个元素的HTML代码

<input type="text" name="fisnInstrTypeDescriptionLabel" size="70" value="" onblur="setFISNComponent('fisnInstrTypeDescription');" id="fisnInstrTypeDescriptionLabel" style="text-align: right" class="textField ui-autocomplete-input" autocomplete="off">

<input type="text" name="fisnRestrictionsLabel" size="70" value="" onblur="setFISNComponent('fisnRestrictions');" id="fisnRestrictionsLabel" style="text-align: right" class="textField ui-autocomplete-input" autocomplete="off">

1 个答案:

答案 0 :(得分:0)

尝试:

{
WebDriverWait wait34 = new WebDriverWait(d, 30);
WebElement element34 = wait34.until(ExpectedConditions.elementToBeClickable(By.id("fisnInstrTypeDescriptionLabel")));  
element34.clear();
element34.click();
element34.sendKeys(e.getCellData("ISIN", 19, i));


WebElement element35 = wait35.until(ExpectedConditions.elementToBeClickable(By.id("fisnRestrictionsLabel"))); 
element35.clear();
element35.click();
element35.sendKeys(e.getCellData("ISIN", 20, i)); 



d.findElement(By.xpath("//input[@onclick='return submit_FISN();']")).click();
}