# Text pasting in different line text box instead of intended line textbox

**URL:** <https://forum.katalon.com/t/text-pasting-in-different-line-text-box-instead-of-intended-line-textbox/88591>\
**Category:** Bug Report\
**Tags:** katalon-recorder, bugs-report, katalon-studio\
**Created:** [May 26, 2023, 1:53pm UTC](https://forum.katalon.com/t/text-pasting-in-different-line-text-box-instead-of-intended-line-textbox/88591 "2023-05-26T13:53:28Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![grylion54](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/grylion54/32/16265_2.png) [@grylion54](https://forum.katalon.com/u/grylion54)\
**Post date:** [May 28, 2023, 7:15pm UTC](https://forum.katalon.com/t/text-pasting-in-different-line-text-box-instead-of-intended-line-textbox/88591/4 "2023-05-28T19:15:14Z")

</div>

Your table starts at line 0 (zero), so the second line should be 1. Unfortunately, if you **insert** a row into the table, the “new” row does not become the “next” number, but some seemingly **random** number. As an example, below are the first two rows in the table after I inserted the new row. The new row went into the **second** row.

```auto
//row1 = _FOpt1:_FOr1:0:_FOSritemNode_receivables_billing:0:MAnt2:0:pt1:MTF1:1:pt1:Trans1:0:ap110:AT1:_ATp:table1: **0** :it27::content
//row2 = _FOpt1:_FOr1:0:_FOSritemNode_receivables_billing:0:MAnt2:0:pt1:MTF1:1:pt1:Trans1:0:ap110:AT1:_ATp:table1: **8** :it27::content

```

As you can see from the part that I highlighted in the above, there is only I digit that is different. Now, the table starts at 0 and the new row would be the ninth, so **8** is correct, however, you would need to **count** how many rows there are to get the new row index.

```auto
import org.openqa.selenium.WebDriver as WebDriver
import org.openqa.selenium.WebElement as WebElement
import com.kms.katalon.core.webui.driver.DriverFactory as DriverFactory

def driver = DriverFactory.getWebDriver()
...
WebUI.click(findTestObject('Object Repository/Page_Manage Transactions - Billing - Oracle_c9685a/input_Number of Periods__FOpt1_FOr10_FOSrit_2e6301'))

WebUI.setText(findTestObject('Object Repository/Page_Manage Transactions - Billing - Oracle_c9685a/input_Assessable Value__FOpt1_FOr10_FOSrite_f82baf'), '2')

List<WebElement> list = driver.findElements(By.xpath('//input[contains(@id,"_FOpt1:_FOr1:0:_FOSritemNode_receivables_billing:0:MAnt2:0:pt1:MTF1:1:pt1:Trans1:0:ap110:AT1:_ATp:table1:") and contains(@id, ":it27::content")]')
rowCount = list.size() // this is the number we want less one because we start at zero

myItem = driver.findElement(By.xpath("id('_FOpt1:_FOr1:0:_FOSritemNode_receivables_billing:0:MAnt2:0:pt1:MTF1:1:pt1:Trans1:0:ap110:AT1:_ATp:table1:${rowCount - 1}:it27::content')")
myItem.sendKeys("2nd line data")

```

I am using a substitution on the **rowCount** and you might have to play with the double quote and single quote placement. The substitution **needs** the double quotes, but the **id** should only need the single quote.

Edit: If I am on the wrong page and therefore the wrong table, my apologies, but I can only imagine what elements you are clicking on based on your **naming convention / description** that you are using, like: `_FOpt1_FOr10_FOSritemNode_receiv_2e1a17`. Perhaps, you can add some text of the element, like 'img\_Reorder Columns\_ **View** \_FOpt1\_FOr10\_FOSritemNo\_901715`, or **Edit** or **Action** or **AddRow** … as I did not find any **901715** on the page.

---

_[View the full topic](https://forum.katalon.com/t/text-pasting-in-different-line-text-box-instead-of-intended-line-textbox/88591)._
