Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
858 views
in Technique[技术] by (71.8m points)

java - The method sendKeys(CharSequence[]) in the type WebElement is not applicable for the arguments (String)

I am trying to send a String to the sendkeys() method, but it is not accepting and throwing an error as

my codes follows:

package healthcare;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.Select;

import com.thoughtworks.selenium.Selenium;
import com.thoughtworks.selenium.webdriven.WebDriverBackedSelenium;

public class MailRegister_Webdriver {
    public WebDriver driver;
    public Selenium selenium;
    public void openURL(){
//System.setProperty("webdriver.chrome.driver", "F:\Library\chromedriver.exe");       
driver=new FirefoxDriver();
selenium=new WebDriverBackedSelenium(driver, "http://mail.in.com");
driver.get("http://mail.in.com");
    }
    public void register() throws Exception{
//driver.findElement(By.cssSelector("input.registernow")).click();
selenium.click("css=input.registernow");
Thread.sleep(3000);
driver.findElement(By.id("fname")).sendKeys("Nagesh");
selenium.select("day", "10");
selenium.select("month", "Jun");
new Select(driver.findElement(By.id("year"))).selectByVisibleText("1999");
Thread.sleep(1000);
driver.findElement(By.xpath("(//input[@name='radiousername'])[5]")).click();    
Thread.sleep(2000);
        driver.findElement(By.id("password")).sendKeys("nag123");
        driver.findElement(By.id("repassword")).sendKeys);
        driver.findElement(By.id("altemail")).sendKeys();
        driver.findElement(By.id("mobileno")).sendKeys("7894561230");
        driver.findElement(By.id("imageField")).click();
}

    public static void main(String[] args) throws Exception {
        // TODO Auto-generated method stub
        MailRegister_Webdriver m=new MailRegister_Webdriver();
        m.openURL();
        m.register();
    }
}

Can somebody help on this, Why Sendkeys() method is not taking String values as arguments?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

It has a simple solution. Change your compiler compliance level from 1.4 to 1.7.

Follow these steps in your eclipse:

  1. Right click on your java project and select Build Path -> Click on
    Configure Build Path...
  2. In project properties window, Click/select Java Compiler at the left
    panel
  3. At the right panel, change the Compiler compliance level from 1.4 to 1.7
    (Select which is higher version in your eclipse)
  4. Lastly Click on Apply and OK

Now check your code. it will never show the same error.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...