0

Hi I am working with selenium using Java. I have an editable table in which I need to enter nearly 12-17 values continuously. what I was trying is:

Prdcode.sendkeys(keys.TAB,"1000",keys.TAB,keys.TAB,"2000",....etc);

Now the problem is that it's not entering all the values; If I send 1000, it enters only 10 and triggers tab.

I have even tried "\t" but the problem is that it will append all the values instead of 'clear and enter'. Can some one help me on this?

5
  • Why do you send Keys.TAB? Is it to jump from textField to textField in a form? Also do you mean it is only entering a portion of the value (e.g. "10" instead of "1000"), or only 10 values from the (12) passed values? And finally, what is Prdcode? A WebElement? Or something else? Please post a bit more code so we know what is going on. Commented Dec 22, 2016 at 7:59
  • Ya.procode is a web element(cell).iam triggering tab to jump from one cell to next cell in table.if you see my code..iam triggering TAB to jump to next cell and enter 1000 in that.but it's entering 10(10 instead of 1000) and triggering TAB....... Commented Dec 22, 2016 at 8:24
  • sendKeys will only work on the Prdcode webelement. For jumping to another cell to enter data you got to give selenium that webelement before you use sendkeys. Commented Dec 22, 2016 at 8:57
  • Try giving 'waits' in between Commented Dec 22, 2016 at 10:53
  • But how to customize send keys to have 'wait' in between Commented Dec 22, 2016 at 11:28

1 Answer 1

1

First of all it is not sendkeys(). Please use sendKeys().

Solution:

Use multiple sendkeys() as given below.

Prdcode.sendKeys(keys.TAB);
Prdcode.sendKeys("1000");
Prdcode.sendKeys(keys.TAB);
Prdcode.sendKeys("2000");
Prdcode.sendKeys(.......);

Possible problems and solution :

  1. Prdcode is only one element and script is overwriting existing data. Here you can change next element as per given HTML. Refer this. Example :

    ele1.sendKeys("1000");
    ele2.sendKeys("2000");
    ele3.sendKeys(.......);
    

    Note : No need to use Prdcode.sendKeys(keys.TAB);

  2. Prdcode have some data entry limit. (Please check manually). If yes then script can not add string more than limit (Valid scenario).

  3. If scenario 1 is entering data randomly, then use Thread.sleep(1000); between sendKeys().

See :

ele1.sendKeys("1000");
Thread.sleep(1000);
ele2.sendKeys("2000");
Thread.sleep(1000);
ele3.sendKeys(.......);
Thread.sleep(1000);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.