45874

Java : For String values we use the command sendKeys(“String”); Similarly what is the command for po

Selenium Java Web Driver: How to pass numeric data to a numeric field? For String values we use the command sendKeys("String");. Similarly, what is the command for posting numeric data to the numeric field?

Answer1:

If you do sendKeys("9"); it will send the number to the numeric field. I suppose you have something like that:

int numberToSend = 9;

And you want to send it to numeric field. You can do it by these two ways:

String numberToString = "" + numberToSend;

And then you can use either

webElement.sendKeys(""+numberToSend);

or

webElement.sendKeys(numberToString);

Answer2:

I would do the following:

String s = "24"; Integer s1 = Integer.parseInt(s); String orderPercent = s1.toString(); .sendKeys(orderPercent);

Answer3:

Converting that integer to string is the simple and easy solution, like this:

int i=1; String A = Integer.toString(i);

Now pass the value to sendkeys like this:

driver.findElement(By.name("q")).sendKeys(A);

And it will send the value 1.

Recommend

  • Retrieving the value from a Selenium Webdriver WebElement field and passing it to a java variable
  • Activate Word window from Excel with VBA
  • Password-protect the macros of a second workbook from a first using VBA
  • Does using package generics require the package to be in Depends or Imports?
  • Sending keystrokes from a C# application to a Java application - strange behaviour?
  • Obtain access token for both Microsoft Graph and individual service API endpoints (Outlook REST APIs
  • How to make a div appear under button
  • QObject::findChild() returns None without obvious reason
  • TextBox AutoCompleteStringCollection Suggest
  • How do i disable a text box within an iframe
  • Outputting SharePoint Hyperlink Column as URL
  • In matplotlib, how do you change the fontsize of a single figure?
  • Does it make sense to call System.gc() and Thread.sleep() when working on Bitmaps?
  • Caching attributes in superclass
  • Word Open XML Mail Merge
  • Extracting HTML between tags
  • Algorithm for a smudge tool?
  • Jenkins: How To Build multiple projects from a TFS repository?
  • C# - Is there a limit to the size of an httpWebRequest stream?
  • Read text file and split every line in MSBuild
  • Fetching methods from BroadcastReceiver to update UI
  • How do I fake an specific browser client when using Java's Net library?
  • Updating server-side rendering client-side
  • WinForms: two way TextBox problem
  • Fill an image in a square container while keeping aspect ratio
  • Join two tables and save into third-sql
  • Convert array of 8 bytes to signed long in C++
  • Apache 2.4 - remove | delete | uninstall
  • How to pass list parameters for each object using Spring MVC?
  • Run Powershell script from inside other Powershell script with dynamic redirection to file
  • Buffer size for converting unsigned long to string
  • How get height of the a view with gone visibility and height defined as wrap_content in xml?
  • Understanding cpu registers
  • FormattedException instead of throw new Exception(string.Format(…)) in .NET
  • sending mail using smtp is too slow
  • Recursive/Hierarchical Query Using Postgres
  • Running Map reduces the dimensions of the matrices
  • Sorting a 2D array using the second column C++
  • Binding checkboxes to object values in AngularJs
  • java string with new operator and a literal