Take the 2-minute tour ×
Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. It's 100% free, no registration required.

I'm trying to expand a tree of nodes with folder structure using XPath locators

selenium.click("//*[@id='ext-gen15']/li/div/img[1]"); 

but as the folder structure is not fixed and changes, so XPath expression must change:

selenium.click("//*[@id='ext-gen15']/li/ul/li[1]/div/img[1]");

It worked in TestLink 1.9.2Version as i had an "Expand All" button to directly expand the tree but this button is missing in 1.9Version and i am unable to expand the tree at once. There are more than 750 test cases under multiple folders and to find each xpath to implement would be really tidious. I want to know to how implement to expand tree as the xpaths are changing dynamically. Please note i want to perform this operation on "testlink tool".

Example XPaths:

/html/body/div[1]/div/div/ul/li/div/img[1]; 
//html/body/div[1]/div/div/ul/li/ul/li[1]/div/img[1]; 
//html/body/div[1]/div/div/ul/li/ul/li[2]/div/img[1]; 
//html/body/div[1]/div/div/ul/li/ul/li[2]/ul/li/div/img[1]; 
//html/body/div[1]/div/div/ul/li/ul/li[2]/ul/li/ul/li/div/img[1]; 
//html/body/div[1]/div/div/ul/li/ul/li[3]/div/img[1]; 
//html/body/div[1]/div/div/ul/li/ul/li[3]/ul/li/div/img[1]; 
//html/body/div[1]/div/div/ul/li/ul/li[4]/div/img[1];

HTML code of the entire tree structure

<div id="tree" class="x-panel x-tree" style="overflow:auto; height:100%;border:1px solid #c3daf9;">
<div id="ext-gen13" class="x-panel-bwrap">
<div id="ext-gen14" class="x-panel-body x-panel-body-noheader" style="overflow: auto;">
<ul id="ext-gen15" class="x-tree-root-ct x-tree-arrows">
<li class="x-tree-node">
<div class="x-tree-node-el x-unselectable x-tree-node-expanded" unselectable="on" ext:tree-node-id="293112">
<span class="x-tree-node-indent"></span>
<img class="x-tree-ec-icon x-tree-elbow-end-minus" src="https://portal.truphone.com/testlink/third_party/ext-js/images/default/s.gif" alt="">
<img class="x-tree-node-icon" unselectable="on" src="https://portal.truphone.com/testlink/third_party/ext-js/images/default/s.gif" alt="">
<a class="x-tree-node-anchor" tabindex="1" href="javascript:SP(293112,0)" hidefocus="on">
<span unselectable="on">
Eden / BIT_Integration_Testing_TestPlan (115)(
<span class="light_not_run" title="Not Run">22,</span>
<span class="light_passed" title="Passed">75,</span>
<span class="light_failed" title="Failed">14,</span>
<span class="light_blocked" title="Blocked">4</span>
)
</span>
</a>
</div>
<ul class="x-tree-node-ct" style="">
<li class="x-tree-node">
<div class="x-tree-node-el x-unselectable x-tree-node-expanded" unselectable="on" ext:tree-node-id="313089">
<span class="x-tree-node-indent">
<img class="x-tree-icon" src="https://portal.truphone.com/testlink/third_party/ext-js/images/default/s.gif" alt="">
</span>
<img class="x-tree-ec-icon x-tree-elbow-minus" src="https://portal.truphone.com/testlink/third_party/ext-js/images/default/s.gif" alt="">
<img class="x-tree-node-icon" unselectable="on" src="https://portal.truphone.com/testlink/third_party/ext-js/images/default/s.gif" alt="">
<a class="x-tree-node-anchor" tabindex="1" href="" hidefocus="on">
<span unselectable="on">
SanityTest Cases (7)(
<span class="light_not_run" title="Not Run">0,</span>
<span class="light_passed" title="Passed">7,</span>
<span class="light_failed" title="Failed">0,</span>
<span class="light_blocked" title="Blocked">0</span>
)
</span>
</a>
</div>
<ul class="x-tree-node-ct" style="">
<li class="x-tree-node">
<div class="x-tree-node-el x-tree-node-leaf x-unselectable" unselectable="on" ext:tree-node-id="310784">
<span class="x-tree-node-indent">
<img class="x-tree-icon" src="https://portal.truphone.com/testlink/third_party/ext-js/images/default/s.gif" alt="">
<img class="x-tree-elbow-line" src="https://portal.truphone.com/testlink/third_party/ext-js/images/default/s.gif" alt="">
</span>
<img class="x-tree-ec-icon x-tree-elbow" src="https://portal.truphone.com/testlink/third_party/ext-js/images/default/s.gif" alt="">
<img class="x-tree-node-icon" unselectable="on" src="https://portal.truphone.com/testlink/third_party/ext-js/images/default/s.gif" alt="">
<a class="x-tree-node-anchor" tabindex="1" href="javascript:ST(310784,310785)" hidefocus="on">
<span unselectable="on">
<span class="light_passed" alt="Passed" title="Passed">
<b>eden-2517</b>
:Verify order for CRIL B2B_US with Elite 1000 having secondary MSISDN of UK.
</span>
</span>
</a>
</div>
<ul class="x-tree-node-ct" style="display:none;"></ul>
</li>
<li class="x-tree-node">
<div class="x-tree-node-el x-tree-node-leaf x-unselectable" unselectable="on" ext:tree-node-id="310011">
<span class="x-tree-node-indent">
<img class="x-tree-icon" src="https://portal.truphone.com/testlink/third_party/ext-js/images/default/s.gif" alt="">
<img class="x-tree-elbow-line" src="https://portal.truphone.com/testlink/third_party/ext-js/images/default/s.gif" alt="">
</span>
<img class="x-tree-ec-icon x-tree-elbow" src="https://portal.truphone.com/testlink/third_party/ext-js/images/default/s.gif" alt="">
<img class="x-tree-node-icon" unselectable="on" src="https://portal.truphone.com/testlink/third_party/ext-js/images/default/s.gif" alt="">
<a class="x-tree-node-anchor" tabindex="1" href="javascript:ST(310011,310012)" hidefocus="on">
<span unselectable="on">
<span class="light_passed" alt="Passed" title="Passed">
<b>eden-2490</b>
:Verify order via fulfillment partner for B2B_AU with Elite 800 havin secondary MSISDN_US.
</span>
</span>
</a>
</div>
<ul class="x-tree-node-ct" style="display:none;"></ul>
</li>
<li class="x-tree-node">
<div class="x-tree-node-el x-tree-node-leaf x-unselectable" unselectable="on" ext:tree-node-id="309782">
<span class="x-tree-node-indent">
<img class="x-tree-icon" src="https://portal.truphone.com/testlink/third_party/ext-js/images/default/s.gif" alt="">
<img class="x-tree-elbow-line" src="https://portal.truphone.com/testlink/third_party/ext-js/images/default/s.gif" alt="">
</span>
<img class="x-tree-ec-icon x-tree-elbow" src="https://portal.truphone.com/testlink/third_party/ext-js/images/default/s.gif" alt="">
<img class="x-tree-node-icon" unselectable="on" src="https://portal.truphone.com/testlink/third_party/ext-js/images/default/s.gif" alt="">
<a class="x-tree-node-anchor" tabindex="1" href="javascript:ST(309782,309783)" hidefocus="on">
<span unselectable="on">
<span class="light_passed" alt="Passed" title="Passed">
<b>eden-2484</b>
:Verify order via fulfilment partner for B2B_UK with Elite 1000 having secondary AU MSISDN
</span>
</span>
</a>
</div>
<ul class="x-tree-node-ct" style="display:none;"></ul>
</li>
<li class="x-tree-node">
<div class="x-tree-node-el x-tree-node-leaf x-unselectable" unselectable="on" ext:tree-node-id="309858">
<span class="x-tree-node-indent">
<img class="x-tree-icon" src="https://portal.truphone.com/testlink/third_party/ext-js/images/default/s.gif" alt="">
<img class="x-tree-elbow-line" src="https://portal.truphone.com/testlink/third_party/ext-js/images/default/s.gif" alt="">
</span>
<img class="x-tree-ec-icon x-tree-elbow" src="https://portal.truphone.com/testlink/third_party/ext-js/images/default/s.gif" alt="">
<img class="x-tree-node-icon" unselectable="on" src="https://portal.truphone.com/testlink/third_party/ext-js/images/default/s.gif" alt="">
<a class="x-tree-node-anchor" tabindex="1" href="javascript:ST(309858,309859)" hidefocus="on">
<span unselectable="on">
<span class="light_passed" alt="Passed" title="Passed">
<b>eden-2486</b>
:Verify order via fulfillment partner for B2B_US with Elite 1000 havin sec MSISDN_UK.
</span>
</span>
</a>
</div>
<ul class="x-tree-node-ct" style="display:none;"></ul>
</li>
<li class="x-tree-node">
<div class="x-tree-node-el x-tree-node-leaf x-unselectable" unselectable="on" ext:tree-node-id="311291">
<span class="x-tree-node-indent">
<img class="x-tree-icon" src="https://portal.truphone.com/testlink/third_party/ext-js/images/default/s.gif" alt="">
<img class="x-tree-elbow-line" src="https://portal.truphone.com/testlink/third_party/ext-js/images/default/s.gif" alt="">
</span>
<img class="x-tree-ec-icon x-tree-elbow" src="https://portal.truphone.com/testlink/third_party/ext-js/images/default/s.gif" alt="">
<img class="x-tree-node-icon" unselectable="on" src="https://portal.truphone.com/testlink/third_party/ext-js/images/default/s.gif" alt="">
<a class="x-tree-node-anchor" tabindex="1" href="javascript:ST(311291,311292)" hidefocus="on">
<span unselectable="on">
<span class="light_passed" alt="Passed" title="Passed">
<b>eden-2534</b>
:Verify order via Partners(InDirect Channel) for B2C_AUS with prepaid product.
</span>
</span>
</a>
</div>
<ul class="x-tree-node-ct" style="display:none;"></ul>
</li>
<li class="x-tree-node">
<div class="x-tree-node-el x-tree-node-leaf x-unselectable" unselectable="on" ext:tree-node-id="311271">
<span class="x-tree-node-indent">
<img class="x-tree-icon" src="https://portal.truphone.com/testlink/third_party/ext-js/images/default/s.gif" alt="">
<img class="x-tree-elbow-line" src="https://portal.truphone.com/testlink/third_party/ext-js/images/default/s.gif" alt="">
</span>
<img class="x-tree-ec-icon x-tree-elbow" src="https://portal.truphone.com/testlink/third_party/ext-js/images/default/s.gif" alt="">
<img class="x-tree-node-icon" unselectable="on" src="https://portal.truphone.com/testlink/third_party/ext-js/images/default/s.gif" alt="">
<a class="x-tree-node-anchor" tabindex="1" href="javascript:ST(311271,311272)" hidefocus="on">
<span unselectable="on">
<span class="light_passed" alt="Passed" title="Passed">
<b>eden-2533</b>
:Verify order via Partners(InDirect Channel) for B2C_US with prepaid product.
</span>
</span>
</a>
</div>
<ul class="x-tree-node-ct" style="display:none;"></ul>
</li>
<li class="x-tree-node">
<div class="x-tree-node-el x-tree-node-leaf x-unselectable" unselectable="on" ext:tree-node-id="311251">
<span class="x-tree-node-indent">
<img class="x-tree-icon" src="https://portal.truphone.com/testlink/third_party/ext-js/images/default/s.gif" alt="">
<img class="x-tree-elbow-line" src="https://portal.truphone.com/testlink/third_party/ext-js/images/default/s.gif" alt="">
</span>
<img class="x-tree-ec-icon x-tree-elbow-end" src="https://portal.truphone.com/testlink/third_party/ext-js/images/default/s.gif" alt="">
<img class="x-tree-node-icon" unselectable="on" src="https://portal.truphone.com/testlink/third_party/ext-js/images/default/s.gif" alt="">
<a class="x-tree-node-anchor" tabindex="1" href="javascript:ST(311251,311252)" hidefocus="on">
<span unselectable="on">
<span class="light_passed" alt="Passed" title="Passed">
<b>eden-2532</b>
:Verify order via Partners(InDirect Channel) for B2C_UK with prepaid product.
</span>
</span>
</a>
</div>
<ul class="x-tree-node-ct" style="display:none;"></ul>
</li>
</ul>
</li>
<li class="x-tree-node">
<div class="x-tree-node-el x-unselectable x-tree-node-collapsed" unselectable="on" ext:tree-node-id="303820">
<span class="x-tree-node-indent">
<img class="x-tree-icon" src="https://portal.truphone.com/testlink/third_party/ext-js/images/default/s.gif" alt="">
</span>
<img class="x-tree-ec-icon x-tree-elbow-plus" src="https://portal.truphone.com/testlink/third_party/ext-js/images/default/s.gif" alt="">
<img class="x-tree-node-icon" unselectable="on" src="https://portal.truphone.com/testlink/third_party/ext-js/images/default/s.gif" alt="">
<a class="x-tree-node-anchor" tabindex="1" href="" hidefocus="on">
<span unselectable="on">
BIT (74)(
<span class="light_not_run" title="Not Run">3,</span>
<span class="light_passed" title="Passed">55,</span>
<span class="light_failed" title="Failed">12,</span>
<span class="light_blocked" title="Blocked">4</span>
)
</span>
</a>
</div>
<ul class="x-tree-node-ct" style="display:none;"></ul>
</li>
<li class="x-tree-node">
<div class="x-tree-node-el x-unselectable x-tree-node-collapsed" unselectable="on" ext:tree-node-id="313071">
<span class="x-tree-node-indent">
<img class="x-tree-icon" src="https://portal.truphone.com/testlink/third_party/ext-js/images/default/s.gif" alt="">
</span>
<img class="x-tree-ec-icon x-tree-elbow-plus" src="https://portal.truphone.com/testlink/third_party/ext-js/images/default/s.gif" alt="">
<img class="x-tree-node-icon" unselectable="on" src="https://portal.truphone.com/testlink/third_party/ext-js/images/default/s.gif" alt="">
<a class="x-tree-node-anchor" tabindex="1" href="" hidefocus="on">
<span unselectable="on">
E2E Tests (30)(
<span class="light_not_run" title="Not Run">15,</span>
<span class="light_passed" title="Passed">13,</span>
<span class="light_failed" title="Failed">2,</span>
<span class="light_blocked" title="Blocked">0</span>
)
</span>
</a>
</div>
<ul class="x-tree-node-ct" style="display:none;"></ul>
</li>
<li class="x-tree-node">
<div class="x-tree-node-el x-unselectable x-tree-node-collapsed" unselectable="on" ext:tree-node-id="322551">
<span class="x-tree-node-indent">
<img class="x-tree-icon" src="https://portal.truphone.com/testlink/third_party/ext-js/images/default/s.gif" alt="">
</span>
<img class="x-tree-ec-icon x-tree-elbow-end-plus" src="https://portal.truphone.com/testlink/third_party/ext-js/images/default/s.gif" alt="">
<img class="x-tree-node-icon" unselectable="on" src="https://portal.truphone.com/testlink/third_party/ext-js/images/default/s.gif" alt="">
<a class="x-tree-node-anchor" tabindex="1" href="" hidefocus="on">
<span unselectable="on">
DE_SCOPED (4)(
<span class="light_not_run" title="Not Run">4,</span>
<span class="light_passed" title="Passed">0,</span>
<span class="light_failed" title="Failed">0,</span>
<span class="light_blocked" title="Blocked">0</span>
)
</span>
</a>
</div>
<ul class="x-tree-node-ct" style="display:none;"></ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
</div>
</body>

On using the provided XPath ,I am getting the error "Element not found". I am attaching the logs for reference.

16:02:14.804 INFO - Command request: getNewBrowserSession[*firefox, https://portal.truphone.com, ] on session null
16:02:14.804 INFO - creating new remote session
16:02:14.851 INFO - Allocated session 1bf2070b72af4d41ba413d5d4f568d24 for https://portal.truphone.com, launching...
jar:file:/C:/Softwares/jars/selenium-server-standalone-2.28.0.jar!/customProfileDirCUSTFFCHROME
16:02:15.163 INFO - Preparing Firefox profile...
16:02:21.097 INFO - Launching Firefox...
16:02:28.562 INFO - Got result: OK,1bf2070b72af4d41ba413d5d4f568d24 on session 1bf2070b72af4d41ba413d5d4f568d24
16:02:28.593 INFO - Command request: windowFocus[, ] on session 1bf2070b72af4d41ba413d5d4f568d24
16:02:28.608 INFO - Got result: OK on session 1bf2070b72af4d41ba413d5d4f568d24
16:02:28.608 INFO - Command request: windowMaximize[, ] on session 1bf2070b72af4d41ba413d5d4f568d24
16:02:28.655 INFO - Got result: OK on session 1bf2070b72af4d41ba413d5d4f568d24
Test Name -- loginTest
total rows -- 2
total cols -- 3
Test Name -- testPlan
total rows -- 2
total cols -- 2
Test Name -- eden_Pass
total rows -- 4
total cols -- 2
username-----password---Y
16:02:28.765 INFO - Command request: open[/testlink/login.php, ] on session 1bf2070b72af4d41ba413d5d4f568d24
16:02:37.556 INFO - Got result: OK on session 1bf2070b72af4d41ba413d5d4f568d24
16:02:40.554 INFO - Command request: type[//*[@id='login'], rpatel] on session 1bf2070b72af4d41ba413d5d4f568d24
16:02:40.570 INFO - Got result: OK on session 1bf2070b72af4d41ba413d5d4f568d24
16:02:43.568 INFO - Command request: type[//html/body/div[2]/form/p[2]/input, ak1LbbY[7] on session 1bf2070b72af4d41ba413d5d4f568d24
16:02:43.599 INFO - Got result: OK on session 1bf2070b72af4d41ba413d5d4f568d24
16:02:46.598 INFO - Command request: click[//html/body/div[2]/form/input[3], ] on session 1bf2070b72af4d41ba413d5d4f568d24
16:02:47.472 INFO - Got result: OK on session 1bf2070b72af4d41ba413d5d4f568d24
16:02:52.485 INFO - Command request: waitForPageToLoad[50000, ] on session 1bf2070b72af4d41ba413d5d4f568d24
16:02:59.606 INFO - Got result: OK on session 1bf2070b72af4d41ba413d5d4f568d24
16:02:59.606 INFO - Command request: select[name=testproject, label=Eden] on session 1bf2070b72af4d41ba413d5d4f568d24
16:02:59.668 INFO - Got result: OK on session 1bf2070b72af4d41ba413d5d4f568d24
16:03:02.666 INFO - Command request: selectFrame[titlebar, ] on session 1bf2070b72af4d41ba413d5d4f568d24
16:03:02.713 INFO - Got result: OK on session 1bf2070b72af4d41ba413d5d4f568d24
16:03:07.710 INFO - Command request: click[link=Test Execution, ] on session 1bf2070b72af4d41ba413d5d4f568d24
16:03:07.788 INFO - Got result: OK on session 1bf2070b72af4d41ba413d5d4f568d24
16:03:10.786 INFO - Command request: selectFrame[relative=up, ] on session 1bf2070b72af4d41ba413d5d4f568d24
16:03:10.849 INFO - Got result: OK on session 1bf2070b72af4d41ba413d5d4f568d24
16:03:13.847 INFO - Command request: selectFrame[mainframe, ] on session 1bf2070b72af4d41ba413d5d4f568d24
16:03:13.878 INFO - Got result: OK on session 1bf2070b72af4d41ba413d5d4f568d24
16:03:13.894 INFO - Command request: selectFrame[treeframe, ] on session 1bf2070b72af4d41ba413d5d4f568d24
16:03:13.972 INFO - Got result: OK on session 1bf2070b72af4d41ba413d5d4f568d24
16:03:16.970 INFO - Command request: selectFrame[relative=up, ] on session 1bf2070b72af4d41ba413d5d4f568d24
16:03:17.001 INFO - Got result: OK on session 1bf2070b72af4d41ba413d5d4f568d24
16:03:17.001 INFO - Command request: select[//*[@id='settings']/table/tbody/tr[1]/td/select, Production_E2E_Testing_TestPlan] on session 1bf2070b72af4d41ba413d5d4f568d24
16:03:17.048 INFO - Got result: OK on session 1bf2070b72af4d41ba413d5d4f568d24
16:03:17.048 INFO - Command request: waitForPageToLoad[30000, ] on session 1bf2070b72af4d41ba413d5d4f568d24
16:03:20.047 INFO - Got result: OK on session 1bf2070b72af4d41ba413d5d4f568d24
16:03:20.047 INFO - Command request: select[//*[@id='settings']/table/tbody/tr[2]/td/select, Cycle-14/01/2013 TO 31/01/2013] on session 1bf2070b72af4d41ba413d5d4f568d24
16:03:20.109 INFO - Got result: OK on session 1bf2070b72af4d41ba413d5d4f568d24
16:03:30.103 INFO - Command request: type[//*[@id='filters']/table/tbody/tr[1]/td[2]/input , eden-2532] on session 1bf2070b72af4d41ba413d5d4f568d24
16:03:30.134 INFO - Got result: OK on session 1bf2070b72af4d41ba413d5d4f568d24
16:03:30.150 INFO - Command request: click[//*[@id='doUpdateTree'], ] on session 1bf2070b72af4d41ba413d5d4f568d24
16:03:30.337 INFO - Got result: OK on session 1bf2070b72af4d41ba413d5d4f568d24
16:03:30.337 INFO - Command request: waitForPageToLoad[30000, ] on session 1bf2070b72af4d41ba413d5d4f568d24
16:03:32.555 INFO - Got result: OK on session 1bf2070b72af4d41ba413d5d4f568d24
16:03:32.555 INFO - Command request: click[//img[@class='x-tree-ec-icon x-tree-elbow-plus'], ] on session 1bf2070b72af4d41ba413d5d4f568d24
16:03:32.617 INFO - Got result: ERROR: Element //img[@class='x-tree-ec-icon x-tree-elbow-plus'] not found on session 1bf2070b72af4d41ba413d5d4f568d24
share|improve this question
    
rephrasing my question, I want to know to how find the xpath of the tree so that the click option will expand the entire tree. the xpath is changing everytime depending on the folder structure. –  Andaleeb Jan 24 '13 at 13:02
    
I removed irrelevant code pieces and clarified the question for you. It is clear to me, that changing folder structure makes a challenge to write XPath expression but I see no relation of your problem with TestLink version. –  dzieciou Jan 24 '13 at 16:37
    
A sidenote: in your code you've used Thread.sleep() which is a risky anti-pattern in test automation. –  dzieciou Jan 24 '13 at 16:38
    
So TestLink is the application under tests? This needs clarification because usually TestLink is considered an application to manage test cases. –  dzieciou Jan 24 '13 at 17:41
    
Does the tree element have some unique id, class or style? –  dzieciou Jan 24 '13 at 17:43

2 Answers 2

Try XPath expression that matches first image of the x-tree-ec-icon and x-tree-elbow-plus classes.

//img[@class='x-tree-ec-icon x-tree-elbow-plus']

This is what both your HTML and your recording IDE suggests. You may see if the above expression matches only one element, and if no, consider matching only the first one (corresponding to the root node of the tree):

//img[@class='x-tree-ec-icon x-tree-elbow-plus'][1]
share|improve this answer
    
dzieciou:Thank you for providing the Xpath, I tried to implement this in my code. But i am getting the error " Element not found" on the very 1st node of the tree itself. I tried with both the Xpaths you provided but no luck :( –  Andaleeb Jan 25 '13 at 11:06
    
Strange. It tried XPaths at xpathtester.com and xpath.online-toolz.com/tools/xpath-editor.php over your document. I had to fix your document first: remove unknown namespaces ext:, close unclosed img tags, and remove tags in the end that do not have corresponding opening tags (your document is incomplete). You may want to play with the sites I listed. –  dzieciou Jan 25 '13 at 11:20
    
I tried to put the entire source code in the sites you provided but i am getting the following error" Something went wrong:The public identifier must begin with either a single or double quote character." I am not too good with this tool to debug the error, and the source code it too big for me to paste it here, it is exceeding the size limit. Could you please help me out :( really stuck with this part of my code. –  Andaleeb Jan 25 '13 at 12:05
    
Ok. HTMLs are not always correct XML documents, so it may be hard to use XML tools. You better stay with Selenium trying to play with expression. Whenever you got "Element not found" error look into the HTML document and see why. –  dzieciou Jan 25 '13 at 12:25

Welcome to SQA, Andaleeb. You need to find something unique about the tree that you can express in the Xpath. For example, the unique quality could be an ID, an element ancestry, a sibling relationship, a particular image, or something else. I don't know what 1.9.2V and 1.9V mean, and I don't see any examples of your HTML, so I can't offer any more specific advice.

Edit: You listed several XPaths but did not say whether they are supposed to correspond to the same clickable item. I see that every XPath ends in img[1]. You might be able to do something with that. Or if there are other images in the page, you might be able to use a property of the img element to identify it. The trick here is to find something that does not vary between the various XPaths that locate that element. Without showing us some HTML, we cannot do that for you.

share|improve this answer
    
Hi, Thanks for the answer. I had tried with the xpath which you provided and it worked fine. But as the folder structure changes there are more than 700 test cases and i am finding it to think of a logic using which the tree gets expanded on clicking. by 1.9.2 v i meant version. sorry as there is character contraint did with the short form. –  Andaleeb Jan 24 '13 at 16:49
    
Some of the xpaths i extracted to see if i can find something unique and i got is the following set. //html/body/div[1]/div/div/ul/li/div/img[1]; //html/body/div[1]/div/div/ul/li/ul/li[1]/div/img[1]; //html/body/div[1]/div/div/ul/li/ul/li[2]/div/img[1]; //html/body/div[1]/div/div/ul/li/ul/li[2]/ul/li/div/img[1]; //html/body/div[1]/div/div/ul/li/ul/li[2]/ul/li/ul/li/div/img[1]; //html/body/div[1]/div/div/ul/li/ul/li[3]/div/img[1]; //html/body/div[1]/div/div/ul/li/ul/li[3]/ul/li/div/img[1]; //html/body/div[1]/div/div/ul/li/ul/li[4]/div/img[1]; –  Andaleeb Jan 24 '13 at 16:49
    
@Andaleeb, please consider updating your question with those XPaths. And format them properly. It's pretty hard to read as is now. –  dzieciou Jan 24 '13 at 16:53
    
@dzieciou,I tried to record using IDE and got this 'selenium.click("css=img.x-tree-ec-icon.x-tree-elbow-plus"); selenium.click("css=img.x-tree-ec-icon.x-tree-elbow-plus"); selenium.click("xpath=(//img[contains(@src,'portal.truphone.com/testlink/third_party/ext-js/images/default/…); selenium.click("css=img.x-tree-ec-icon.x-tree-elbow-plus"); selenium.click("xpath=(//img[contains(@src,'portal.truphone.com/testlink/third_party/ext-js/images/default/…; I need a logic to implement the expand tree as these xpaths change depending on folder structure –  Andaleeb Jan 24 '13 at 17:10
    
@dzieciou: Could you please let me know how to share my HTML code with you. I am unable to put the code:( –  Andaleeb Jan 24 '13 at 19:30

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.