title: Xpath / Selenium - How do I grab all of the options in a <select>, excluding the default, given a simple dom?
body: <p>Working on an automation test using codeceptjs/selenium, I need to read the text of the nodes of a select drop down without knowing what they will be ahead of time and excluding the greyed out default option (since the app will not function until a choice is made).</p>
  
  <pre><code>&lt;select id="itemname1"&gt;
   &lt;option class="greydefault"&gt;How Many?&lt;/option&gt;
   &lt;option&gt;6&lt;/option&gt;
   &lt;option&gt;8&lt;/option&gt;
   &lt;option&gt;10&lt;/option&gt;
   &lt;option&gt;12&lt;/option&gt;
  &lt;/select&gt;
  &lt;select id="itemname2"&gt;
   &lt;option class="greydefault"&gt;What Type?&lt;/option&gt;
   &lt;option&gt;a&lt;/option&gt;
   &lt;option&gt;b&lt;/option&gt;
   &lt;option&gt;c&lt;/option&gt;
   &lt;option&gt;d&lt;/option&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>Given the above simple dom, question is how to write an xpath that grab all 4 of the option nodes that contain 6 8 10 and 12. And another xpath that returns all 4 of the option nodes a b c and d. </p>
  
  <p>Here are my attempts that don't work for me:</p>
  
  <pre><code>.//option/preceding::option[text()="What Type?"]/following::option[text()="How Many?"]
  
  .//option/following::option[text()="How Many?"]/preceding::option[text()="What Type?"]
  
  
  .//option/preceding::option[text()="What Type?"] and following::option[text()="How Many?"]
  
  
  .//option/[preceding::option[text()="What Type?"] and following::option[text()="How Many?"]]
  </code></pre>
  
  <p>The first 2 attempts returns only the node "How many" for me, and the next attempts are invalid.</p>
  
  <p>The output of the xpath query should return each option node other than the default node.</p>
  
  <p>That xpath is put into a function that reads the texts of the nodes, it looks like this:</p>
  
  <pre><code>  getElementsText(locator) {
      let driver = this.helpers.Protractor.browser;
      return driver.element.all(locator).getAttribute("textContent").then((result) =&gt; {
        return result.toString().split(',');
      });
    }
  </code></pre>