driver.findElementById("com.devere.development:id/et_code_1").sendKeys(Keys.valueOf(1);
driver.findElementById("com.devere.development:id/et_code_1").sendKeys(Keys.valueOf(1);
Asked
Active
Viewed 8,126 times
-2

undetected Selenium
- 183,867
- 41
- 278
- 352

Medha Parulekar
- 31
- 1
- 7
2 Answers
3
sendKeys()
will only take String as an argument.
However, if you want to convert a string into integer, you could use this code :
String str = "1234";
int foo = Integer.parseInt(str);
for conversion from Interger to String, you could use :
String.valueOf(number)

cruisepandey
- 28,520
- 6
- 20
- 38
0
To invoke sendKeys()
with Integer
values you need to use String.valueOf()
method to convert the integer
to String
and can use the following solution:
Code Block:
WebDriver driver = new ChromeDriver(chromeOptions); driver.get("https://www.google.com/"); int myInt = 1234567890; driver.findElement(By.name("q")).sendKeys(String.valueOf(myInt));
If your usecase is to send numbers e.g. 1234567890 you can invoke sendKeys()
with the desired Character Sequence
i.e. 1234567890
and the element validation functions will validate the value on it's own if it was an integer and you can use the following solution:
Code Block:
WebDriver driver = new ChromeDriver(chromeOptions); driver.get("https://www.google.com/"); driver.findElement(By.name("q")).sendKeys("1234567890");
Broswer Snapshot:

undetected Selenium
- 183,867
- 41
- 278
- 352