How can i get all the Test Object attributes when i have one of them?

Hi,

i’m writing a test on page that has multiple items.
each item is a backup, each backup has a type and a number.
i want to get the number of the backup, which i can find in the id of the object, from the type which is entered by the user.

here is my code:

@Keyword

def int getBackupNum(String backupType)

{

TestObject backupIcon = new TestObject()

String src = “//*[@src = '/assets/device_icon_” + backupType + “.png]”

backupIcon.addProperty(“src”, ConditionType.EQUALS, src )

WebUI.verifyElementPresent(backupIcon, 0)

List list = backupIcon.getProperties()

String id = backupIcon.getObjectId()

int num = Integer.parseInt(id.replaceAll("\\D", “”));

return num

}

i can’t get the id from no where, both list & id doesn’t have what i need.

any ideas?

I’ve solved this issues with the following code:

def int getBackupNum(String backupType)

{

WebDriver driver = DriverFactory.getWebDriver()

TestObject backupIcon = new TestObject()

String src = “//p[(text() = '” + backupType + “’ or . = '” + backupType + “’)]”

backupIcon.addProperty(“xpath”, ConditionType.EQUALS, src )

WebUI.verifyElementPresent(backupIcon, 15)

WebElement element = driver.findElement(By.xpath(src))

String id = element.getAttribute(“id”)

int num = Integer.parseInt(id.replaceAll("\\D", “”));

return num

}