I have a set of really strange text fields that I simply cannot find a locator for. I found a workaround in the forum via tabbing to the field from another element, then executing this to enter text to the field:
WebUI.executeJavaScript('document.activeElement.value = "MyValue"', [])
This works a treat. However, I need to have a variable in the value I set to this field (basically, it’s an attribute editor for a product. I change the description here, then go back to the product page and verify that it’s updated to match what I put in). My pet unique variable is just using a timestamp, so I’d love to be able to just have the value be something like “New description timestamp”
However, every time I try to put a variable into this expression, I get an error. I don’t come from a technical background, so I don’t know if I’m committing syntax sins or if this is impossible.
This is what I use to get the timestamp:
Date date = new Date()
def value = date.getTime().toString()
and this is how I get to the field and input text:
WebUI.sendKeys(findTestObject('Attribute/tabMarketCommercial'), Keys.chord(Keys.TAB, Keys.TAB, Keys.TAB, Keys.TAB))
WebUI.executeJavaScript('document.activeElement.value = "This is an automated test description."', [])
Any help would be very much appreciated!