0

i am using Selenium and i would like to replace xpath to get a list of this

  • elements.

    enter image description here

    So far this xpath works, but i think is is unsophisticated. I think is better change for a CSSselector or shorter xpath, but i am not able to gat the same result.

    enter image description here

    Thanks

  • Andres
    • 29
    • 3

    3 Answers3

    0

    Below xpath will work

    "//div[@id='igTreeProjectTree']//li[starts-with(@data-path, '0_0_')]"
    

    Because I think data-path is unique in all elements

    Francesco Tagliani
    • 109
    • 1
    • 1
    • 10
    0

    For the :

    //*[@id='igTreeProjectTree']/ul/li/ul/li/ul/li
    

    The equivalent will be:

    #igTreeProjectTree > ul > li > ul > li > ul > li
    

    A more canonical Locator Strategy would be:

    #igTreeProjectTree ul[data-depth='2'] > li.ui-igtree-node-nochildren[data-path='0_0_0']
    
    undetected Selenium
    • 183,867
    • 41
    • 278
    • 352
    0

    Try this CSS-selector:

    '#igTreeProjectTree li.ui-igtree-node-nochildren'
    
    JaSON
    • 4,843
    • 2
    • 8
    • 15