title: How do I click the li tag inside ul with Selenium?
body: <p>HTML:</p>
  
  <pre><code>&lt;div class="hdetSelect right moreRooms" style=""&gt;
  &lt;select class="bookedRoom_1 perSelector xsmall number-room-booked_fbc1336de4c882dd" ref="1" id="selectRoomBooked_1" style="display: none;"&gt;
     &lt;option value="0"&gt;0&lt;/option&gt;
     &lt;option value="1"&gt;1&lt;/option&gt;
     &lt;/select&gt;
  &lt;div class="nsSelect-container search-num-selector left"&gt;
     &lt;input class="nsSelect-input bookedRoom_1 perSelector xsmall number-room-booked_fbc1336de4c882dd" type="text" style="display: inline-block;"&gt;
     &lt;div class="nsSelect-opt-container search-num-selector left rounded5 hide" style="top: 696.8px; left: 875px; display: none;"&gt;
     &lt;ul&gt;
     &lt;li class="clear" style="display: block; width: 27px;"&gt;
     &lt;a href="#" ref="0" class=""&gt;0&lt;/a&gt;
     &lt;/li&gt;
     &lt;li style="display: block; width: 27px;"&gt;
     &lt;a href="#" ref="1" class="active"&gt;1&lt;/a&gt;
     &lt;/li&gt;&lt;/ul&gt;
     &lt;a class="nsSelect-close"&gt;Cancel&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;
    &lt;span class="dRoom"&gt;Room&lt;/span&gt; 
  &lt;/div&gt;
  </code></pre>
  
  <p>I'm trying to click an li inside a ul using XPath or <code>cssSelector</code>, but I always get the error "no such element: Unable to locate".</p>
  
  <p>Here's what I'm trying with:</p>
  
  <p>With JavaScript executor with <code>cssSelector</code>:</p>
  
  <pre><code>WebElement room_num = driver.findElement(By.cssSelector("div.room-list-item:nth-child(1)&gt; div:nth-child(1)&gt; div:nth-child(4)&gt; div:nth-child(2)&gt; div:nth-child(2)&gt; ul:nth-child(1)&gt; li:nth-child(2)&gt;a"));
  executor.executeScript("arguments[0].click();",room_num);
  </code></pre>
  
  <p>With XPath :</p>
  
  <pre><code>driver.findElement(By.xpath("//*[@id='room-list']/div[1]/div[1]/div[2]/div/div/ul/li[2]/a")).click();
  </code></pre>
  
  <p>I want to select/click(UI) li with innerHTML 1 ,but nothing seems to work. I'm running out of ideas so please do leave feedback or maybe solution.</p>