Java : For String values we use the command sendKeys ("String"); Similarly what is the command for posting a numeric data to the numeric field

标签 java selenium webdriver

Selenium Java Web 驱动程序:如何将数字数据传递到数字字段? 对于 String 值,我们使用命令 sendKeys("String");。同样,将数字数据发布到数字字段的命令是什么?

最佳答案

如果您执行 sendKeys("9");,它会将数字发送到数字字段。我想你有类似的东西:

 int numberToSend = 9;

并且您想将其发送到数字字段。您可以通过以下两种方式完成:

String numberToString = "" + numberToSend;

然后你可以使用任何一个

webElement.sendKeys(""+numberToSend);

webElement.sendKeys(numberToString);

关于Java : For String values we use the command sendKeys ("String"); Similarly what is the command for posting a numeric data to the numeric field,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11224822/

相关文章:

python - Selenium 的 chromedriver PermissionError : [Errno 1] Operation not permitted Error on Mac OSx

python - Selenium xpath 元素属性

java - 如何使用 Selenium WebDriver 处理 HtmlUnitDriver 的身份验证?

javascript - 使用带有多个起始 URL 的 selenium 和 Scrapy 抓取动态内容

java - 使用 NetBeans 8 但低于 Lambda 表达式的编译错误

java - log4j。唯一的日志文件名

Java:如果变量为空(来自用户输入);休息;否则继续主要方法

c# - 在 Chrome 中捕获 XHR/Ajax 请求

java - selenium webdriver 模式对话框 java

java - 如何验证返回的状态代码是否成功,即使用 Rest Assured 的任何 2xx HTTP 状态代码?