WebElement 类型中的方法 sendKeys(CharSequence[]) 不适用于参数 (String) [英] The method sendKeys(CharSequence[]) in the type WebElement is not applicable for the arguments (String)

查看:28
本文介绍了WebElement 类型中的方法 sendKeys(CharSequence[]) 不适用于参数 (String)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试向 sendkeys() 方法发送一个字符串,但它不接受并抛出错误,因为

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

我的代码如下:

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();
    }
}

有人可以帮忙解决这个问题,为什么 Sendkeys() 方法不将字符串值作为参数?

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

推荐答案

它有一个简单的解决方案.将您的编译器合规性级别从 1.4 更改为 1.7.

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

在您的日食中执行以下步骤:

Follow these steps in your eclipse:

  1. 右键单击您的 Java 项目并选择构建路径 -> 单击
    配置构建路径...
  2. 在项目属性窗口中,单击/选择左侧的Java Compiler
    面板
  3. 在右侧面板中,将编译器合规性级别从 1.4 更改为 1.7
    (在你的 Eclipse 中选择哪个版本更高)
  4. 最后点击应用确定
  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.

这篇关于WebElement 类型中的方法 sendKeys(CharSequence[]) 不适用于参数 (String)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆