0% found this document useful (0 votes)
509 views

Selenium Webdriver Interview Questions and Answers by ITeLearn PDF

Uploaded by

AshishJaiswal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
509 views

Selenium Webdriver Interview Questions and Answers by ITeLearn PDF

Uploaded by

AshishJaiswal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 40
Pris 7 Aria ee Ta Ret) [email protected] Seen Tear ie +91-837-4323-742(India) iTALe arn Selenium Websriver interview Questions and Answers Chapter: 2 Topic: JUnit What Is JUnit? . It isa software testing framework to for unit testing. . It is written in Java and designed to test Java applications. . Itisan Open Source Software |. All of the above aeges Ans: d be How to Write a Simple JUnit Test Class? a. import org junit*; public class HelloTest { @Test public void testHello() { String message = "Hello World!"; ‘AssertassertEquals( 12, message.length()); y b. @Test public void testHello() { String message = "Hello World!"; ‘AssertassertEquals( 12, message.length()); } ¢. public class HelloTest { . public void testHello() String message = "Hello World!"; AssertassertE quals( 12, message.length(); ) d. None of the above Ans:a 3. Why Not Just Use a Debugger for Unit Testing? a. Debugger is designed for automation unit testing b. Debugger is designed for manual debugging ¢, Debugger can be used for unit testing 4. All of the above Ans: b Website: http://www.!TeLearn.com Emai [email protected] Contact: + 1-314-827-5272, +91-837-4323-742(India) iTALe arn Selenium Websriver interview Questions and Answers 4, Do You Need to Write a Test Class for Every Class That Need to Be Tested? a. Yes b. No Ans: b 5. How to create a Test Suite using JUnit in Eclipse? Select File > New > Other... > Java > JUnit > JUnit Test Suite. . Select the arrow of the button in the upper left of the toolbar. Select Other... > Java > JUnit > JUnit Test Suite, ¢, Right click on a package in the Package Explorer view in the Java Perspective, and select Other... > Java > JUnit > JUnit Test Suite, d. You can create a normal Java class, but include junit.framework.TestSuite as the super class of the test class you are creating. @. Allof the above Ans: 6. How to Run a JUnit Test Case in Eclipse? @. You can rightclick onthe test case class or testsuite class,and select.Run As > JUnit Test. b. Youcan selecta test(ase or suite and click:thearrow onthe icon or select Run from the toolbar, and select Run As > JUnit Test. ¢. Both 1 and 2 d. None ofthe above Ans: ¢ Chapter: 2 Topic: JUnit 4.ANTisa__ a. Build Tool Only For Java. b. b. Build Tools Only For .Net ¢. Alanguage d. Build Too! Ans: d Website: http://www.!TeLearn.com Email: [email protected] Contact: + 1-314-827-5272, +91-837-4323-742(India) iTALe arn Selenium Websriver interview Questions and Answers 2. How to make build directory in XML file? mkdir dir="$(dir.build}"> emakedir dir="${dit-build}"/> mkdir Dir="{dir.build}"/> None of the above eee Ans: ¢ 3. Which one are the properties of the Ant? a. Basedir b. Basedir ¢, Rootdir d. None of the above Ans: b 4. Which one is not a property of the Ant? @. antjava.version b. antversion ¢. antereate d. anthome Ans: 5. Which one is true method for message printing in xml file? a. printf b. printin ¢. echo d. None of the above Ans: ¢ 6. We can execute the class file with help of Ant? a, TRUE b. FALSE Ans: a Website: http://www.!TeLearn.com Email: [email protected] Contact: + 1-314-827-5272, +91-837-4323-742(India) iTALe arn Selenium Websriver interview Questions and Answers 7. What is Stand for is Ant VM? a, Account Virtual Machines b. Accountable Virtual Machines c. Amount able Virtual Machines d. All of the above Ans: b 8. How to set the Source directory in Ant? . ¢. d. None of the above Ans: ¢. 9. Ant can make directory with relative path? a. TRUE b. FALSE Ans: a 10. Which one Is the sign of path separator in Ant? a. be; ow. dt Ans: ¢ Chapter: 2 Topic: Basics of Core JAVA 1. What is Constructor? A constructor is a special method whose task is to initialize the object of its class Constructor is invoked whenever an object of its associated class is created It is special because its name is the same as the class name All of the above aeoe Ans: d Website: http://www.!TeLearn.com Email: [email protected] Contact: + 1-314-827-5272, +91-837-4323-742(India) iIALe arn Selenium Websriver interview Questions and Answers 2. Can constructor be inherited? a. Yes. b. No Ans: b 3. What are Access Specifies available in Java? Public Protected Default Private All of the above eaese Ans: e 4, Is delete , next, main, exit or null keyword in Java? a. Yes b. No Ans: b 5. What if you write Static public void instead of public static void? a. Program will not compile ib. Program will not run properly ¢, Program compiles and runs properly d. Syntax Error Ans: 6. What is the default value of the local variables? a. Local variables are not initialized to any default value b. Local variables are initialized to default value 0 c. Local variables are initialized to default value NULL d. None of the above b, Ans: a . 0 7. What will be the initial value of an object reference which is defined as an instance variable? 1 ©. a. . No initial value d. Null Ans: d Website: http://www.!TeLearn.com Email: [email protected] Contact: + 1-314-827-5272, +91-837-4323-742(India) iTALe arn Selenium Websriver interview Questions and Answers 8, What is the purpose of default constructor? a. Default constructor provides 0 to the objects b. Default constructor provides the default values to the objects c. Default constructor does nothing d. None of the above Ans: b 9. What is JVM? ‘@. Java virtual machine b. Provides runtime environment to execute java bytecode ‘¢. JVM is platform dependent d. All of the above Ans: d 10..What is the return type of the main method? ‘a. Main method doesn’t return anything hence declared void ib. It returns default value 0 ¢. It returns the value/of function called within it d. None of the above. Ansia 11. Is Java support pointer? TRUE b. FALSE Ans: a 12. Which is here class? . int a. b. integer c. float d. double Ans: b Website: http://www.!TeLearn.com Email: [email protected] Contact: + 1-314-827-5272, +91-837-4323-742(India) iTALe arn Selenium Websriver interview Questions and Answers 13, Size of char in Java? Ans: b 14, Is Java support multiple inheritance? a. FALSE b. TRUE Ans: a 15, Which two statements are reserved words in java? A.Run B. Import . Default D. implement a. BC b. AB <. AD 4. B,D Ans: a 16. Which will declare a method that forces a subclass to implement it? a. Public double methodx(); b. Static void methodx(double d1) {} ¢, Public native double methodx(); d. Abstract public void methodx(); Ans: d Website: http://www.!TeLearn.com Emai [email protected] Contact: + 1-314-827-5272, +91-837-4323-742(India) iTALe arn Selenium Websriver interview Questions and Answers 17. public class Foo { public static void main (string (] args) StringBuffer a = new StringBuffer ("A"); StringBuffer b = new StringBuffer ("B"); operate(a,b system.out.printin(a +"," + b); } static void operate (StringBuffer x, StringBuffer y) { x.append(y); yx; } } a. Code compiles and prints A bj Code\compiles and prints B ¢. Code compiles and prints AB d. None of the above Ansne 18. Which constructs a DataOutputStream? a. new dataOutputStream(new writer("out.txt”)); ib. new dataOutputStream(new FileWriter("out.txt)); ‘¢. new dataOutputStream(new OutputStream("out.txt"): d. new dataOutputStream(new FileOutputStream("out. txt" Ans: d 19. Which can be used to encodeChars for output? a. java.io. OutputStream b. java.io. QutputStreamWriter ¢. java.io.EncodeOutputStream d. jJava.io.EncodeWriter Ans: b Website: http://www.!TeLearn.com Emai [email protected] Contact: + 1-314-827-5272, +91-837-4323-742(India) iTALe arn Selenium Websriver interview Questions and Answers 20. class StaticDemo static int a = 42; static int b = 99; staticvoid ca||m System.outprintin("a = "+ a); class StaticByName{ public static void main(String args[]){ StaticDemo.caljme(); System.outprint|n("b =" + StaticDemo~b); a a=42 b=99 b. a=99. b=42 c. a=88. b=99 d. None of the above 21 Which of these not associated Java? a. exception b. extern ¢. extends d. error Ans: 22. Collection interface found in which package? a. java.iang b. java.io c. java.util d. java.net Ans: ¢ 23. Hashcode method must be used with which method? a. init() b. service() ‘c. finally) d. equals() Ans: d Website: http://www.!TeLearn.com Emai [email protected] Contact: + 1-314-827-5272, +91-837-4323-742(India) iTALe arn Selenium Websriver interview Questions and Answers 24, Wait, notify, notify belongs to which class? a. thread b. object c. object class d. None of the above Ans: b 25. Java supports which code? a. ascii b. ebedic ¢, Unicode d. Grey Ans: ¢ 26, Static Keyword associated with 27. Which structure used for synchronization? a. hash table b. array list c. array d. All of the above Ans: 28. Which structure store unique element? a b <. set 4. stringbuffer Ans: ¢ Website: http://www.!TeLearn.com Emai [email protected] Contact: +1-314-827-5272, +91-837-4323-74 (India) iTALe arn Selenium Websriver interview Questions and Answers Chapter: 1 To) Selenium IDE Basics 1. What is Selenium IDE? ‘@. Selenium IDE (Integrated Development Environment) is an ideal tool used to develop selenium test scripts. Which allows us to record user actions on browser window It operates as a Mozilla Firefox add on and provides an easy to use interface for developing and running individual test cases or entire test suites d. An open source functional automation tool e. All of the above eg Ans: e 2. How"do youlopen/start selenium-ide after installation ? ‘a. Goto Start > All Programs > Selenium IDE b. First launch/open firefox browser and then click on ‘Tools’ tab in the menu bar and click Selenium IDE, ‘¢. Click Shortcut option on the Desktop d. None of the above: Ans: b 3. Features of selenium IDE _ a. Its main feature is record and playback b identifies element using id, name, xpathetc c. Ithas an option of asserting title of every page automatically d. It has a feature of exporting testcase/suite into different formats like C#, Java, Ruby, Python @. All of the above Ans: @ 4, Selenium IDE runs in ___ browser ‘Chrome 1E8 Safari Firefox Netscape lp pep Website: http://www.!TeLearn.com Email: [email protected] Contact: + 1-314-827-5272, +91-837-4323-742(India) iTALe arn Selenium Websriver interview Questions and Answers 29. You can use date related function in which package in Java? a, java.util b. java.io «. javalang 4. All of the above Ans: a 30. Which is true about thread in Java? a. Thread share the address space b. Thread can be created by extending thread class ¢. Thread is a lightweight class 4. Allof the above Ans: d Chi To Unit annotations 1. Theannotation _ identifies that a method is a test method a. @Before b. @Test ¢. @After 4. @Ignore Ans: & 2.___will execute the method before each test. a. @Before b. @Test « @Atter 4. @Atter Class Ans: a iz will execute the method after each test. a. @Before b. @Atter Class « @Test d. @After Ans: d Website: http://www.!TeLearn.com Email: [email protected] Contact: + 1-314-827-5272, +91-837-4323-742(India) iTALe arn Selenium Websriver interview Questions and Answers 4, @ Test (timeout=100), what is the significance of this statement? a 5. will execute the method once, before the start of all tests. Pass, if the method takes longer than 100 miliseconds Same as @Test Fails, if the method takes longer than 100 miliseconds. None of the above aoge ns: ¢ a. @Before b. @Before Class ¢. @Atter d. @Test Ans: & 6. will execute the method once, after all tests have finished. 2. @Alter Class b. @Before Class &. @After 4, @lgnore Ans: a Chapter: 4&5 & DATA Driven Does Selenium support Data Driven Framework? No Only supports Modular framework Yes ‘Only supports Keyword driven framework None of the above paoge Ans: ¢ Barge .In__ approach tests can be executed multiple sets of test data Data Driven Framework Modular Framework Keyword Driven Framework Hybrid Framework Website: http://www.!TeLearn.com Email: [email protected] Contact: + 1-314-827-5272, +91-837-4323-742(India) iTALe arn Selenium Websriver interview Questions and Answers 3. What is the basic approach of Data Driven Framework? a. Code and Data as a single unit b. Code and Data as a separate units ¢. None of the above Ans: b 4, Which statement is correct to create excel automation object using POI excel API? a. File myx! == new File (excel path>) b, File myxl =File () ¢ myxl = new File () 4d. File myx! =new File () Ans: d 5. = ‘ut the correct option to open a excel file for read. . File myx! = new File ().Selected() driver-findElement(By.id( <>)-isSelected() driver-findElement(By id(<>).isChecked() All of the above aege Ans: b 6. Can Selenium handle Alerts or Pop ups windows? a. Yes. b. No Ans: a 7. What is getWindowHandle method? a. Method will help to handle parent window b. Method will help to handle of opened windows other than parent <, Only handles alert d. None of the above Ans: b Website: http://www.!TeLearn.com Email: [email protected] Contact: + 1-314-827-5272, +91-837-4323-742(India) iTALe arn Selenium Websriver interview Questions and Answers 10, We use __(for firefox) to identify elements a. Object Spy b. HTML DOM cc. Xpath 4. Firebug Ans: d 11. What is selenese ? ‘@. Selenium set of commands b. A type of language ‘¢. Scripting language d. All of the above Ans: 12.___ is used when the expected value is mandatory to continue with next set of steps a, Verify 'b. Wait For Text G. Assert d. Verify Text Ans:c 13,___ is used when the expected value is optional t6 continuéWith the next set of steps a. Verity b. Assert cc. Verify Text d. Wait For Text Ans: a 14, Can tests recorded using Selenium IDE be run in other browsers? a. Yes. b. No Ans: a Website: http://www.!TeLearn.com Emai [email protected] Contact: + 1-314-827-5272, +91-837-4323-742(India) iTALe arn Selenium Websriver interview Questions and Answers 8, How to handle alert using selenium? a. driver.switchto.popup() b. driver.switchto «. driver.switchto.alert() 4. None of the above Ans: ¢ 9. What is lterator? a. Iterator enables you to cycle through a collection, obtaining or removing elements b. It basically starts at the beginning ofa collection . When you want to know which things are in a certain collection, you iterate over the collection, which is just another term for going through all elements. This is what an Iterator does d._ All of the above. Ans: d 10. After the popup actions, how to switch the driver back to the parent window? a) browser.switehTo().window(parentWindowHandle); b. browser.switehTo(alert(); Both1 &2 d. None of the above: Website: http://www.!TeLearn.com Email: [email protected] Contact: + 1-314-827-5272, +91-837-4323-742(India) iTALe arn Selenium Websriver interview Questions and Answers 15. What kind of application is the Selenium IDE? a. Windows Application b. Web application ¢. Firefox add-on d. None of the above Ans: ¢ 16. A Selenium IDE test case has three columns, Command, Target and Value. What data is stored In the Target column? a. Element or location where the command Is executed b. Test step execution result ‘¢. [Optional] purpose of the test step d. None of the above Ans: a 17. By default, in which format does the Selenium IDE save a test case? a In proprietary format b. As HTML . As Java source code d. As Ruby or Python or C# code depending on user options selected during installation Ans: b 18, What features are available in Selenium IDE to debug an automated test case? a. Toggle Breakpoint b. Pause/ Resume c. Step d. All of the above Ans: d 19. What is the Selenium print command? a. echo b. print e. alert d. System.out.printin() Ans: 1 Website: http://www.!TeLearn.com Email: [email protected] Contact: + 1-314-827-5272, +91-837-4323-742(India) iTALe arn Selenium Websriver interview Questions and Answers 20. What Is the difference between a command and the same command with "AndWait" (e.g. click and clickAndWait commands)? a. Selenium waits indefinitely for the result of the “AndWait” command. b. It waits for the result of the "AndWait” command but only for 30 seconds (default timeout). ¢. Itwaits for the result of the "AndWalt" command but only up to a maximum of 30 seconds (default timeout). d. Some commands do not have an "AndWait" command, so this question is incorrect. Ans: ¢ 21. What is the correct syntax to access the value of a Selenium variable called name? a. name b. $name ¢, {name} d. ${name} Ansid 22. In which associative array does Selenium store all of a test case's variables and their respective values? . Array storedVars var There is no such array in Selenium aere Ans: b 23. Where can you create your own Selenium commands? a. This is not possible. b. In user-extensions.js file ¢. Inany JavaScript file, but the preferred name is user-extensions.|s for consistency d. In any Java, C#t, Python, Ruby, PHP or Perl file Ans: ¢ Website: http://www.!TeLearn.com Email: [email protected] Contact: + 1-314-827-5272, +91-837-4323-742(India) iTALe arn Selenium Websriver interview Questions and Answers 24, What is the purpose of the Find button? a, Highlight the element that is given in the locator b. Search the appropriate command for the given target ¢, Find the current value of the target d. None of the above Ans: a 25. Why are relative XPaths preferred over absolute XPaths as locators? a. For non-root elements, absolute XPaths are longer and slow down the test automation. b. Absolute XPaths fail if any part of the path changes even slightly. cc. Relative XPaths are the default in Selenium. d. None of the above Ans: b 26. What is the best way to handle asynchronous data rétrie val fromithe server as in/AJ AX applications? a. Run the test case at the slowest speed. b. Use the pause command. ¢. Use the “AndWait" commands. d. Use the “waitFor” commands. Ans: d 27. What happens when the application creates a JavaScript alert during test case play? a. Thealert is suppressed by Selenium. b. If there is no command to handle the alert, the play is stopped with an error. c. If the alert is handled with assertAlert, assertAleriP resent or verifyAlert, no alert is displayed and there is no error. d. All of the above Ans: d Website: http://www.!TeLearn.com Email: [email protected] Contact: + 1-314-827-5272, +91-837-4323-742(India) iTALe arn Selenium Websriver interview Questions and Answers Chapter: 2 Topic: Selenium RC 4, What is Selenium RC? Selenium RC starts up browsers(one at a time) and then runs commands we pass along from our tests b. Itallows us to use a programming language for maximum flexibility and extensibility in developing test logic ¢. Itprovides an API and library for each of its supports languages like Java, Ruby, Python, Perl and C# d. All of the above Ans:d 2. Selenium RC components are _ a, Selenium server b. Client libraries . Selenium Grid d. Both 1&2 Ans: d 3. Selenium Server launches and kills browser a. TRUE b. FALSE Ans: a 4. provide the interface between each programming language and the Selenium RC sei 3 ‘Selenium RC Client libraries Selenium Server None of the above Ans: 5, Why selenium RC is used 2 Used to automate web applications with more effective browser actions when compared to Selenium IDE We can handle multiple windows and pop-ups, we can use loops and conditions, capturing screenshot etc RC can perform Data-Driven (read/write data from external files) concept, decent report generation and mailing All of the above a 9 ¢ 952 pegs Ans: d Website: http://www.!TeLearn.com Email: [email protected] Contact: + 1-314-827-5272, +91-837-4323-742(India) iTALe arn Selenium Websriver interview Questions and Answers 6. What are the languages and operating systems that support RC ? a, Java b. CH cc. Perl d. Python . Allof the above Ans: e 7. Sleep() method is used __ a. To pause the test execution until the time provided in sleep method b. To stop the test c. To set the time of delay which will follow each and every selenium command d. None of the above Ans: a 8. Haw do you select second value from a drop down menu? ‘a. String af]=selenium.getSelect Options(locatar of drop down); selenium. select("locator of drop down", a[2]); ibs» selenium.select("locator of drop down", "value); ¢. String af]=selenium.getSelectOptions(locator of drop down); selenium.select("locator of drop down", a[1]) d. None of the above Ans: e 9, What are the frameworks available inRC ? a. JUnit b. NUnit c. TestNG d. Bromine e, All of the above Ans: e 10. How do you run selenium commands in slow motion in Selenium RC? Thread. Sleep Selenium.SetSpeed wait() Both1 &2 aeoe Ans: d Website: http://www.!TeLearn.com Email: [email protected] Contact: + 1-314-827-5272, +91-837-4323-742(India)

You might also like