Automation testing involves the use of a separate testing tool which lets you create test scripts which can be executed repeatedly and doesn’t require any manual intervention.
2. What are the benefits of Automation testing ?
2. What are the benefits of Automation testing ?
Supports execution of repeated test cases
Enables parallel execution
Improves accuracy thereby reducing human-generated errors
Saves time and money
Enables parallel execution
Improves accuracy thereby reducing human-generated errors
Saves time and money
3. What is Selenium?
Selenium is one of the most popular testing suites. Is is designed in the way to automate the functional aspects of web application and wide range of browsers and platforms. Due to its existence in open source community, it has become one of the most accepted testing tool. It is the package of several testing tools. The main purpose of automation to reduce the time of regression.
4. Why do you prefer Selenium Automation Tool?
4. Why do you prefer Selenium Automation Tool?
Some of the benefits of Selenium to do automation testing are
Free and open source –
Have large user base and helping communities.
Cross Platform compatibility
Multiple programming languages
Parallel Execution
Continuous Integration
5.Which execution engine have you used?
Selenium has no execute engine. J unit is used in selenium C#.
6.How do you capture the screen shot during run time?
We design out test case in such a way when there is any failure occur it goes to the catch block there we can write the code to capture the screenshot. We link the screenshot to extent report when failure occur screenshot will attach.
7. What are the Selenium components?
Selenium IDE- It is a Firefox/Chrome plug-in that was developed to speed up the creation of automation scripts. It records the user actions on the web browser and exports them as a reusable script.
7. What are the Selenium components?
Selenium IDE- It is a Firefox/Chrome plug-in that was developed to speed up the creation of automation scripts. It records the user actions on the web browser and exports them as a reusable script.
Selenium Remote Control (RC)- RC is a server that allows users to write application tests in various programming languages. The commands from the test script are accepted by this server and are sent to the browser as Selenium core JavaScript commands. The browser then behaves accordingly. It is deprecated.
Selenium Web Driver- Web Driver is a programming interface that helps create and run test cases. It makes provision to act on web elements. Unlike RC, Web Driver does not require an additional server and interacts naively with the browser applications.
Selenium Grid- Grid was designed to distribute commands to different machines simultaneously. It allows the parallel execution of tests on different browsers and different operating systems.
8. What is Selenium framework?
Is is a code structure for making code maintainable simpler and code readability better. It involves breaking the entire code into smaller pieces of code which test a particular functionality.
9. What are the different types of framework available in Selenium?
Selenium Web Driver- Web Driver is a programming interface that helps create and run test cases. It makes provision to act on web elements. Unlike RC, Web Driver does not require an additional server and interacts naively with the browser applications.
Selenium Grid- Grid was designed to distribute commands to different machines simultaneously. It allows the parallel execution of tests on different browsers and different operating systems.
8. What is Selenium framework?
Is is a code structure for making code maintainable simpler and code readability better. It involves breaking the entire code into smaller pieces of code which test a particular functionality.
9. What are the different types of framework available in Selenium?
Data Driven Framework:-
When the entire test data is generated from some external files like Excel, CSV, XML or some database table, then it is called Data Driven framework.
Keyword Driven Framework:-
When only the instructions and operations are written in a different file like an Excel worksheet or in feature file, it is called Keyword Driven framework.
Hybrid Framework:-
A combination of both the Data Driven framework and the Keyword Driven framework is called Hybrid framework
10. What are the challenges and limitation of Selenium Web driver?
Challenges -it is difficult to test image based application.
Can not perform tests on web services like soap and rest using Selenium
Limitations- Can not test mobile applications and window based applications, can not test the barcode.
11. Which Framework you worked on?
Challenges -it is difficult to test image based application.
Can not perform tests on web services like soap and rest using Selenium
Limitations- Can not test mobile applications and window based applications, can not test the barcode.
11. Which Framework you worked on?
I have worked on Data driven and behaviour driven framework. Explain the components of framework.
12.What was your challenge during framework design?
My challenge was to identifying the proper structure and all right components which fulfill our current and future requirements. The main challenge was how to write page functions, libraries of the framework.
13. What source code management tool have you used?
I have used git repository for my source code management. It is the Central location where we can push our code and people can clone. We can resolve the conflicts and merge and check out the project.
14. How many team members were there in your team?
In my company, we follow agile approach . We have small number of team. In my module, there are 5 members out of 2 QA , whose responsibilities is to start automation from functional testing to the performance testing.
15. How many browser have you covered?
Basically 2- Chrome, Firefox
16. How did you manage to work in multiple browser?
We use Jenkins to trigger our scripts.
17. How many scripts do you automate in a day?
It depends on end to end Scenario, How good framework you have whether all page factory ready or not.
18. What are the testing types supported by Selenium?
Selenium basically supports Regression testing and Functional testing, UAT testing.
19. What is the difference between Selenium 2.0 and Selenium 3.0?
Selenium 2.0 is a tool that makes the development of automated tests for web applications easier. It represents the merger of the original Selenium project with the Web Driver project. Selenium RC got deprecated since the merge, however, was used for backward compatibility
Selenium 3.0 is the extended version of Selenium 2.0. It is inherently backward compatible and does not involve Selenium RC. The new version came along with several bug fixes and increased stability.
20. What is the same-origin policy and how is it handled?
Same Origin policy is a feature adopted for security purposes. According to this policy, a web browser allows scripts from one web page to access the contents of another web page provided both the pages have the same origin. The origin refers to a combination of the URL scheme, host name, and port number.
22. Mention the types of Web locators.
Locator is a command that tells Selenium IDE which GUI elements ( say Text Box, Buttons, Check Boxes, etc) it needs to operate on. Locators specify the area of action.
Locator by ID: It takes a string parameter which is a value of the ID attribute which returns the object to findElement() method.
Locator by the link: If your targeted element is a link text then you can use the by.linkText locator to locate that element.
Locator by Partial link: The target link can be located using a portion of text in a link text element.
Locator by Name: The first element with the name attribute value matching the location will be returned.
Locator by TagName: Locates all the elements with the matching tag name
Locator by classname: This finds elements based on the value of the CLASS attribute. If an element has many classes then this will match against each of them.
Locator by XPath: It takes a parameter of String which is a XPATHEXPRESSION and it returns an object to findElement() method.
Locator by CSS Selector: Locates elements based on the driver’s underlying CSS selector engine.
23. Mention the types of navigation commands
driver.navigate() - Navigates to the provided URL
driver.navigate().refresh() - This method refreshes the current page
driver.navigate().forward() - This method does the same operation as clicking on the Forward Button of any browser. It neither accepts nor returns anything.
driver.navigate().back() - This method does the same operation as clicking on the Back Button of any browser. It neither accepts nor returns anything.
24. What is the major difference between driver.close() and driver.quit()?
driver.close()- This command closes the browser’s current window. If multiple windows are open, the current window of focus will be closed.
driver.quit()- When quit() is called on the driver instance and there are one or more browser windows open, it closes all the open browser windows.
25. How to type text in an input box using Selenium?
SendKeys() is the method used to type text in input boxes
26. How to mouse hover over a web element?
Actions class utility is used to hover over a web element in Selenium Web Driver
Instantiate Actions class.
Actions action = new Actions(driver);
27. What is POM (Page Object Model)?
Every web page of the application has a corresponding page class that is responsible for locating the web elements and performing actions on them. Page Object Model is a design pattern that helps create object repositories for the web elements. POM improves code re-usability and readability. Multiple test cases can be run on the object repository. It keeps the test and element locators separately.
28. Difference between Page Factory and Page Object model?
Page Object Model- It is a design pattern to create object repository for web UI elements. Each web page should have corresponding page class.
Page Factory- It is the way to initialise the web elements within the page object when an instance is created.
29. How to handle multiple windows in Selenium?
A window Handle is a unique identifier that holds the address of all the windows. This is basically a pointer to the window which returns the string value.
getWindowHandle()- To get the current window handle.
getWindowHandles ()- To get all opened window handles.
30. What are assert and verify commands?
Assert is used to compare actual result with excepted result.
Verify means there wont be any halt in the test execution even though the verify condition is true and false. Verifies if the specified condition is true and false. If the result is true, the next test step will be executed. In case of false condition, the execution would still continue
32. When do we use findElement() and findElements()?
findElement() is used to access any single element on the web page. It returns the object of the first matching element of the specified locator. It throws an exception when element is not visible.
General syntax:
WebElement element = driver.findElement(By.id(page1));
findElements() is used to find all the elements in the current web page matching the specified locator value. All the matching elements would be fetched and stored in the list of Web elements. It does not throw an exception when elements are not visible.
General syntax:
List <WebElement> elementList = driver.findElements(By.id(page1));
33. What is the difference between single and double slash in Xpath?
Single slash is used to create Xpath with an absolute path i.e. the XPath would be created to start selection from the start node.
/html/body/h1/h2
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
//div[class="hello"]
34. Selenium WebDriver Commands in C#:
Browser commands- Url, Title, pageSource, close, quit, back, forward, refresh
Web Element commands- Click, Clear, SendKeys, Displayed, Enabled, Selected, Submit,Text, TagName, GetCSSValue
Dropdown commands- SelectByText, SelectByValue, options, IsMultiple, deselectAll, deselectByIndex, deselectByValue, deselectByText
TimeoutException: This exception is thrown when a command performing an operation does not complete in the stipulated time
12.What was your challenge during framework design?
My challenge was to identifying the proper structure and all right components which fulfill our current and future requirements. The main challenge was how to write page functions, libraries of the framework.
13. What source code management tool have you used?
I have used git repository for my source code management. It is the Central location where we can push our code and people can clone. We can resolve the conflicts and merge and check out the project.
14. How many team members were there in your team?
In my company, we follow agile approach . We have small number of team. In my module, there are 5 members out of 2 QA , whose responsibilities is to start automation from functional testing to the performance testing.
15. How many browser have you covered?
Basically 2- Chrome, Firefox
16. How did you manage to work in multiple browser?
We use Jenkins to trigger our scripts.
17. How many scripts do you automate in a day?
It depends on end to end Scenario, How good framework you have whether all page factory ready or not.
18. What are the testing types supported by Selenium?
Selenium basically supports Regression testing and Functional testing, UAT testing.
Steps involved are -
Re-testing: All tests in the existing test suite are executed. It proves to be very expensive and time-consuming.
Regression test selection: Tests are classified as feature tests, integration tests, and the end to end tests. In this step, some of the tests are selected.
Prioritization of test cases: The selected test cases are prioritized based on business impact and critical functionalities.
Functional testing - Functional Testing involves the verification of every function of the application with the required specification.
The following are the steps involved:
Identify test input
Compute test outcome
Execute test
Compare the test outcome with the actual outcome
Re-testing: All tests in the existing test suite are executed. It proves to be very expensive and time-consuming.
Regression test selection: Tests are classified as feature tests, integration tests, and the end to end tests. In this step, some of the tests are selected.
Prioritization of test cases: The selected test cases are prioritized based on business impact and critical functionalities.
Functional testing - Functional Testing involves the verification of every function of the application with the required specification.
The following are the steps involved:
Identify test input
Compute test outcome
Execute test
Compare the test outcome with the actual outcome
19. What is the difference between Selenium 2.0 and Selenium 3.0?
Selenium 2.0 is a tool that makes the development of automated tests for web applications easier. It represents the merger of the original Selenium project with the Web Driver project. Selenium RC got deprecated since the merge, however, was used for backward compatibility
Selenium 3.0 is the extended version of Selenium 2.0. It is inherently backward compatible and does not involve Selenium RC. The new version came along with several bug fixes and increased stability.
20. What is the same-origin policy and how is it handled?
Same Origin policy is a feature adopted for security purposes. According to this policy, a web browser allows scripts from one web page to access the contents of another web page provided both the pages have the same origin. The origin refers to a combination of the URL scheme, host name, and port number.
21. What is Selenese? How is it classified?
Selenese is the set of Selenium commands which are used to test your web application. The tester can test the broken links, the existence of some object on the UI, Ajax functionality, alerts, window, list options, and a lot more using Selenese.
Action: Commands which interact directly with the application
Accessors: Allow the user to store certain values to a user-defined variable
Assertions: Verifies the current state of the application with an expected state
Selenese is the set of Selenium commands which are used to test your web application. The tester can test the broken links, the existence of some object on the UI, Ajax functionality, alerts, window, list options, and a lot more using Selenese.
Action: Commands which interact directly with the application
Accessors: Allow the user to store certain values to a user-defined variable
Assertions: Verifies the current state of the application with an expected state
22. Mention the types of Web locators.
Locator is a command that tells Selenium IDE which GUI elements ( say Text Box, Buttons, Check Boxes, etc) it needs to operate on. Locators specify the area of action.
Locator by ID: It takes a string parameter which is a value of the ID attribute which returns the object to findElement() method.
Locator by the link: If your targeted element is a link text then you can use the by.linkText locator to locate that element.
Locator by Partial link: The target link can be located using a portion of text in a link text element.
Locator by Name: The first element with the name attribute value matching the location will be returned.
Locator by TagName: Locates all the elements with the matching tag name
Locator by classname: This finds elements based on the value of the CLASS attribute. If an element has many classes then this will match against each of them.
Locator by XPath: It takes a parameter of String which is a XPATHEXPRESSION and it returns an object to findElement() method.
Locator by CSS Selector: Locates elements based on the driver’s underlying CSS selector engine.
23. Mention the types of navigation commands
driver.navigate() - Navigates to the provided URL
driver.navigate().refresh() - This method refreshes the current page
driver.navigate().forward() - This method does the same operation as clicking on the Forward Button of any browser. It neither accepts nor returns anything.
driver.navigate().back() - This method does the same operation as clicking on the Back Button of any browser. It neither accepts nor returns anything.
24. What is the major difference between driver.close() and driver.quit()?
driver.close()- This command closes the browser’s current window. If multiple windows are open, the current window of focus will be closed.
driver.quit()- When quit() is called on the driver instance and there are one or more browser windows open, it closes all the open browser windows.
25. How to type text in an input box using Selenium?
SendKeys() is the method used to type text in input boxes
26. How to mouse hover over a web element?
Actions class utility is used to hover over a web element in Selenium Web Driver
Instantiate Actions class.
Actions action = new Actions(driver);
27. What is POM (Page Object Model)?
Every web page of the application has a corresponding page class that is responsible for locating the web elements and performing actions on them. Page Object Model is a design pattern that helps create object repositories for the web elements. POM improves code re-usability and readability. Multiple test cases can be run on the object repository. It keeps the test and element locators separately.
28. Difference between Page Factory and Page Object model?
Page Object Model- It is a design pattern to create object repository for web UI elements. Each web page should have corresponding page class.
Page Factory- It is the way to initialise the web elements within the page object when an instance is created.
29. How to handle multiple windows in Selenium?
A window Handle is a unique identifier that holds the address of all the windows. This is basically a pointer to the window which returns the string value.
getWindowHandle()- To get the current window handle.
getWindowHandles ()- To get all opened window handles.
30. What are assert and verify commands?
Assert is used to compare actual result with excepted result.
Verify means there wont be any halt in the test execution even though the verify condition is true and false. Verifies if the specified condition is true and false. If the result is true, the next test step will be executed. In case of false condition, the execution would still continue
31. What does the switch To() command do?
Switch To() command is used to switch between windows, frames or pop-ups within the application. Every window instantiated by the Web Driver is given a unique alphanumeric value called “Window Handle”.
Get the window handle of the window you wish to switch to
String handle= driver.getWindowHandle();
Switch to the desired window
driver.switchTo().window(handle);
Switch To() command is used to switch between windows, frames or pop-ups within the application. Every window instantiated by the Web Driver is given a unique alphanumeric value called “Window Handle”.
Get the window handle of the window you wish to switch to
String handle= driver.getWindowHandle();
Switch to the desired window
driver.switchTo().window(handle);
32. When do we use findElement() and findElements()?
findElement() is used to access any single element on the web page. It returns the object of the first matching element of the specified locator. It throws an exception when element is not visible.
General syntax:
WebElement element = driver.findElement(By.id(page1));
findElements() is used to find all the elements in the current web page matching the specified locator value. All the matching elements would be fetched and stored in the list of Web elements. It does not throw an exception when elements are not visible.
General syntax:
List <WebElement> elementList = driver.findElements(By.id(page1));
33. What is the difference between single and double slash in Xpath?
Single slash is used to create Xpath with an absolute path i.e. the XPath would be created to start selection from the start node.
/html/body/h1/h2
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
//div[class="hello"]
34. Selenium WebDriver Commands in C#:
Browser commands- Url, Title, pageSource, close, quit, back, forward, refresh
Web Element commands- Click, Clear, SendKeys, Displayed, Enabled, Selected, Submit,Text, TagName, GetCSSValue
Dropdown commands- SelectByText, SelectByValue, options, IsMultiple, deselectAll, deselectByIndex, deselectByValue, deselectByText
35. Explain the different exceptions in Selenium WebDriver.
NoSuchElementException: This exception is thrown when an element with given attributes is not found on the web page
ElementNotVisibleException: This exception is thrown when the element is present in DOM (Document Object Model), but not visible on the web page
StaleElementException: This exception is thrown when the element is either deleted or no longer attached to the DOM
36. Write a code to wait for a particular element to be visible on a page. Write a code to wait for an alert to appear.
We can write a code such that we specify the xpath of the web element that needs to be visible on the page and then ask the WebDriver to wait for a specified time. Look at the sample piece of code below:
WebDriverWait wait=new WebDriverWait(driver, 20);
Element = wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath( “<xpath”)));
Similarly, we can write another piece of code asking the WebDriver to wait until an error appears like this:
WebDriverWait wait=new WebDriverWait(driver, 20);
Element = wait.until(ExpectedConditions.alertIsPresent());
38. What is a Robot class?
This robot class provides control over the mouse and keyboard devices.
The methods include:
KeyPress(): This method is called when you want to press any key.
KeyRelease(): This method is used to release the pressed key on the keyboard.
MouseMove(): This method is called when you want to move the mouse pointer in the X and Y co-ordinates.
MousePress(): This is used to press the left button of the mouse.
MouseMove(): This method helps in releasing the pressed button of the mouse.
36. Write a code to wait for a particular element to be visible on a page. Write a code to wait for an alert to appear.
We can write a code such that we specify the xpath of the web element that needs to be visible on the page and then ask the WebDriver to wait for a specified time. Look at the sample piece of code below:
WebDriverWait wait=new WebDriverWait(driver, 20);
Element = wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath( “<xpath”)));
Similarly, we can write another piece of code asking the WebDriver to wait until an error appears like this:
WebDriverWait wait=new WebDriverWait(driver, 20);
Element = wait.until(ExpectedConditions.alertIsPresent());
37.How can you fetch an attribute from an element? How to retrieve typed text from a textbox?
We can fetch the attribute of an element by using the getAttribute() method. Sample code:
WebElement eLogin = driver.findElement(By.name(“Login”);
String LoginClassName = eLogin.getAttribute("classname");
38. What is a Robot class?We can fetch the attribute of an element by using the getAttribute() method. Sample code:
WebElement eLogin = driver.findElement(By.name(“Login”);
String LoginClassName = eLogin.getAttribute("classname");
This robot class provides control over the mouse and keyboard devices.
The methods include:
KeyPress(): This method is called when you want to press any key.
KeyRelease(): This method is used to release the pressed key on the keyboard.
MouseMove(): This method is called when you want to move the mouse pointer in the X and Y co-ordinates.
MousePress(): This is used to press the left button of the mouse.
MouseMove(): This method helps in releasing the pressed button of the mouse.
39. How to handle a dropdown in Selenium WebDriver? How to select a value from dropdown?
This is a 2 step process:
Identify the ‘select’ html element (Because dropdowns must have the ‘select’ tag)
Select an option from that dropdown element
To identify the ‘select’ html element from the web page, we need to use findElement() method. Look at the below piece of code:
WebElement mySelectElement = driver.findElement(By.id("mySelect"));
Select dropdown = new Select(mySelectElement);
Now to select an option from that dropdown, we can do it in either of the three ways:
This is a 2 step process:
Identify the ‘select’ html element (Because dropdowns must have the ‘select’ tag)
Select an option from that dropdown element
To identify the ‘select’ html element from the web page, we need to use findElement() method. Look at the below piece of code:
WebElement mySelectElement = driver.findElement(By.id("mySelect"));
Select dropdown = new Select(mySelectElement);
Now to select an option from that dropdown, we can do it in either of the three ways:
dropdown.selectByVisibleText(“ABC”); → Selecting an option by the text that is visible
dropdown.selectByIndex(“1”); → Selecting, by choosing the Index number of that option
dropdown.selectByValue(“option2”); → Selecting, by choosing the value of that option
dropdown.selectByIndex(“1”); → Selecting, by choosing the Index number of that option
dropdown.selectByValue(“option2”); → Selecting, by choosing the value of that option
40. Difference between isselected, isenabled, isdisplayed
isdisplayed()- whether the element is diplay on web page or not
isenabled ()- whether element is enable or disable
isselected()- whether element is selected or not - in case of radio buttons, check box and drop downs
41. how to resize the browser window?
dimension d= new dimension (480,620);
driver.manage.setsize(d);
42. When do we use selenium grid?
It can be used to execute same or different test scripts on multiple platforms and browsers concurrently so as to achieve distributed test execution.
43. how to drag and drop an element?
action.clickandHold(driver.findelement()).release().build().perform()
No comments:
Post a Comment
Please let me know if you have any doubts.