iOS finding element using string

Hi,

I need to find the element using a particular string. I tried like below,but not working.
Can any one pls let me know,how to do that.

element = driver.findElement(By.xpath("//UIAStaticText[@name=‘C381WF’]"));
String name = element.getAttribute(“name”); //Here i am getting name as C381WF.

I want to use this string name in some other screen and find that element.
I tried like below.
element = driver.findElement(By.xpath("//UIAStaticText[@name= name]"));

This is not working.

It should be something like

driver.findElement(By.xpath("//UIAStaticText[@name='"+name+"']"));

If you want it more pretty, look for something like
http://docs.oracle.com/javase/7/docs/api/java/util/Formatter.html

1 Like

Thanks a lot.It work nicely.