Having problem in xpath - getText()

144 views
Skip to first unread message

Elang

unread,
Jun 5, 2013, 4:34:16 AM6/5/13
to appium-...@googlegroups.com

Hi guys,

I want to extract the text from the application. For that I tried with getText() and getAtrribute("name") with the xpath. It was  not working. Bur when I try with the tagName() it works.

The way I used xpath is,

               driver.findElement(By.xpath("//tableview[2]/cell[2]")).getText()
               driver.findElement(By.xpath("//tableview[2]/cell[2]")).getAttribute("name"), both these are failed.

The way I used tagName is

            List<WebElement> rows = table.findElements(By.tagName("tableCell"));             
            System.out.println(rows.get(1).getAttribute("name")); This works fine.

I attached the picture, there you will find the application and its xpath. Please refer that and say what is the problem with the xpath, which I use.

Also in which case I have to use getText() and getAtrribute() here.

Thanks.

Regards,
Elang.



appium_inspector_recipe_06052013.jpg

Al Villaflor

unread,
Jun 5, 2013, 6:51:06 AM6/5/13
to appium-...@googlegroups.com
Try
driver.findElement(By.xpath("//tableview[2]/cell[2]/text")).getText()
driver.findElement(By.xpath("//tableview[2]/cell[2]/text")).getAttribute("name")
Reply all
Reply to author
Forward
0 new messages