Compare string [] with string [closed]

-3

I tried this way:

IWebElement descriptionTextXPath = driver.FindElement(By.XPath("html/body/div[1]/div[1]/div[2]/div/ng-include[1]/section/ul/li[1]/div/div/article/h4"));
            String h4 = descriptionTextXPath.Text;
            Assert.AreEqual("Controle\n" + "Básico", h4);

Return:

Message:Assert.AreEqual.Failed
Expected:<Controle Básico>.Atual:<Controle Básico>

The purpose is to state that "Basic Control" exists on the screen. Here is the html structure where you are:

<h4 class="simulation-plan-name ng-binding">

Controle 
<span class="simulation-plan-type ng-binding">Básico</span>
</h4>

I tried to be as clear as possible, can you please help me?

    
asked by anonymous 10.09.2015 / 13:15

1 answer

2

Well, I still do not know if I can figure out what you need to do, but I assumed you wanted to compare the value you have in string with all values of array de string .

To do this, you must use the static string.Join() " to join all values of array to a string and then compare to the value that already is in string .

The method string.Join() gets first parameter the array values separator and second parameter the array whose values you want to "join".

string[] arrStr = {"Controle", "Básico"};
string str = "Controle Básico";
var str2 = string.Join(" ", arrStr);

if(str == str2)
    //Essa condição será verdadeira
    
11.09.2015 / 02:15