Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

assert list string having URL contains sub-string using C#

I am trying to assert list of string that contains URL extracted from href attributes of elements using Selenium C#. Below is my code and when i am running its given false.

    public static void Main()
    {
        List<string> urlList = new List<string>();

    // Adding elements to List
    urlList.Add("https://www.google.com");
    urlList.Add("/app/facebook");
    urlList.Add("https://www.gmail.com");
        
    // Checking whether string is present
    // in List or not
    Console.Write(urlList.Contains("google"));
    }

OUTPUT: False

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

try this

Console.Write(urlList.Any(x => x.Contains("google")));
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading