'What to use for find exact word in selenium java while two words contains same characters?
I have to use switch case for this, I mean if the page contains "Ski" means it enters some value in text box if the page contains "Ski Boots" means it returns some value to text box now I have problem like if "Ski Boots" is displayed in the screen means it returns both the value of "Ski" and "Ski Boots". How to find exact value that returns only "Ski Boots" value to the text box.
Solution 1:[1]
You should check for Ski Boots first, then check for Ski:
List<String> inputs = Arrays.asList(new String[] {"Ski", "Ski Boots", "Ski Poles"});
for (String input : inputs) {
switch(input) {
case "Ski Boots":
System.out.println("input is Ski Boots");
break;
case "Ski":
System.out.println("input is Ski");
break;
default:
System.out.println("input is something else");
break;
}
}
This prints:
input is Ski
input is Ski Boots
input is something else
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Tim Biegeleisen |
