Reputation: 111
How do I click a i tag that is under a li tag?
The "li" would be the options displayed in this "ul" list, and the "i" is the checkbox of each "li" I need to click
What I tried:
IList<IWebElement> dropDownMenu = driver.FindElements(By.CssSelector("div.col-lg-6:nth-child(1) > ul:nth-child(1)"));
IList<IWebElement> selectmember = dropDownMenu[0].FindElements(By.TagName("i"));
var count = selectmember.Count;
if (count > 0)
{
selectmember[0].Click();
}
HTML code:
<li ng-repeat="s in servicePlans | orderBy:'name' | filter:filterServicePlans" ng-if="!($index % 2)" style="font-size: 12px; margin: 3px 0; min-height: 24px; list-style-type: none;" class="crop-long-text ng-scope">
<a href="javascript:;" style="text-decoration: none" class="font-dark" ng-click="clickService(s)">
<i class="fa fa-minus-square-o" ng-class="{ 'fa-square-o': s.checked == false, 'fa-check-square-o': s.checked, 'fa-minus-square-o' : s.checked == null }" style="margin-right: 5px;"></i>
<span class="ng-binding">To-Do (BPOS_S_TODO_1)</span>
</a>
</li>
Upvotes: 0
Views: 155
Reputation: 443
sGet directly to needed i element you can with this code
IWebElement selectmember = Driver.FindElement.By.XPath(".//ul[what attributes it have place here]//li[order number]//i")
Get an array of i elements to iterate click you can with this code
IWebElement[] selectmembers = Driver.FindElements.By.XPath(".//ul[attributes]//li//i").ToArray();
foreach(IWebElement q in selectmembers)
q.Click();
Upvotes: 1