Selenium将不需要的选项卡([\t])发送到具有验证的输入字段
我需要在一个div中填充多个值,它以前工作过,但不知怎的,当迁移到新环境时,它突然开始在代码中识别这些[\t]符号,我的页面抛出了一个错误。 每次我发送翻译后都有一个标签键,但我把它删除了 守则:Selenium将不需要的选项卡([\t])发送到具有验证的输入字段,selenium,junit,cucumber,selenium-chromedriver,Selenium,Junit,Cucumber,Selenium Chromedriver,我需要在一个div中填充多个值,它以前工作过,但不知怎的,当迁移到新环境时,它突然开始在代码中识别这些[\t]符号,我的页面抛出了一个错误。 每次我发送翻译后都有一个标签键,但我把它删除了 守则: public void setTranslationsFor(final String elementId, final String translation) throws InterruptedException { try { for (final WebElement
public void setTranslationsFor(final String elementId, final String translation) throws InterruptedException {
try {
for (final WebElement input : translationElementsOf(elementId)) {
input.clear();
input.sendKeys(textOrVariableValue(translation));
if (isExplorer()) {
((JavascriptExecutor) driver()).executeScript("$(arguments[0]).change(); return true;", input);
}
sleep();
}
} catch (final Exception e) {
makeScreenshot();
testBlocked();
throw e;
}
}
protected final List<WebElement> translationElementsOf(final String name) {
return elementsOf(name + "_translations", ".//input[starts-with(@id, '" + name + "_') and @id != '" + name + "_x-keyword']");
}
public void setTranslationsFor(final String elementId,final String translation)抛出中断异常{
试一试{
for(最终WebElement输入:translationElementsOf(elementId)){
input.clear();
输入.sendKeys(文本或变量值(翻译));
if(isExplorer()){
((JavascriptExecutor)driver()).executeScript($(参数[0]).change();返回true;”,输入);
}
睡眠();
}
}捕获(最终异常e){
makeScreenshot();
testBlocked();
投掷e;
}
}
受保护的最终列表translationElementsOf(最终字符串名称){
返回元素sof(name+“_-translations”、“//input[以(@id、“+name+”)、@id!=”“+name+“_-x-keyword”]”开头];
}
已解决
这是一个问题,我在Webdriver中的一个空白处发送了密钥,而不是密钥的值