Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/google-chrome/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 测试用例在chrome中失败_Javascript_Google Chrome_Selenium - Fatal编程技术网

Javascript 测试用例在chrome中失败

Javascript 测试用例在chrome中失败,javascript,google-chrome,selenium,Javascript,Google Chrome,Selenium,嗨,我正试图在chrome浏览器中运行一个测试用例,该测试用例在firefox中通过,但在chrome浏览器中失败了 .这是selenium代码 _driver.findElement(By.linkText("Expence_Link")).click();; _driver.findElement(By.id("searchButton")).click(); _driver.findElement(By.id("descriptionInput")).sendKeys("Descripti

嗨,我正试图在chrome浏览器中运行一个测试用例,该测试用例在firefox中通过,但在chrome浏览器中失败了 .这是selenium代码

_driver.findElement(By.linkText("Expence_Link")).click();;
_driver.findElement(By.id("searchButton")).click();
_driver.findElement(By.id("descriptionInput")).sendKeys("Description");
_driver.findElement(By.id("saveAndNextExpenseButton")).click();
这是html代码

<input id="searchButton" class="formSubmit" type="button" value="Search" tabindex="3">
<a href="https://xyz/Collaborate?pbId=77501&sB=yat93&op=AddProjectBudgetActualExpense">Expence_Link</a>
<input id="descriptionInput" name="pre.projectBudgetActualExpense.description.value" value="" size="30" style="width:300px" tabindex="4" maxlength="665">
<input id="saveAndNextExpenseButton" class="formSubmit" type="button" onclick="onSaveAndNextExpenseButtonClick(); return false;" value="Save & Next Actual" tabindex="13">
我无法将密钥发送到id为“descriptionInput”的文本框中,我尝试了使用name、xpath、cssSelector,但没有任何功能。点击expence链接和搜索按钮在chrome中运行良好

请帮我摆脱这个问题 提前感谢

尝试使用下面的方法等待字段的可见性,然后向其发送值:

//Waiting for 10 seconds for the presence of the description field and then entering text 'Description'
try{
    WebElement input_desc = new WebDriverWait(_driver,10).until(ExpectedConditions.visibilityOfElementLocated(By.id("descriptionInput")));
    input_desc.clear();
    input_desc.sendKeys("Description");
}catch(Throwable e){
    System.err.println("Description field wasn't found. "+e.getMessage());
}
或者将时间增加到10秒:

_driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

您得到的是什么错误/异常?它在哪个findElement语句上失败?您得到的是哪个元素的NoSuchElementException?请添加完整的stacktrace。@Subh它没有显示这样的内容element@user3819070例如我看得出来。但是,请添加显示该异常的元素。您必须在控制台中获取Stacktrace。。请加上这个。因为仅仅声明部分异常不会帮助我们跟踪代码中的问题。
_driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);