-1

Problem: Hi Guys, I'm testing a CMS tool using selenium c# but problem is to find a selector for a tiny drop down button because of random ID(all selectors). While it is generating HTML codes but i can not take the help of it as the next time when script runs it changes the IDs (Class name and all other identifiers).

Tried : i tried storing Xpaths of all drop down button on page in an array and next time clicking on the array position of the element but it didnt store any element xpath in array.

please suggest what can i do in this case, possibly its a case of java script enabled page.

HTML Code of element:

<span class="epi-extraIcon epi-pt-contextMenu epi-iconContextMenu" role="presentation" title="Display menu" data-dojo-attach-point="iconNodeMenu" _dijitmenuuniqname_51_43="1"/>
alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
Pankaj Dubey
  • 279
  • 2
  • 18

1 Answers1

1

Recently I used selenium in C# and had a few problems like that.

My solution was to use XPath.

I inspected the elements that I needed with firebug (on Mozilla Firefox) to get the Xpath.

After that, I used HtmlAgilityPack nuget to load the page source and select the nodes and then I was able to get the elements.

I also disabled the JQuery animations of the page to avoid some problems.

So, my code for the selection of the nodes was something like that:

var document = new HtmlDocument();

            document.LoadHtml(pageSource);

            var htmlLoaded = DocumentParsing(document.DocumentNode.SelectNodes(
                "/html/body/table[2]/tbody/tr/td/table[2]/tbody/tr/td[1]/font[2]/b[1] |" +
                "/html/body/table[2]/tbody/tr/td/table[2]/tbody/tr/td[1]/font[2]/b[2]));

And my code for disable JQuery animations:

 try
            {
                var js = DriverService as IJavaScriptExecutor;
                js.ExecuteScript("$.fx.off = !$.fx.off;");

                return true;
            }
            catch (Exception)
            {
                return false;
            }

Hope that helps.