Ques : write CSS Selector for the above buttons
<td>
<button class ="gwt-button" type="button">Clone</button>
</td>
<td>
<button class ="gwt-button" type="button">Cancel</button>
</td>
Ans :
driver.findElement(By.cssS elector (".gwt-button "));
Ques : How to switch to frame in Selenium Webdriver
Ans :driver.switchTo().frame( driver.findElement(By.tagName( "iframe")));
Ques : How to select the CEO from the drop down ?
code to select from drop down
<html>
<body>
<select id = "designation">
<option value = "MD">MD</option>
<option value = "prog"> Programmer </option>
<option value = "CEO"> CEO </option>
</option>
</select>
<body>
</html>
Ans :
new Select (driver.findElement(By.id(" designation"))). selectByVisibleText("CEO");
QUES : is the below code is correct ?
interface A
{
}
interface B
{
}
class C implements A, B
{
}
Ans : Yes above code is correct and it will compile and run without giving any error.
QUES : count the occurences of every word
String s ="abbcccddddeeeggghhdsdsda";
Ans :
Program for count occurences of every charactor
*************
public class CountSimilarWordInString { AA
@Test
public void count(){
String str="abbcccddddeeeggghhdsdsda" ;
//Creating a HashMap containing char as a key and occurrences as a value
HashMap<Character,Integer> charcount=new HashMap<Character,Integer>();
//Converting given string to char array
char[]strArry=str.toCharArray( );
//checking each char of strArray
for(char c:strArry){
if(charcount.containsKey(c)){
//If char is present in charCountMap, incrementing it's count by 1
charcount.put(c, charcount.get(c)+1);
}else{
//If char is not present in charCountMap,
//putting this char to charCountMap with 1 as it's value
charcount.put(c,1);
}
}
//Printing the value
System.out.println("value of string:"+charcount);
}
}
***************************
Output : value of string:{g=3, d=7, e=3, s=2, b=2, c=3, a=2, h=2}
No comments:
Post a Comment