1. What are the annotations used in TestNG?


@Test, @BeforeSuite, @AfterSuite, @BeforeTest, @AfterTest, @BeforeClass, @AfterClass,
@BeforeMethod, @AfterMethod

2. How do you read data from excel?


FileInputStream fis = new FileInputStream (“path of excel file”);
Workbook wb = WorkbookFactory.create (fis);
Sheet s = wb.getSheet (“sheetName”)
String value = s.getRow (rowNum).getCell (cellNum).getStringCellValue ();

3. What is the use of xpath?


It is used to find the WebElement in web page. It is very useful to identify the dynamic web elements.

4. What are different types of locators?


There are 8 types of locators and all are the static methods of the By class.

• By.id ()
• By.name ()
• By.tagName ()
• By.className ()
• By.linkText ()
• By.partialLinkText ()
• By.xpath
• By.cssSelector ()
5. What is the difference between Assert and Verify?


Assert it is used to verify the result. If the test case fails then it will stop the execution of the test case there itself and move the control to another test case.

Verify it is also used to verify the result. If the test case fails then it will not stop the execution of that test case.
 6. What is the alternate way to click on login button?>


Use submit () method but it can be used only when attribute type=submit.
 7. How do you verify if the checkbox/radio is checked or not?


We can use isSelected () method.
Syntax –

driver.findElement (By.xpath (“xpath of the checkbox/radio button”)).isSelected ();

If the return value of this method is true then it is checked else it is not.
 8. How do you handle alert popup?


To handle alert popup, we need to 1st switch control to alert popup then click on ok or cancel then move control back to the main page.

Syntax:

String mainPage = driver.getWindowHandle ();
Alert alt = driver.switchTo ().alert (); // to move control to alert popup
alt.accept (); // to click on ok.
alt.dismiss (); // to click on cancel.
//Then move the control back to main web page
driver.switchTo ().window (mainPage); → to switch back to main page.

9. How do you launch IE/chrome browser?


Before launching IE or Chrome browser we need to set the System property.

//To open IE browser

System.setProperty (“webdriver.ie.driver”,”path of the iedriver.exe file”);

Web Driver driver = new InternetExplorerDriver ();
//To open Chrome browser → System.setProperty (“webdriver.chrome.driver”,”path of the chromeDriver.exe file”);
WebDriver driver = new ChromeDriver ();

 10. How to perform right click using WebDriver?



Use Actions class

Actions act = new Actions (driver); // where driver is WebDriver type
act.moveToElement(WebElement).perform();
act.contextClick ().perform ();

 11. How do perform drag and drop using WebDriver?


Use Action class

Actions act = new Actions (driver);
WebElement source = driver.findElement (By.xpath (“”)); //source ele which you want to drag
WebElement target = driver.findElement (By.xpath (“”)); //target where you want to drop
act.dragAndDrop(source, target).perform();

 
12. Give the example for method overload in WebDriver.


Frame (string), frame (int), and frame (WebElement).

13. How do you upload a file?


To upload a file we can use sendKeys() method.

driver.findElement (By.xpath (“input field”)).sendKeys (“path of the file which u want to upload”);

14. How do you click on a menu item in a drop down menu?


If that menu has been created by using select tag then we can use the methods selectByValue () or selectByIndex () or selectByVisibleText (). These are the methods of the Select class.

If the menu has not been created by using the select tag then we can simply find the xpath of that element and click on that to select.
15. How do you simulate browser back and forward?


Driver. Navigate ().back ();
Driver. Navigate ().forward ();

16. How do you get the current page URL?


driver.getCurrentUrl ();

17. What is the difference between ‘/’ and ‘//’?


// It is used to search in the entire structure.
/ It is used to identify the immediate child.
18. What is the difference between find Element and find Elements?


Both methods are abstract method of WebDriver interface and used to find the WebElement in a web page. Find Element () – it used to find the one web element. It return only one WebElement type.
FindElements () it used to find more than one web element. It returns List of WebElement.
19. How do you achieve synchronization in WebDriver?


We can use implicit wait.

Syntax:

driver.manage ().timeouts ().implicitly Wait (10, TimeUnit.SECONDS);

Here it will wait for 10sec if while execution driver did not find the element in the page immediately. This code will attach to each and every line of the script automatically. It is not required to write every time. Just write it once after opening the browser.
20. Write the code for Reading and Writing to Excel through Selenium?


FileInputStream fis = new FileInputStream (“path of excel file”);
Workbook wb = WorkbookFactory.create (fis);
Sheet s = wb.getSheet (“sheetName”);
String value = s.getRow (rowNum).getCell (cellNum).getStringCellValue (); // read data
s.getRow (rowNum).getCell (cellNum).setCellValue (“value to be set”); //write data
FileOutputStream FOS = new FileOutputStream (“path of file”);
wb.write (FOS); //save file

21. How to get typed text from a textbox?


Use get Attribute (“value”) method by passing arg as value.
String typedText = driver.findElement (By.xpath (“xpath of box”)).get Attribute (“value”));

22. What are the different exceptions you got when working with WebDriver?


• ElementNotVisibleException
• ElementNotSelectableException
• NoAlertPresentException
• NoSuchAttributeException
• NoSuchWindowException
• TimeoutException
• WebDriverException

23. What are the languages supported by WebDriver?


Python, Ruby, C# and Java are all supported directly by the development team. There are also WebDriver implementations for PHP and Perl.

24. How do you clear the contents of a textbox in selenium?


Use clear () method.

driver.findElement (By.xpath (“xpath of box”)).clear ();

 
25. What is a Framework?


A framework is set of automation guidelines which help in Maintaining consistency of Testing, Improves test structuring, Minimum usage of code, Less Maintenance of code, Improve reusability, Non Technical testers can be involved in code, a Training period of using the tool can be reduced, Involves Data wherever appropriate.

There are five types of the framework used in software automation testing:

• Data Driven Automation Framework
• Method Driven Automation Framework
• Modular Automation Framework
• Keyword Driven Automation Framework
• Hybrid Automation Framework, it‟s basically a combination of different frameworks. (1+2+3).

26. What are the prerequisites to run selenium WebDriver?


JDK, Eclipse, WebDriver (selenium standalone jar file), browser, application to be tested.

27. What are the advantages of selenium WebDriver?


a) It supports with most of the browsers like Firefox, IE, Chrome, Safari, Opera etc. b) It supports with most of the language like Java, Python, Ruby, C# etc.

b) Doesn‟t require to start the server before executing the test script.
c) It has actual core API which has binding in a range of languages. d) It supports of moving mouse cursors.
e) It supports to test iPhone/Android applications.

28. What is WebDriverBackedSelenium?


WebDriverBackedSelenium is a kind of class name where we can create an object for it as below:

Selenium WebDriver= new WebDriverBackedSelenium

(WebDriver object name, “URL path of website”)

The main use of this is when we want to write code using both WebDriver and Selenium RC, we must use above-created object to use selenium commands.

29. How to invoke an application in WebDriver?


driver. get (“url”); or driver. Navigate ().to (“url”);

 
30. What is Selenium Grid?


Selenium Grid allows you to run your tests on different machines against different browsers in parallel. That is, running multiple tests at the same time against different machines, different browsers, and operating systems.
Essentially, Selenium Grid support distributed test execution. It allows for running your tests in a distributed test execution environment.
31. How to get the number of frames on a page?


ListframesList=driver.findElements(By.xpath(“//iframe”));
int numOfFrames = frameList.size ();

32. How do you simulate scroll down action?


JavaScript Executor jsx = (JavaScript Executor) driver;
jsx.executeScript (“window.scrollBy (0, 4500)”, “”); //scroll down, value 4500 you can change as per your req
jsx.executeScript (“window.scrollBy (450,0)”, “”); //scroll up
public class Scroll Down {
public static void main (String[] args) throws Interrupted Exception {
WebDriver driver = new Firefox Driver ();
driver.manage ().timeouts ().implicitly Wait (10, TimeUnit.SECONDS);
}
}

 
33. What is the command line we have to write inside a .bat file to execute a selenium project when we are using TestNG?


Java cp bin; jars/* org.testng.TestNG testng.xml

34. Which is the package which is to be imported while working with WebDriver?


org.openqa.selenium

35. How to check if an element is visible on the web page?


Use is Displayed() method.The return type of the method is Boolean.So if it returns true then the element is visible else not visible.

driver.findElement (By.xpath (“xpath of element”)).is Displayed ();

 
36. How to check if a button is enabled on the page?


Use is Enabled () method. The return type of the method is Boolean. So if it returns true then the button is enabled else not enabled.

driver.findElement (By.xpath (“xpath of button”)).is Enabled ();

 
37. How to check if a text is highlighted on the page ?


To identify weather color for a field is different or not,

String color = driver.findElement (By.xpath (“//a [text () =’Shop’]”)).getCssValue (“color”);
String backcolor = driver.findElement (By.xpath (“//a [text () =’Shop’]”)).getCssValue
(“backgroundcolor”);
System.out.println (color);
System.out.println (backcolor);

Here if both color and back color different then that me that element is in different colour.

 38. How to check the checkbox or radio button is selected?


Use selected () method to identify. The return type of the method is Boolean. So if it return true then button is selected else not enabled.
driver.findElement (By.xpath (“xpath of button”)).isSelected ();

 
39. How to get the title of the page?


Use getTitle () method.
Syntax: driver.getTitle ();

 
40. How does u get the width of the textbox?


driver.findElement (By.xpath (“xpath of textbox”)).getSize().getWidth ();
driver.findElement (By.xpath (“xpath of textbox”)).getSize().getHeight();

 
41. How do u get the attribute of the web element?


driver.getElement (By.tagName (“img”)).getAttribute(“src”) will give you the src attribute of this tag.
Similarly, you can get the values of attributes such as title, alt etc.
Similarly you can get CSS properties of any tag by using getCssValue (“some property name”).

42. How to check whether a text is underlined or not?


Identify by getCssValue (“borderbottom”) or sometime getCssValue (“text decoration”) method if the CssValue is „underline‟ for that WebElement or not.

Ex:

This is for when moving cursor over element that is going to be underlined or not

public class UnderLine
{
public static void main (String [] args)
{
WebDriver driver = new Firefox Driver();
driver.manage ().timeouts ().implicitly Wait (10, TimeUnit.SECONDS);
driver.get (“https://www.google.co.in/?gfe_rd=ctrl&ei=bXAwU8jYN4W6iAf8zIDgDA&gws_rd=cr“);
StringcssValue=driver.findElement (By.xpath(“//a[text()=’Hindi’]”)).getCssValue(“textdecoration”);
System.out.println (“value”+cssValue);
Actions act = new Actions(driver);
act.moveToElement (driver.findElement (By.xpath (“//a[text()=’Hindi’]”))).perform();
String cssValue1=driver.findElement (By.xpath(“//a[text()=’Hindi’]”)).getCssValue(“textdecoration”);
System.out.println (“value over”+cssValue1);
driver.close ();
}
}

 
43. How to change the URL on a webpage using selenium web driver?


driver.get(“url1”);
driver. get (“url2”);

 
44. How to hover the mouse on an element?


Actions act = new Actions(Driver)
act.moveToElement (WebElement); //WebElement on which you want to move cursor

 
45. What is the use of get Options () method?


get Options () is used to get the selected option from the dropdown list.

46. What is the use of deselect All () method?


It is used to deselect all the options which have been selected from the dropdown list.

47. Is WebElement an interface or a class?


WebDriver is an Interface.

48. Firefox Driver is class or an interface and from where is it inherited?


Firefox Driver is a class. It implements all the methods of WebDriver interface.

49. What is the difference b/w close () and quit ()?


close()–it will close the browser where the control is.
quit () – it will close all the browsers opened by WebDriver.

50. Can Selenium handle windows based pop up?


Selenium is an automation testing tool which supports only web application testing. Therefore, windows pop up cannot be handled using Selenium.

 
51. Why should Selenium be selected as a test tool?


Selenium
is free and open source
have a large user base and helping communities
have cross Browser compatibility (Firefox, chrome, Internet Explorer, Safari etc.)
have great platform compatibility (Windows, Mac OS, Linux etc.)
supports multiple programming languages (Java, C#, Ruby, Python, Pearl etc.)
has fresh and regular repository developments
supports distributed testing

 
52. What is Selenium? What are the different Selenium components?


Selenium is one of the most popular automated testing suites. Selenium is designed in a way to support and encourage automation testing of functional aspects of web-based applications and a wide range of browsers and platforms. Due to its existence in the open source community, it has become one of the most accepted tools amongst the testing professionals.

Selenium is not just a single tool or a utility, rather a package of several testing tools and for the same reason, it is referred to as a Suite. Each of these tools is designed to cater different testing and test environment requirements.

The suite package constitutes the following sets of tools:

Selenium Integrated Development Environment (IDE) – Selenium IDE is a record and playback tool. It is distributed as a Firefox Plugin.
Selenium Remote Control (RC) – Selenium RC is a server that allows user to create test scripts in a desired programming language. It also allows executing test scripts within the large spectrum of browsers.
Selenium WebDriver – WebDriver is a different tool altogether that has various advantages over Selenium RC. WebDriver directly communicates with the web browser and uses its native compatibility to automate.
Selenium Grid – Selenium Grid is used to distribute your test execution on multiple platforms and environments concurrently.

 
53. What are the testing types that can be supported by Selenium?


Selenium supports the following types of testing:
• Functional Testing
• Regression Testing

54. What are the limitations of Selenium?


Following are the limitations of Selenium:
• Selenium supports testing of only web-based applications
• Mobile applications cannot be tested using Selenium
• Captcha and Barcode readers cannot be tested using Selenium
• Reports can only be generated using third-party tools like TestNG or JUnit.
• As Selenium is a free tool, thus there is no ready vendor support through the user can find numerous helping communities.
• User is expected to possess prior programming language knowledge.

 
55. When should I use Selenium IDE?


Selenium IDE is the simplest and easiest of all the tools within the Selenium Package. Its record and playback feature makes it exceptionally easy to learn with minimal acquaintances to any programming language. Selenium IDE is an ideal tool for a naïve user.

 
56. What is Selenese?


Selenese is the language which is used to write test scripts in Selenium IDE.

 
57. What are the different types of locators in Selenium?


Locator can be termed as an address that identifies a web element uniquely within the webpage. Thus, to identify web elements accurately and precisely we have different types of locators in Selenium:
• ID
• ClassName
• Name
• TagName
• LinkText
• PartialLinkText
• Xpath
• CSS Selector
• DOM

58. What is difference between assert and verify commands?


Assert: Assert command checks whether the given condition is true or false. Let’s say we assert whether the given element is present on the web page or not. If the condition is true then the program control will execute the next test step but if the condition is false, the execution would stop and no further test would be executed.

Verify: Verify command also checks whether the given condition is true or false. Irrespective of the condition being true or false, the program execution doesn’t halts i.e. any failure during verification would not stop the execution and all the test steps would be executed.

59. What is an XPath?


XPath is used to locate a web element based on its XML path. XML stands for Extensible Markup Language and is used to store, organize and transport arbitrary data. It stores data in a key-value pair which is very much similar to HTML tags. Both being markup languages and since they fall under the same umbrella, Xpath can be used to locate HTML elements.
The fundamental behind locating elements using Xpath is the traversing between various elements across the entire page and thus enabling a user to find an element with the reference of another element.

 
60. What is the difference between “/” and “//” in Xpath?


Single Slash “/” – Single slash is used to create Xpath with absolute path i.e. the xpath would be created to start selection from the document node/start node.
Double Slash “//” – Double slash is used to create Xpath with relative path i.e. the xpath would be created to start selection from anywhere within the document.

61. What is Same origin policy and how it can be handled?


The problem of same origin policy disallows to access the DOM of a document from an origin that is different from the origin we are trying to access the document.

Origin is a sequential combination of scheme, host and port of the URL. For example, for a URL http:// http://www.credosystemz.com/resources/, the origin is a combination of http, credosystemz.com, 80 correspondingly.

Thus the Selenium Core (JavaScript Program) cannot access the elements from an origin that is different from where it was launched. For Example, if I have launched the JavaScript Program from “http://www.credosystemz.com”, then I would be able to access the pages within the same domain such as “http://www.credosystemz.com/resources” or “http://www.credosystemz.com/istqb-free-updates/”. The other domains like google.com, seleniumhq.org would no more be accessible.

So, In order to handle same origin policy, Selenium Remote Control was introduced.

62. When should I use Selenium Grid?


Selenium Grid can be used to execute same or different test scripts on multiple platforms and browsers concurrently so as to achieve distributed test execution, testing under different environments and saving execution time remarkably.

63. What do we mean by Selenium 1 and Selenium 2?


Selenium RC and WebDriver, in a combination are popularly known as Selenium 2. Selenium RC alone is also referred as Selenium 1.

64. Which is the latest Selenium tool?


WebDriver

65. How do I launch the browser using WebDriver?


The following syntax can be used to launch Browser:
WebDriver driver = new FirefoxDriver();
WebDriver driver = new ChromeDriver();
WebDriver driver = new InternetExplorerDriver();

66. What are the different types of Drivers available in WebDriver?


The different drivers available in WebDriver are:
• FirefoxDriver
• InternetExplorerDriver
• ChromeDriver
• SafariDriver
• OperaDriver
• AndroidDriver
• IPhoneDriver
• HtmlUnitDriver

 67. What are the different types of waits available in WebDriver?


There are two types of waits available in WebDriver:

• Implicit Wait
• Explicit Wait

Implicit Wait: Implicit waits are used to provide a default waiting time (say 30 seconds) between each consecutive test step/command across the entire test script. Thus, subsequent test step would only execute when the 30 seconds have elapsed after executing the previous test step/command.

Explicit Wait: Explicit waits are used to halt the execution till the time a particular condition is met or the maximum time has elapsed. Unlike Implicit waits, explicit waits are applied for a particular instance only.

68. How to type in a textbox using Selenium?


User can use sendKeys(“String to be entered”) to enter the string in the textbox.
Syntax:
WebElement username = drv.findElement(By.id(“Email”));
// entering username
username.sendKeys(“sth”);

69. How can you find if an element in displayed on the screen?


WebDriver facilitates the user with the following methods to check the visibility of the web elements. These web elements can be buttons, drop boxes, checkboxes, radio buttons, labels etc.

• isDisplayed()
• isSelected()
• isEnabled()
Syntax:

isDisplayed():
boolean buttonPresence = driver.findElement(By.id(“gbqfba”)).isDisplayed();
isSelected():
boolean buttonSelected = driver.findElement(By.id(“gbqfba”)).isDisplayed();
isEnabled():
boolean searchIconEnabled = driver.findElement(By.id(“gbqfb”)).isEnabled();

70. How can we get a text of a web element?


Get command is used to retrieve the inner text of the specified web element. The command doesn’t require any parameter but returns a string value. It is also one of the extensively used commands for verification of messages, labels, errors etc displayed on the web pages.
Syntax:
String Text = driver.findElement(By.id(“Text”)).getText();

71. How to select value in a drop-down?


The value in the drop down can be selected using WebDriver’s Select class.
Syntax:

selectByValue:
Select selectByValue = new Select(driver.findElement(By.id(“SelectID_One”)));
selectByValue.selectByValue(“greenvalue”);
selectByVisibleText:
Select selectByVisibleText = new Select (driver.findElement(By.id(“SelectID_Two”)));
selectByVisibleText.selectByVisibleText(“Lime”);
selectByIndex:
Select selectByIndex = new Select(driver.findElement(By.id(“SelectID_Three”)));
selectByIndex.selectByIndex(2);

72. What are the different types of navigation commands?


Following are the navigation commands:
navigate().back() – The above command requires no parameters and takes back the user to the previous webpage in the web browser’s history.
Sample code:
driver.navigate().back();
navigate().forward() – This command lets the user to navigate to the next web page with reference to the browser’s history.
Sample code:
driver.navigate().forward();
navigate().refresh() – This command lets the user to refresh the current web page there by reloading all the web elements.
Sample code:
driver.navigate().refresh();
navigate().to() – This command lets the user to launch a new web browser window and navigate to the specified URL.
Sample code:
driver.navigate().to(“https://google.com”);

73. How to click on a hyper link using linkText?


driver.findElement(By.linkText(“Google”)).click();
The command finds the element using link text and then click on that element and thus the user would be re-directed to the corresponding page.
The above mentioned link can also be accessed by using the following command.
driver.findElement(By.partialLinkText(“Goo”)).click();
The above command find the element based on the substring of the link provided in the parenthesis and thus partialLinkText() finds the web element with the specified substring and then clicks on it.

74. How to handle frame in WebDriver?


An inline frame acronym as iframe is used to insert another document with in the current HTML document or simply a web page into a web page by enabling nesting.

Select iframe by id
driver.switchTo().frame(“ID of the frame“);
Locating iframe using tagName
driver.switchTo().frame(driver.findElements(By.tagName(“iframe”).get(0));
Locating iframe using index
frame(index)
driver.switchTo().frame(0);
frame(Name of Frame)
driver.switchTo().frame(“name of the frame”);
frame(WebElement element)
Select Parent Window
driver.switchTo().defaultContent();

 

75. When do we use findElement() and findElements()?


findElement(): findElement() is used to find the first element in the current web page matching to the specified locator value. Take a note that only first matching element would be fetched.
Syntax:
WebElement element = driver.findElements(By.xpath(“//div[@id=’example’]//ul//li”));
findElements(): findElements() is used to find all the elements in the current web page matching to the specified locator value. Take a note that all the matching elements would be fetched and stored in the list of WebElements.
Syntax:
List elementList = driver.findElements(By.xpath(“//div[@id=’example’]//ul//li”));

76. What is TestNG and how is it better than Junit?


TestNG is an advanced framework designed in a way to leverage the benefits by both the developers and testers. With the commencement of the frameworks, JUnit gained an enormous popularity across the Java applications, Java developers and Java testers with remarkably increasing the code quality. Despite being easy to use and straightforward, JUnit has its own limitations which give rise to the need of bringing TestNG into the picture. TestNG is an open source framework which is distributed under the Apache Software License and is readily available for download.

TestNG with WebDriver provides an efficient and effective test result format that can, in turn, be shared with the stakeholders to have a glimpse on the product’s/application’s health thereby eliminating the drawback of WebDriver’s incapability to generate test reports. TestNG has an inbuilt exception handling mechanism which lets the program to run without terminating unexpectedly.

There are various advantages that make TestNG superior to JUnit. Some of them are:
• Added advance and easy annotations
• Execution patterns can set
• Concurrent execution of test scripts
• Test case dependencies can be set

77. What is a framework?


Framework is a constructive blend of various guidelines, coding standards, concepts, processes, practices, project hierarchies, modularity, reporting mechanism, test data injections etc. to pillar automation testing.

78. What are the advantages of Automation framework?


Advantage of Test Automation framework
• Reusability of code
• Maximum coverage
• Recovery scenario
• Low cost maintenance
• Minimal manual intervention
• Easy Reporting

79. What are the different types of frameworks?


Below are the different types of frameworks:

Module Based Testing Framework: The framework divides the entire “Application Under Test” into number of logical and isolated modules. For each module, we create a separate and independent test script. Thus, when these test scripts taken together builds a larger test script representing more than one module.

Library Architecture Testing Framework: The basic fundamental behind the framework is to determine the common steps and group them into functions under a library and call those functions in the test scripts whenever required.

Data Driven Testing Framework: Data Driven Testing Framework helps the user segregate the test script logic and the test data from each other. It lets the user store the test data into an external database. The data is conventionally stored in “Key-Value” pairs. Thus, the key can be used to access and populate the data within the test scripts.

Keyword Driven Testing Framework: The Keyword driven testing framework is an extension to Data driven Testing Framework in a sense that it not only segregates the test data from the scripts, it also keeps the certain set of code belonging to the test script into an external data file.

Hybrid Testing Framework: Hybrid Testing Framework is a combination of more than one above mentioned frameworks. The best thing about such a setup is that it leverages the benefits of all kinds of associated frameworks.

Behaviour Driven Development Framework: Behaviour Driven Development framework allows automation of functional validations in easily readable and understandable format to Business Analysts, Developers, Testers, etc.

80. Can WebDriver test Mobile applications?


WebDriver cannot test Mobile applications. WebDriver is a web-based testing tool, therefore applications on the mobile browsers can be tested.

81. Can captcha be automated?


No, captcha and barcode reader cannot be automated.

82. What is the difference between driver.get() and driver.navigate.to()


You can use both methods to navigate to an url.
Because navigating to a URL is very common, then driver.get() is a convenient way. However it does the same function as the driver.navigate().to(“url”)
The driver.navigate() also has other functions, such as

driver.navigate().back()

driver.navigate().forward()

driver.navigate().refresh()

83. What are the four parameters that have to be passed to Selenium?


Four parameters that have to be passed to selenium are:
• Host
• Port Number
• Browser
• URL

84. What is a fundamental difference between XPath and css selector?


The fundamental difference between XPath and css selector is using XPaths we traverse up in the document i.e. we can move to parent elements. Whereas using CSS selector we can only move downwards in the document.

85. What is the difference between driver.getWindowHandle() and driver.getWindowHandles() in selenium?


driver.getWindowHandle() returns a handle of the current page (a unique identifier)
Whereas driver.getWindowHandles() returns a set of handles of the all the pages available.

86. What are the different keyboard operations that can be performed in selenium?


The different keyboard operations that can be performed in selenium are-
.sendKeys(“sequence of characters”) – Used for passing charcter sequesnce to an input or textbox element.
.pressKey(“non-text keys”) – Used for keys like control, function keys etc that ae non text.
.releaseKey(“non-text keys”) – Used in conjuntion with keypress event to simulate releasing a key from keyboard event.

87. How can we handle window UI elements and window POP ups using selenium?


Selenium is used for automating Web-based application only(or browsers only). For handling window GUI elements we can use AutoIT. AutoIT is a freeware used for automating window GUI. The AutoIt scripts follow simple BASIC language like syntax and can be easily integrated with selenium tests.

88. What is an Object repository?


An object repository is a centralized location of all the object or WebElements of the test scripts. In selenium, we can create object repository using Page Object Model and Page Factory design patterns.

89. What is a data-driven framework?


A data-driven framework is one in which the test data is put in external files like csv, excel etc separated from test logic written in test script files. The test data drives the test cases, i.e. the test methods run for each set of test data values. TestNG provides inherent support for data-driven testing using @dataProvider annotation.

90. What is a hybrid framework?


Ans. A hybrid framework is a combination of one or more frameworks. Normally it is associated with the combination of data were driven and keyword driven frameworks where both the test data and test actions are kept in external files(in the form of a table).

91. What is the main difference between the close() and quit() methods?


close() – it closes the currently active browser window.
quit()- it will close all of the opened browser windows and the browser itself.

92. How to configure selenium web driver in eclipse?


In Eclipse, I created Java projects and added JUnit or TestNG classes. In the project reference, I added JUnit or TestNG jar file. In the test class, I used webdriver in setup, test and teardown methods. Sometimes, I used webdriver in beforeclass, beforemethod, aftermethod, afterclass sections.

93. What is webdriver backed selenium?


WebDriver backed Selenium is API that enables running Selenium 1.0 tests in web driver.

94. Why should testers opt for Selenium and not QTP


Selenium is more popular than QTP as
• Selenium is an open source whereas QTP is a commercial tool
• Selenium is used especially for testing web-based applications while QTP can be used for testing client-server application also
• Selenium supports Firefox, IE, Opera, Safari operating systems like Windows, Mac, Linux etc. however QTP is limited to Internet Explorer on Windows.
• Selenium supports many programming languages like Ruby, Perl, Python whereas QTP supports only VB script

95. What is the difference between setSpeed() and sleep() methods?


Both will delay the speed of execution.
Thread.sleep (): It will stop the current (java) thread for the specified period of time. Its done only once
• It takes a single argument in integer format
Ex: thread.sleep(2000)- It will wait for 2 seconds

• It waits only once at the command given at sleep
SetSpeed (): For a specific amount of time it will stop the execution for every selenium command.

• It takes a single argument in integer format
Ex: selenium.setSpeed(“2000”)- It will wait for 2 seconds

• Runs each command after setSpeed delay by the number of milliseconds mentioned in set Speed
This command is useful for demonstration purpose or if you are using a slow web application

96. What is the Selenese command to show the value of a variable in the log file?


echo() is the Selenese command to show the value of a variable.

97. How to conduct Database Testing with Selenium WebDriver?


With the help of programming features, we can connect to any Database Management System (Ex: Oracle, MS SQL Server, MySQL etc…) and conduct Database Testing.

 
98. What is actions class in WebDriver?


The user-facing API for emulating complex user gestures. Use this class rather than using the Keyboard or Mouse directly.

 99. What are the Testing Frameworks used in Selenium?


• JNuit, TestNG etc … Testing frameworks used in Selenium.
• JNunit will help to execute Test Batches and generate Test Reports.
• TestNG framework is used to group Test cases, Execute Test suites, and generate Test Reports.

100. What are the Drawbacks of Selenium IDE


• It supports Mozilla Firefox Browser only.
• Data Driven Testing (executing tests using multiple sets of test data) is not possible.
• Test Results are not generated using Selenium IDE (It generates summary only).
• Random Test Cases execution is not possible
• Selenium IDE doesn’t support Flow control Statements.
• It doesn’t support programming (Conditional statements, loop statements etc…) for enhancing Test cases.
• It is not suitable for complex Test case design.
• It doesn’t support random Test case execution.