Untitled

mail@pastecode.io avatar
unknown
csharp
a month ago
670 B
2
Indexable
Never
public bool IsSessionShownInList(string sessionName)
{
    try
    {
        IWebElement listViewContainer = Driver.FindElement(By.Id("listViewContainer"));
        IEnumerable<IWebElement> sessionList = GetListViewDisplayedRows();

        return SessionExists(sessionList, sessionName);
    }
    catch (NoSuchElementException)
    {
        // Handle NoSuchElementException if needed
    }

    return false;  // No matching session found
}

// Separate method to check if the session exists in the list
private bool SessionExists(IEnumerable<IWebElement> sessionList, string sessionName)
{
    return sessionList.Any(session => session.Text.Contains(sessionName));
}
Leave a Comment