参数WebElement中的方法sendKeys(CharSequence [])不适用于参数(String) [英] The method sendKeys(CharSequence[]) in the type WebElement is not applicable for the arguments (String)
本文介绍了参数WebElement中的方法sendKeys(CharSequence [])不适用于参数(String)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试将一个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()方法是不是将String值作为参数?
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:
- 右键单击您的java项目并选择构建路径 - >单击
配置构建路径... - 在项目属性窗口中,单击/选择左侧的 Java编译器
面板 - 在右侧面板中,将编译器合规性级别从1.4更改为1.7
(选择哪个是日食中的更高版本) - 最后点击应用和确定
- Right click on your java project and select Build Path -> Click on
Configure Build Path... - In project properties window, Click/select Java Compiler at the left
panel - At the right panel, change the Compiler compliance level from 1.4 to 1.7
(Select which is higher version in your eclipse) - Lastly Click on Apply and OK
现在检查您的代码。它永远不会显示相同的错误。
Now check your code. it will never show the same error.
这篇关于参数WebElement中的方法sendKeys(CharSequence [])不适用于参数(String)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文