I have the values in this variable
private String possibleTitleNames = "Sistem ,PC ,Desktop ";
When I go on my method like this:
checkPageTitle(driver, possibleTitleNames);
I want to check if a title contains one value from this String My method for this is here
public void checkPageTitle(WebDriver driver, String titles)
{
String[] items2 = titles.split(",");
String[] items1 =getRandomWayStringValues(items2);
items1 = titles.split(",");
for(int i=0;i<items2.length;i++){
boolean found = false;
for(int j=0;j<items1.length;j++){
if((items2[i].equals(items1[j]))){
found = true;
break;
}
}
if (found) {
Assert.assertTrue(items2[i],driver.getTitle().contains(items2[i]));
System.out.println(items2[i]);
} else {
System.out.println("Elements are not equals");
}
}
}
In String [] items1 I want to have these values shuffled and the method for this is right here
public String[] getRandomWayStringValues(String [] list){
String[] newValuesList = new String[] {"PC","Desktop","Sistem"};
List<String> strList = Arrays.asList(newValuesList);
Collections.shuffle(strList);
return newValuesList = strList.toArray(new String[strList.size()]);
}
My method works when the title contains the word "Sistem" but if I have a title with "Desktop" or "PC" it doesn't work and I think that the getRandom method doesn't do what I want to do