-3
I tried so:
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 intention is to affirm that the "Basic Control" exists on the screen. It follows the html structure where it is:
<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 I could, can you please help me ?
I don’t understand what you want to buy. Put an example of what you tried and the expected result.
– Maniero
is like asking how to compare a
int[]
(ex:{1, 2, 3}
) with aint
(ex:1
). They can’t be compared, they’re different. You have to convert theint[]
in aint
, or the other way round.– dcastro
Ever tried to make a
String words = s.Split(' ').Join("");
and compare with thedescriptionTextXPath
?– Felipe Avelar
So I want to make an assertion and see if they’re exactly the same, "Basic Control" that’s on the screen and "Basic Control" that I created. But the assertion does not work. If the case, it is to leave two types equal String - String. How would I do that and what I would use to verify that the equality condition is true ?
– Anderson Alves
Here’s what I tried: Iwebelement h4element = 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 descriptionTextXPath = h4element.Text; String s = "Basic Control"; String[] words = s.Split(' '); I don’t know what I would use in this case, but I tried Assert.Areequals(words,descriptionTextXPath); But it didn’t work.
– Anderson Alves
If you want to make both guys equal
string
it makes no sense to makeString[] words = s.Split(' ');
.– Jéf Bueno
@Andersonalves please edit your question and put the code in it. In the comments it is practically impossible to understand.
– Jéf Bueno
I tried: String s = "Basic Control"; String words = s.Split(' '). Join("); Points out the following error: 'System.Array' does not contain a Definition for 'Join' and Extension method 'Join' Accepting of type 'System.Array' could be found (are you Missing a using Directive or an Assembly Reference ?) I tried to declare with using System.Array; .
– Anderson Alves
In short, I want to compare these two guys: String descriptionTextXPath = h4element.Text; String[] words = s.Split(' '); .
– Anderson Alves
The question is': how do you want to convert a string array to a string? If the string array is
{ hello, world }
, what should be the result? This is a question for you, not for us. So' you know how you want to make the comparison.– dcastro
String s = "Basic Control"; String[] words = s.Split(' '); Console.Writeline(words);
– Anderson Alves
Iwebelement h4element = 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 descriptionTextXPath = h4element.Text; Console.Writeline(descriptionTextXPath); String s = "Basic Control"; String[] words = s.Split(' '); foreach (string word in words) { Console.Writeline(word); } // Personal I put inside this foreach and turned to string the two values are equal "Basic Control" with line break. It remains to be seen how I compare now?
– Anderson Alves
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("Control n" + "Basic", H4);
– Anderson Alves