Real Time Automation Interview Questions - Part 6
In continuation with the latest series of Real Time Automation Interview Questions, we present you the part 6 of the course structure. Click on below links for previous parts.
Real Time Automation Interview Questions - Part 6
- What are different types of Annotations used in Cucumber?
- Total 11 Annotations - Feature, Scenario, Background, given, when , then, and, but, example, scenario outline, scenario template.
- What are Hashmap and HashSet?
- HashMap and HashSet both are one of the most important classes of Java Collection framework. ... HashMap Stores elements in form of key-value pair i.e each element has its corresponding key which is required for its retrieval during iteration. HashSet stores only objects no such key value pairs maintained.
- Links : https://www.geeksforgeeks.org/difference-between-hashmap-and-hashset/ https://www.javatpoint.com/difference-between-hashset-and-hashmap
- Where do you use a Hashmap?
- Maps are used for when you want to associate a key with a value and Lists are an ordered collection. Map is an interface in the Java Collection Framework and a HashMap is one implementation of the Map interface.
- HashMap are efficient for locating a value based on a key and inserting and deleting values based on a key.
- HashMap map = new HashMap<>();.
- Example :
- // Add elements to the map map.put("vishal", 10);
- map.put("sachin", 30);
- map.put("vaibhav", 20);
- // Print size and content System.out.println("Size of map is:- "+ map.size()); System.out.println(map);
- // Check if a key is present and if present, print value
- if (map.containsKey("vishal"))
- { Integer a = map.get("vishal");
- System.out.println("value for key"+ " \"vishal\" is:- " + a);
- How do you handle if XPATH is changing dynamically?
- Option 1: Look for any other attribute which Is not changing every time In that div node like name, class etc. So If this div node has class attribute then we can write xpath as below.
- //div[@class='post-body entry-content']/div[1]/form[1]/input[1]
- Option 2: We can use absolute xpath (full xpath) where you do not need to give any attribute names In xpath. /html/body/div[3]/div[2]/div[2]/div[2]/div[2]/div[2]/div[2]/div/div[4]/div[1]/div/div/div/div[1]/div/div/div/div [1]/div[2]/div[1]/form[1]/input[1]
- Option 3: We can use starts-with function. In this xpath's ID attribute, "post-body-" part remains same every time.
- //div[starts-with(@id,'post-body-')]/div[1]/form[1]/input[1]
- Option 4: We can use contains function. Same way you can use contains function as Above //div[contains(@id,'post-body-')]/div[1]/form[1]/input[1]
- Does Jenkins require a local system for CI?
- It is a server-based application and requires a web server like Apache Tomcat
- When finally block gets executed?
- The finally block always executes when the try block exits. This ensures that the finally block is executed even if an unexpected exception occurs.
- How many times you can write catch block?
- maximum one catch block will be executed. Yes, we can write multiple catch block but only one is executed at a time.
- What is maven architecture and explain pom.xml?
- POM is an acronym for Project Object Model. The pom.xml file contains information of project and configuration information for the maven to build the project such as dependencies, build directory, source directory, test source directory, plugin, goals etc. Maven reads the pom.
- How do you handle alert in selenium webdriver?
- Simple alert(one option), Confirm Alert(Y/N), Prompt alert(enter any value)
- Alert a= driver.switchTo().alert();
- a.getText();
- a.accept();
- a.dismiss();
- a.sendKeys(“name”);
- How to handle iFrames in Selenium Webdriver?
- driver.switchTo().frames(via index value, name, webelement);
- driver.findElement(by.id(“value”)).getText();
- driver.switchTo().defaultContent();-To get back from iframe
Comments
Post a Comment