Skip to content

sendKeys() fails with start > length() #142

@php-coder

Description

@php-coder

sendKeys() method fails with StringIndexOutOfBoundsException: start > length():

java.lang.RuntimeException: 
	at org.robotframework.javalib.library.AnnotationLibrary.retrieveInnerException(AnnotationLibrary.java:148)
	at org.robotframework.javalib.library.AnnotationLibrary.runKeyword(AnnotationLibrary.java:130)
	at robot.model.testcase$py.visit$7(C:\Users\hifi\git\robotframework\build\Lib\robot\model\testcase.py:74)
	at robot.model.testcase$py.call_function(C:\Users\hifi\git\robotframework\build\Lib\robot\model\testcase.py)
	at robot.model.itemlist$py.visit$11(C:\Users\hifi\git\robotframework\build\Lib\robot\model\itemlist.py:71)
	at robot.model.itemlist$py.call_function(C:\Users\hifi\git\robotframework\build\Lib\robot\model\itemlist.py)
	at robot.model.visitor$py.visit_suite$2(C:\Users\hifi\git\robotframework\build\Lib\robot\model\visitor.py:88)
	at robot.model.visitor$py.call_function(C:\Users\hifi\git\robotframework\build\Lib\robot\model\visitor.py)
	at robot.model.testsuite$py.visit$19(C:\Users\hifi\git\robotframework\build\Lib\robot\model\testsuite.py:168)
	at robot.model.testsuite$py.call_function(C:\Users\hifi\git\robotframework\build\Lib\robot\model\testsuite.py)
	at robot.model.itemlist$py.visit$11(C:\Users\hifi\git\robotframework\build\Lib\robot\model\itemlist.py:71)
	at robot.model.itemlist$py.call_function(C:\Users\hifi\git\robotframework\build\Lib\robot\model\itemlist.py)
	at robot.model.visitor$py.visit_suite$2(C:\Users\hifi\git\robotframework\build\Lib\robot\model\visitor.py:88)
	at robot.model.visitor$py.call_function(C:\Users\hifi\git\robotframework\build\Lib\robot\model\visitor.py)
	at robot.model.testsuite$py.visit$19(C:\Users\hifi\git\robotframework\build\Lib\robot\model\testsuite.py:168)
	at robot.model.testsuite$py.call_function(C:\Users\hifi\git\robotframework\build\Lib\robot\model\testsuite.py)
	at robot.model.itemlist$py.visit$11(C:\Users\hifi\git\robotframework\build\Lib\robot\model\itemlist.py:71)
	at robot.model.itemlist$py.call_function(C:\Users\hifi\git\robotframework\build\Lib\robot\model\itemlist.py)
	at robot.model.visitor$py.visit_suite$2(C:\Users\hifi\git\robotframework\build\Lib\robot\model\visitor.py:88)
	at robot.model.visitor$py.call_function(C:\Users\hifi\git\robotframework\build\Lib\robot\model\visitor.py)
	at robot.model.testsuite$py.visit$19(C:\Users\hifi\git\robotframework\build\Lib\robot\model\testsuite.py:168)
	at robot.model.testsuite$py.call_function(C:\Users\hifi\git\robotframework\build\Lib\robot\model\testsuite.py)
	at robot.model.itemlist$py.visit$11(C:\Users\hifi\git\robotframework\build\Lib\robot\model\itemlist.py:71)
	at robot.model.itemlist$py.call_function(C:\Users\hifi\git\robotframework\build\Lib\robot\model\itemlist.py)
	at robot.model.visitor$py.visit_suite$2(C:\Users\hifi\git\robotframework\build\Lib\robot\model\visitor.py:88)
	at robot.model.visitor$py.call_function(C:\Users\hifi\git\robotframework\build\Lib\robot\model\visitor.py)
	at robot.model.testsuite$py.visit$19(C:\Users\hifi\git\robotframework\build\Lib\robot\model\testsuite.py:168)
	at robot.model.testsuite$py.call_function(C:\Users\hifi\git\robotframework\build\Lib\robot\model\testsuite.py)
	at robot.model.itemlist$py.visit$11(C:\Users\hifi\git\robotframework\build\Lib\robot\model\itemlist.py:71)
	at robot.model.itemlist$py.call_function(C:\Users\hifi\git\robotframework\build\Lib\robot\model\itemlist.py)
	at robot.model.visitor$py.visit_suite$2(C:\Users\hifi\git\robotframework\build\Lib\robot\model\visitor.py:88)
	at robot.model.visitor$py.call_function(C:\Users\hifi\git\robotframework\build\Lib\robot\model\visitor.py)
	at robot.model.testsuite$py.visit$19(C:\Users\hifi\git\robotframework\build\Lib\robot\model\testsuite.py:168)
	at robot.model.testsuite$py.call_function(C:\Users\hifi\git\robotframework\build\Lib\robot\model\testsuite.py)
	at robot.run$py.main$3(C:\Users\hifi\git\robotframework\build\Lib\robot\run.py:448)
	at robot.run$py.call_function(C:\Users\hifi\git\robotframework\build\Lib\robot\run.py)
	at robot.utils.application$py._execute$10(C:\Users\hifi\git\robotframework\build\Lib\robot\utils\application.py:94)
	at robot.utils.application$py.call_function(C:\Users\hifi\git\robotframework\build\Lib\robot\utils\application.py)
	at robot.utils.application$py.execute_cli$5(C:\Users\hifi\git\robotframework\build\Lib\robot\utils\application.py:49)
	at robot.utils.application$py.call_function(C:\Users\hifi\git\robotframework\build\Lib\robot\utils\application.py)
	at robot.run$py.run_cli$7(C:\Users\hifi\git\robotframework\build\Lib\robot\run.py:488)
	at robot.run$py.call_function(C:\Users\hifi\git\robotframework\build\Lib\robot\run.py)
	at robot.jarrunner$py._run$3(C:\Users\hifi\git\robotframework\build\Lib\robot\jarrunner.py:64)
	at robot.jarrunner$py.call_function(C:\Users\hifi\git\robotframework\build\Lib\robot\jarrunner.py)
	at robot.jarrunner$py.run$2(C:\Users\hifi\git\robotframework\build\Lib\robot\jarrunner.py:57)
	at robot.jarrunner$py.call_function(C:\Users\hifi\git\robotframework\build\Lib\robot\jarrunner.py)
	at org.robotframework.RobotRunner.run(RobotRunner.java:74)
	at org.robotframework.RobotFramework.run(RobotFramework.java:61)
	at org.robotframework.mavenplugin.AcceptanceTestMojo.executeRobot(AcceptanceTestMojo.java:73)
	at org.robotframework.mavenplugin.AcceptanceTestMojo.subclassExecute(AcceptanceTestMojo.java:68)
	at org.robotframework.mavenplugin.AbstractMojoWithLoadedClasspath.execute(AbstractMojoWithLoadedClasspath.java:53)
	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:210)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:156)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
	at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56)
	at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
	at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
	at org.apache.maven.cli.MavenCli.execute(MavenCli.java:956)
	at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
	at org.apache.maven.cli.MavenCli.main(MavenCli.java:192)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:282)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225)
	at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:406)
	at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347)
	at org.apache.maven.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:39)
	at org.apache.maven.wrapper.WrapperExecutor.execute(WrapperExecutor.java:122)
	at org.apache.maven.wrapper.MavenWrapperMain.main(MavenWrapperMain.java:61)
Caused by: java.lang.StringIndexOutOfBoundsException: start > length()
	at java.lang.AbstractStringBuilder.replace(AbstractStringBuilder.java:853)
	at java.lang.StringBuilder.replace(StringBuilder.java:262)
	at com.gargoylesoftware.htmlunit.html.DoTypeProcessor.add(DoTypeProcessor.java:138)
	at com.gargoylesoftware.htmlunit.html.DoTypeProcessor.doType(DoTypeProcessor.java:123)
	at com.gargoylesoftware.htmlunit.html.HtmlUrlInput.doType(HtmlUrlInput.java:138)
	at com.gargoylesoftware.htmlunit.html.HtmlElement.type(HtmlElement.java:551)
	at com.gargoylesoftware.htmlunit.html.HtmlElement.type(HtmlElement.java:648)
	at org.openqa.selenium.htmlunit.HtmlUnitKeyboard.sendKeys(HtmlUnitKeyboard.java:89)
	at org.openqa.selenium.htmlunit.HtmlUnitKeyboard.sendKeys(HtmlUnitKeyboard.java:58)
	at org.openqa.selenium.htmlunit.HtmlUnitDriver.lambda$sendKeys$7(HtmlUnitDriver.java:487)
	at org.openqa.selenium.htmlunit.HtmlUnitDriver.lambda$runAsync$0(HtmlUnitDriver.java:438)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)

It happens with <input type="url"> in my case. It only reproducible when another test typed a value into this field and submitted a form. But as the form is React component, it seems like htmlunit holds some state between tests and it doesn't invalidate it because a form is submitted by JavaScript code.

Verisons:

  • htmlunit 2.37.0
  • htmlunit-driver 2.37.0
  • selenium 3.141.59

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions