title: Using C# and Selenium, how do you select a SubMenu Item that is a hover link in IE?
body: <p>I have searched several topics on Stack Overflow and other sites for several days trying to find the solution for this with no luck. I have a website I am trying to automate using C# Selenium and can not get Webdriver to click on this sub menu item link. How do you use XPath or other solution to click on this sub menu item? </p>
  
  <p>You have to click on the Menu heading first to get the rest of the menu list to appear, then click on one of the options in the sub menu to get to the page. I am trying to click on "Ad Hoc POCNs" to display the sub menu item list which works fine using Webdriver Click() but then clicking on a sub menu item like "Create POCN by PO Number/Part Number" does not work.</p>
  
  <p>Here is the HTML:</p>
  
  <pre><code>    &lt;div id="WUC_Menu1_divMenu" style="WIDTH: 780px;height: 18px;"&gt;
  &lt;GDC:Menu userType="B" type="main" hilitecolor="white" hilitebgcolor="black" normalcolor="White" normalbgcolor="#713400" normalendbgcolor="Black" noframes="yes" xmlns:GDC="company website taken out"&gt;
      &lt;GDC:Menu type="horz" caption="Requisitions" href="" value="" normalbgcolor="#B58759"&gt;
          &lt;GDC:Menu useView="true" type="vert" caption="Create New Req" href="EditReq.aspx"/&gt;
          &lt;GDC:Menu useView="true" type="vert" caption="Unreleased Reqs" href="ListReqs.aspx?type=P&amp;amp;status=U&amp;amp;StartPage=N" mtype="P" status="U"/&gt;
          &lt;GDC:Menu useView="true" type="vert" caption="Reqs Awaiting Auto Conversion" href="ListReqs.aspx?type=P&amp;amp;status=A&amp;amp;StartPage=N" mtype="P" status="A"/&gt;
          &lt;GDC:Menu useView="true" type="vert" caption="Reqs Awaiting Other Approval" href="ListReqsAwaitingOtherApproval.aspx?type=P&amp;amp;status=I&amp;amp;StartPage=N" mtype="P" status="I"/&gt;
          &lt;GDC:Menu useView="true" type="vert" caption="Rejected Reqs" href="ListReqs.aspx?type=P&amp;amp;status=R" mtype="P" status="R"/&gt;
          &lt;GDC:Menu useView="true" type="vert" caption="Cancelled Reqs" href="ListReqs.aspx?type=P&amp;amp;status=C" mtype="P" status="C"/&gt;
          &lt;GDC:Menu useView="true" type="vert" caption="Converted Reqs" href="ListReqs.aspx?type=P&amp;amp;status=P" mtype="P" status="P"/&gt;
          &lt;GDC:Menu useView="true" type="vert" caption="Copy Latest Req" href="CopyLatestReq.aspx"/&gt;
          &lt;GDC:Menu useView="true" type="vert" caption="Replicate Req" href="ReplicateReq.aspx"/&gt;
      &lt;/GDC:Menu&gt;
      &lt;GDC:Menu type="horz" caption="Ad Hoc POCNs" href="" value="" normalbgcolor="#B58759"&gt;
          &lt;GDC:Menu useView="true" type="vert" caption="Create POCN by PO Number/Part Number" href="ListOpenPOs.aspx?CREATE=Y&amp;amp;POCN=Y"/&gt;
          &lt;GDC:Menu useView="true" type="vert" caption="Create New POCN" href="ListOpenPOs.aspx?POCN=Y"/&gt;
          &lt;GDC:Menu useView="true" type="vert" caption="Unreleased POCNs" href="ListReqs.aspx?type=C&amp;amp;status=U&amp;amp;StartPage=N" mtype="C" status="U"/&gt;
          &lt;GDC:Menu useView="true" type="vert" caption="POCNs Awaiting Auto Conversion" href="ListReqs.aspx?type=C&amp;amp;status=A&amp;amp;StartPage=N" mtype="C" status="A"/&gt;
          &lt;GDC:Menu useView="true" type="vert" caption="POCNs Awaiting Other Approval" href="ListReqsAwaitingOtherApproval.aspx?type=C&amp;amp;status=I&amp;amp;StartPage=N" mtype="C" status="I"/&gt;
          &lt;GDC:Menu useView="true" type="vert" caption="Rejected POCNs" href="ListReqs.aspx?type=C&amp;amp;status=R" mtype="C" status="R"/&gt;
          &lt;GDC:Menu useView="true" type="vert" caption="Cancelled POCNs" href="ListReqs.aspx?type=C&amp;amp;status=C" mtype="C" status="C"/&gt;
          &lt;GDC:Menu useView="true" type="vert" caption="Converted POCNs" href="ListReqs.aspx?type=C&amp;amp;status=P" mtype="C" status="P"/&gt;
      &lt;/GDC:Menu&gt;
      &lt;GDC:Menu type="horz" caption="AutoGen POCNs" href="" value="" normalbgcolor="#B58759"&gt;
          &lt;GDC:Menu useView="true" type="vert" caption="POCNs Awaiting Approver Selection" href="ListReqs.aspx?type=S&amp;amp;status=S&amp;amp;StartPage=N" mtype="C" status="S"/&gt;
          &lt;GDC:Menu useView="true" type="vert" caption="POCNs Awaiting Auto Conversion" href="ListReqs.aspx?type=S&amp;amp;status=H&amp;amp;StartPage=N" mtype="C" status="H"/&gt;
          &lt;GDC:Menu useView="true" type="vert" caption="POCNs Awaiting Other Approval" href="ListReqsAwaitingOtherApproval.aspx?type=S&amp;amp;status=SI&amp;amp;StartPage=N" mtype="C" status="SI"/&gt;
          &lt;GDC:Menu useView="true" type="vert" caption="Rejected POCNs" href="ListReqs.aspx?type=S&amp;amp;status=SR" mtype="C" status="SR"/&gt;
          &lt;GDC:Menu useView="true" type="vert" caption="Cancelled POCNs" href="ListReqs.aspx?type=S&amp;amp;status=SC" mtype="C" status="SC"/&gt;
          &lt;GDC:Menu useView="true" type="vert" caption="Converted POCNs" href="ListReqs.aspx?type=S&amp;amp;status=SP" mtype="C" status="SP"/&gt;
          &lt;GDC:Menu useView="true" type="vert" caption="ByPass AutoGen" href="ByPassAutoGenPOCN.aspx"/&gt;
          &lt;GDC:Menu useView="true" type="vert" caption="AUTO POCN Process Errors" href="ListAutoGenPOCNProcessErrors.aspx" mtype="S" status="AUTO"/&gt;
      &lt;/GDC:Menu&gt;
  &lt;/GDC:Menu&gt;
      &lt;/div&gt;
  </code></pre>
  
  <p>Here is my code:</p>
  
  <pre><code>//Click on the Ad Hoc POCNs to get the menu to appear and show sub menu options -- this works
  driver.FindElement(By.XPath("//*[text()='Ad Hoc POCNs']")).Click();
  
  //I am trying to click on Create POCN by PO Number/Part - this does not work
  driver.FindElement(By.XPath("//*[text()='Create POCN by PO Number/Part Number']")).Click();
  </code></pre>
  
  <p>I have also tried</p>
  
  <pre><code>driver.FindElement(By.CssSelector("[href*='ListOpenPOs.aspx?CREATE=Y&amp;amp;POCN=Y']")).Click();
  
  driver.FindElement(By.Name...
  driver.FindElement(By.Link...
  driver.FindElement(By.TagName...
  driver.FindElement(By.ID...
  driver.FindElement(By.ClassName...
  </code></pre>
  
  <p>The first click works fine. The second click does not work. I have tried XPath and a number of other OpenQA.Selenium.By.<strong>__</strong> to click on this sub menu link and nothing seems to work. I get the error "OpenQA.Selenium.Support.UI.UnexpectedTagNameException : Element should have been select but was menu" when trying using SelectElement. </p>
  
  <p>This HTML does not have the standard anchors and instead has GDC:Menu tags.</p>
  
  <p>I thought XPath was for finding elements in XML or XLST but I am seeing where other engineers using XPath for finding HTML elements. </p>
  
  <p>I have also tried Actions but maybe I am not getting my code right.</p>
  
  <p>Also maybe I just don't have the proper XPath expression to get to the sub menu item. </p>
  
  <p>Please help me find a solution by xpath or some other solution. </p>