Expand or Collapse the Tree structure -Selenium-TestNG

1,621 views
Skip to first unread message

Baskar.R

unread,
Jul 22, 2011, 5:49:53 PM7/22/11
to seleniu...@googlegroups.com
Hi All,

i want to expand a tree structure, to expand i have a image [+] , on clicking the image, the tree should get expanded, on clicking the [-] image, the tree should get collapsed.

Please help me on this,i know this is a basic question, i am new to selenium.

Environment used:
Eclipse, Selenium,TestNG

i tried the following code:
selenium.click(<xPath of the image>)

Getting the following error:

com.thoughtworks.selenium.
SeleniumException: ERROR: Element id=('tree')/x:li[2]/x:div not found

Note: i have taken the xpath location using xpath option.
this is the xpath "id=('tree')/x:li[2]/x:div"


Regards,
Baskar

baski

unread,
Jul 22, 2011, 5:47:16 PM7/22/11
to seleniu...@googlegroups.com
Hi All,

i want to expand a tree structure, to expand i have a image [+] , on clicking the image, the tree should get expanded, on clicking the [-] image, the tree should get collapsed.

Please help me on this,i know this is a basic question, i am new to selenium.

Environment used:
Eclipse, Selenium,TestNG

i tried the following code:
selenium.click(<xPath of the image>)

Getting the following error:

com.thoughtworks.selenium.SeleniumException: ERROR: Element id=('tree')/x:li[2]/x:div not found

Eli Polonsky

unread,
Jul 23, 2011, 2:14:27 PM7/23/11
to Selenium Users
This Xpath looks a liitle bizare. Not ones I am used ti.
Did you get this from Xpather on Firefox?
Try using the selenium IDE to record your click.
You should see the locator it used and there you can choose Xpath.
It should look something like //div[id='tree']/img

Baskar.R

unread,
Jul 25, 2011, 3:29:02 AM7/25/11
to Selenium Users
Hi,

Thanks for the response, i tried to record using IDE and getting the
below code on clicking Expand.

selenium.click("css=img[alt=Collapse tree view for node.]");
selenium.waitForPageToLoad("30000");

Thanks,
Baskar

On Jul 23, 11:14 pm, Eli Polonsky <eli.polon...@gmail.com> wrote:
> This Xpath looks a liitle bizare. Not ones I am used ti.
> Did you get this from Xpather on Firefox?
> Try using the selenium IDE to record your click.
> You should see the locator it used and there you can choose Xpath.
> It should look something like //div[id='tree']/img
>
> On Jul 23, 12:47 am, baski <torgbas...@gmail.com> wrote:
>
>
>
>
>
>
>
> > Hi All,
>
> > i want toexpanda tree structure, toexpandi have a image [+] , on
Reply all
Reply to author
Forward
0 new messages