0

I am trying to select an element from the following html code:

<ul class="selectReplace opened">
<li class="default">Standardpizzor</li>
<li class="first">Standardpizzor</li>
<li class="">Specialpizzor</li>
<li class="">Kebab</li>
<li class="last">Dricker</li>
</ul>

by Selenium RC command:

selenium.click("//ul/li[4]");

but no luck! Please help me out if anybody have any solution.

mahadi
  • 55
  • 1
  • 5

1 Answers1

0

If I understand correctly, you want the text 'Dricker' to be selected. You can use the approach suggested here.

selenium.runScript("
    function selectElementContents(el,start,end) { 
        var sel = window.getSelection(); 
        var range = window.document.createRange();     
        range.setStart(el,start); range.setEnd(el,end); 
        sel.removeAllRanges(); sel.addRange(range); 
    }     
    selectElementContents(window.document.getElementsByTagName("li")[4].firstChild,0,7);
");
Community
  • 1
  • 1
shamp00
  • 11,106
  • 4
  • 38
  • 81