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

Sending Text One Character at a time fails with "cannot convert from char to string"

I am trying to send a string one character at a time. When I try the code below it isn’t working. It says Argument 1: cannot convert from char to string. I know this is probably something simple I am not doing, I just can’t think of what it is.

    public void SelectUnit(string unitStr)
    {
        // Enter the text for the search
        new LufasWebManager().Stall(500);
        for (int i = 0; i < unitStr.Length; i++)
        {
            unitTxt.SendText(unitStr[i]);
            Thread.Sleep(10);
        }
        
        new LufasWebManager().Stall(2000);

        // Locate the correct result
        var unitSearchResult = driver.FindElement(By.XPath($"//lfs-search-results-drop-list/div/div/div[contains(text(), '{unitStr}')]"));

        // And then click it
        unitSearchResult.Click();
    }

It is not working when I try the unitStr[i].

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 :

cannot convert from char to string

So send a string:

unitTxt.SendText(unitStr[i].ToString());
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