Error with selenium.WebElement.sendKeys()

前端 未结 3 1515
面向向阳花
面向向阳花 2020-12-21 09:51

I am putting together a small app to perform automated checkouts on a Magento site, using Selenium WebDriver in Java. I\'m working on learning Java, so I\'m adamant on getti

相关标签:
3条回答
  • 2020-12-21 10:31

    I have had similar problems with calling sendKeys(). The problem usually is, that the signature is a var-ary, that is CharSequence... instead of just CharSequence.

    Of course this should not be a problem with Java 6. My guess would be that your maven compile uses a different compiler setting. Anyways you could change your code to

    searchField.sendKeys(new String[] { "sample" });
    

    to help diagnose the problem.

    0 讨论(0)
  • 2020-12-21 10:36

    When you are creating project make sure that you select "Use an execution environment JRE: JavaSE-1.6. You can execute test successfully with out any Sendkeys Error. 100% it will work.

    0 讨论(0)
  • 2020-12-21 10:38

    I discovered another way to work around this. I was not specifying the version of Java to compile for, so Maven was compiling for an older version. I added this to my pom.xml:

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>2.0.2</version>
        <configuration>
          <source>1.5</source>
          <target>1.5</target>
        </configuration>
      </plugin>
    

    That allows me to just a literal string "SAMPLE" in sendKeys() and it works fine.

    0 讨论(0)
提交回复
热议问题