0

I'm trying to expand the + button to expand the option under it but unable to expand and python IDE throws below error. Tried different CSS and Xpaths but no luck :(

Error message:

selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath",

Firefox XPath:

.//*[@id='ExcentiveTreeViewn0']/img

html code below:

<table cellspacing="0" cellpadding="0" style="border-width:0;">
    <tbody>
            <tr>
                <td>
                    <a id="ExcentiveTreeViewn0" href="javascript:TreeView_PopulateNode(ExcentiveTreeView_Data,0,document.getElementById('ExcentiveTreeViewn0'),document.getElementById('ExcentiveTreeViewt0'),null,'r','<span class=\'nodeCss\' onclick=\"LoadPage(\'grids%252fgrid_folders.aspx%253fid_node%253dTzlq3UXxbAE%253d%2526id_table%253d-301%2526id_mod%253dTzlq3UXxbAE%253d\', \'iGrid\');\"><img class=\'nodeIcon\' src=\"../style/-1/treeview/picto_folder.gif\" /><span class=\'nodeText\'>Rules</span></span>','-300#-301#0#staticNode#0#culture#F','f','','f')">
                        <img style="border-width:0;" alt="Develop" src="../style/-1/treeview/rplus.gif"/>
                    </a>
                </td>
                <td class="" style="white-space:nowrap;" onmouseout="TreeView_UnhoverNode(this)" onmouseover="TreeView_HoverNode(ExcentiveTreeView_Data, this)">
            </tr>
    </tbody>
</table>
sorak
  • 2,607
  • 2
  • 16
  • 24
  • 1
    Can you provide the url? – G_M Mar 13 '18 at 21:01
  • Also, can you share the code snippet around the point where this exception occurs? – Ian Lesperance Mar 13 '18 at 21:55
  • I'm very sorry,site URL will not be able to access to the members outside of my organization – Abhishek s Mar 14 '18 at 07:00
  • @Ian Scenario is, I'm logging into the website and in the home page the + button is available to expand the tree.The URL of the site will not be able to access outside of Org and i'll not be able to give you the site URL or the snippet which you asked as the above code would be of opening the website which contains site URL.Thanks – Abhishek s Mar 14 '18 at 07:05
  • Then remove/obscure the URL from the snippet. Without more information, we can’t help debug your problem. – Ian Lesperance Mar 14 '18 at 12:43

2 Answers2

0

Don't start the xpath with a period

//a[@id='ExcentiveTreeViewn0']/img

Other options:

  1. The code is inside an iFrame so you would need to switch to it first.
  2. The javascript in the href is confusing the selenium parser. There is a lot of HTML code embedded in there.

Please edit the question to include the code you are trying along with a larger section of the HTML

MivaScott
  • 1,763
  • 1
  • 12
  • 30
  • So they understand why they shouldn't use the "period". [https://stackoverflow.com/questions/40914661/what-does-dot-mean-in-the-xpath-of-selenium](https://stackoverflow.com/questions/40914661/what-does-dot-mean-in-the-xpath-of-selenium) – IamBatman Mar 13 '18 at 22:46
  • Thanks for your reply and suggestion.I tried after removing period but still no luck. getting same error. selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//a[@id='ExcentiveTreeViewn0']/img"} (Session info: chrome=64.0.3282.186) – Abhishek s Mar 14 '18 at 06:54
  • @MIvaScott Thank you soo much for your suggestion.i have followed your other options steps mentioned above and it worked:).Firstly,switched to correct frame and javascript in the href was confusing selenium so used Action class to resolve it. – Abhishek s Mar 15 '18 at 07:41
0

Issue was Resolved After routing to correct IFrame and using action class as mentioned in the below link

Link: Unable to perform click action in selenium python