M prajwala
M prajwala

Reputation: 1

Selenium with Java send keys with keys.TAB

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?

Upvotes: 0

Views: 4182

Answers (1)

Sagar007
Sagar007

Reputation: 848

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);

Upvotes: 1

Related Questions