I am trying to select an element from a list that will update fields upon a clicking outside of the list. The below code works if I only have one event (see picture)
Actions action = new Actions(driver);
EventGrid.FindElement(By.XPath("//div[contains(.,'" + nameToBeClicked + "')]")).Click();
// Forces a click outside element to fire the triggers
EventGrid.FindElement(By.XPath("//html")).Click();
But will not work when I have two events (notice there are two events in the picture now, one new event and the other called buffet breakfast). I pass in the event name to the method which does click the buffet breakfast from the drop down however the click to html only works with the above picture but not the below. Any ideas how to get around this?
Html of the list:
<div id="boundlist-1193" class="x-boundlist x-boundlist-floating x-layer x-boundlist-default x-border-box" tabindex="-1" style="right: auto; left: 100px; top: 97px; height: auto; width: 150px; z-index: 29001;" data-selenium-id="EventGrid-EventClassificationName-list">
<div id="boundlist-1193-listEl" class="x-boundlist-list-ct x-unselectable" style="overflow: auto; height: auto;" role="presentation">
<ul class="x-list-plain">
<li class="x-boundlist-item" unselectable="on" role="option">
<div>Buffet Breakfast</div>
</li>
<li class="x-boundlist-item" unselectable="on" role="option">
<div>NotMarkedAsPosted</div>
</li>
<li class="x-boundlist-item" unselectable="on" role="option">
<div>Package Afternoon Break</div>
</li>
<li class="x-boundlist-item" unselectable="on" role="option">
<div>Package Dinner</div>
</li>
<li class="x-boundlist-item" unselectable="on" role="option">
<div>Package Lunch</div>
</li>
<li class="x-boundlist-item" unselectable="on" role="option">
<div>Package Morning Break</div>
</li>
<li class="x-boundlist-item" unselectable="on" role="option">
<div>Party Hard</div>
</li>
<li class="x-boundlist-item" unselectable="on" role="option">
<div>Unassigned</div>
</li>
</ul>
</div>
</div>