Unable to enter Full values using Selenium Script, only half of the values are passed in to the field

I am trying to enter a text into an "unselectable row" sometimes it enters only half of the text (it fails to enter first few Characters)

E.g: If I am trying to enter "qqwwssagsdafdsagdfgafgafdahdghjagds" text, sometimes it accepts only last few characters i.e. fgafdahdghjagds.

HTML code of the element which i am trying to enter Values:

HTML:

<div id="ext-comp-1002" class="x-layer x-editor x-small-editor x-grid-editor" style="position: absolute; z-index: 11000; visibility: hidden; left: -10000px; top: -10000px; overflow: auto; width: 238px;">
<input id="mltprcrtmain-1" class=" x-form-text x-form-field x-form-fieldui x-form-field-text " type="edit" name="mltprcrtmain-1" autocomplete="off" size="20" style="width: 238px;" maxlength="32">

Script which i have used to pass values in unselectable row (i.e.row) :

Code:

Actions act = new Actions(driver);
act.moveToElement(driver.findElement(By.id(genericHandlingExcel.getdata(FilePath, Sheetname2, 66,2)))).click(); 
act.sendKeys(genericHandlingExcel.getdata(FilePath, Sheetname2, 66,3)); 
Thread.sleep(5000);
act.sendKeys(Keys.ENTER);

Upvotes: 0

Views: 178

Answers (2)

Subburaj
Subburaj

Reputation: 2334

As per your input HTML, your input text box size is 20 and it will support maximum of 32 characters.So, we should able to enter only max of 32 characters and only few characters will be visible in UI(At Max, 20 characters will be displayed and it may be changed based on the attribute which is mentioned in the class).

You are trying to enter a text with 35 characters and hence few characters might not be entered correctly

I would suggest to validate the entered character manually and also ensure the same by manually entering the same character.

Upvotes: 1

Andrei
Andrei

Reputation: 5647

Try to add a small pause in code after click:

Actions act = new Actions(driver); 
act.moveToElement(driver.findElement(By.id(genericHandlingExcel.getdata(FilePath, Sheetname2, 66,2)))).click();
Thread.sleep(2000); // add a small pause after click
act.sendKeys(genericHandlingExcel.getdata(FilePath, Sheetname2, 66,3)); 
Thread.sleep(5000); 
act.sendKeys(Keys.ENTER);

Upvotes: 0

Related Questions