sendKeys method throwing an error in selenium like"The method sendKeys(char sequence[] )in the type webelement is not applicable for the string"

huangapple go评论71阅读模式
英文:

sendKeys method throwing an error in selenium like"The method sendKeys(char sequence[] )in the type webelement is not applicable for the string"

问题

>这是我的课程*****

    ```
    package automation;

    import org.openqa.selenium.By;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.chrome.ChromeDriver;

    public class Test1 {

	public static void main(String[] args) 
	{
	 System.setProperty("webdriver.chrome.driver", "C:/Users/UMASHANKAR/Downloads/chromedriver_win32/chromedriver.exe");
     WebDriver driver=new ChromeDriver();
     driver.findElement(By.id("userName")).sendKeys("https://sdzclient-kpiregister.azurewebsites.net/");
     driver.findElement(By.id("passwords")).sendKeys("Gravity@123");
    	 driver.findElement(By.id("btn-sdz-login")).click();
	}
    }
    ```

   
   
>在悬停时sendKeys方法将出现错误类似于WebElement类型中的sendKeys(char sequence[])方法不适用于字符串”。
英文:

>this is my class*****

```
package automation;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class Test1 {

public static void main(String[] args) 
{
 System.setProperty("webdriver.chrome.driver", "C:/Users/UMASHANKAR/Downloads/chromedriver_win32/chromedriver.exe");
 WebDriver driver=new ChromeDriver();
 driver.findElement(By.id("userName")).sendKeys("https://sdzclient-kpiregister.azurewebsites.net/");
 driver.findElement(By.id("passwords")).sendKeys("Gravity@123");
	 driver.findElement(By.id("btn-sdz-login")).click();
}
}
```

>on Hover the SendKeys method will get an error like"The method sendKeys(char sequence[] )in the type webelement is not applicable for the string".***

答案1

得分: 0

我不确定,当您说您无法更改编译版本时。您可以根据以下屏幕截图进行更改。

..项目>右键单击>构建路径>配置构建路径>java编译器>

不要忘记在更改编译版本后点击应用

英文:

I am not sure, when you said you are not able to change compilation version. You can change as per below screen grab.

> ..project>right click>build path>configure build path >java compiler>

sendKeys method throwing an error in selenium like"The method sendKeys(char sequence[] )in the type webelement is not applicable for the string"

Do not forget to click on Apply after changing compilation version.

答案2

得分: 0

当您使用Selenium时,需要遵循以下几个步骤:

//首先,您需要添加Chrome驱动程序路径
System.setProperty("webdriver.chrome.driver", "C:/Users/UMASHANKAR/Downloads/chromedriver_win32/chromedriver.exe");

//其次,您需要初始化WebDriver对象 - 您已经完成了
WebDriver driver = new ChromeDriver();

//第三,您需要告诉WebDriver对象去哪里,加载哪个页面
driver.get("https://sdzclient-kpiregister.azurewebsites.net/");

//以下是登录部分
driver.findElement(By.id("userName")).sendKeys("SET_YOUR_USERNAME_HERE");
driver.findElement(By.id("passwords")).sendKeys("Gravity@123");
driver.findElement(By.id("btn-sdz-login")).click();

您的错误是由于驱动程序不知道要前往哪个页面,但您尝试发送一些按键,而不是驱动页面路径。

英文:

When you are working with Selenium you need to follow a few steps

//first you add your chrome driver path    
System.setProperty("webdriver.chrome.driver", "C:/Users/UMASHANKAR/Downloads/chromedriver_win32/chromedriver.exe");

// second you need to initialize the WebDriver object - and you did it
WebDriver driver=new ChromeDriver();

// third you need to tell to the WebDriver object where to go, what page to load 
driver.get("https://sdzclient-kpiregister.azurewebsites.net/"); 

//below is the login part
driver.findElement(By.id("userName")).sendKeys("SET_YOUR_USERNAME_HERE");
driver.findElement(By.id("passwords")).sendKeys("Gravity@123");
driver.findElement(By.id("btn-sdz-login")).click();

your error was throw because the driver didn't know where to go but you tried to send some keys instead of a driving page path

huangapple
  • 本文由 发表于 2020年9月16日 16:46:23
  • 转载请务必保留本文链接:https://go.coder-hub.com/63916398.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定