1.Which framework you have used in ur
project?
Ans- Hybrid
driven framework.
2. what is
hybrid framework?
Ans. Its an
combination of all frameworks-module+function+data driven.
3.What is xpath-
Ans- Its an locator used to identify the web
element on any web page.
4. what is // and
/ in xpath-
/- it
is used to identify the immediate child.
5.which selenium
version ur working?
Ans- 2.43(current version)
6.How do find the
xpath?
Ans- to find the xpath , we use Firebug addons on firefox
browser and to varify the xpath written we use Firepath addons.
Syntax- //htmltag[@attname='attvalue'] or
//html[text()='textvalue'] or //htmltag[contains(text(),'textvalue')] or
//htmltag[contains(@attname,'attvalue')]
7. Explain about
selenium architecture
Selenium Client ? Selenium RC ? Browser
Browser API
Application under test (AUT)
DOMJavaScript
8.What is
Selenium IDE
Ans- Selenium IDE is a complete integrated development
environment (IDE) for Selenium tests. It is implemented as a Firefox Add-On,
and allows recording, editing, and debugging tests. It was previously known as
Selenium Recorder.
Scripts may be automatically recorded and edited manually
providing autocompletion support and the ability to move commands around
quickly.
Scripts are recorded in Selenese, a special test scripting
language for Selenium. Selenese provides commands for performing actions in a
browser (click a link, select an option), and for retrieving data from the
resulting pages.
9. What
is Selenium Webdriver?
Ans- WebDriver is the name of the key interface against
which tests should be written in Java, the implementing classes one should use are
listed as below:
“AndroidDriver, ChromeDriver, EventFiringWebDriver,
FirefoxDriver, HtmlUnitDriver, InternetExplorerDriver, IPhoneDriver,
PhantomJSDriver, RemoteWebDriver,
SafariDriver”
10. Have you
used TestNG ?
Ans- yes.
To know about Testng and installation Please ClickHere
11.What is
Annotations ?
Ans- @Test,
@BeforeTest , @AfterTest, @BeforeClass, @AfterClass, @BeforeMethod,
@AfterMethod, @BeforeSuite, @AfterSuite.
12.What is
TestNg ? why we need it?
Ans- TestNG is a unit testing framework for the Java
programming language inspired from JUnit and NUnit. The design goal of TestNG
is to cover all categories of tests:
unit, functional, end-to-end, integration, etc., with more powerful and
easy-to-use functionalities.
Why we need it - TestNG's main features include:
a)- Annotation
support.
b)- Support for
parameterized and data-driven testing (with @DataProvider and/or XML configuration).
c)- Support for
multiple instances of the same test class (with @Factory)
d)- Flexible
execution model. TestNG can be run either by Ant via build.xml (with or without
a test suite defined), or by an IDE
plugin with visual
results. There
isn't a TestSuite class, while test suites, groups and tests selected to run
are defined and configured by XML
files.
e)- Concurrent
testing
f)- Embeds
BeanShell for further flexibility.
g)- Default JDK
functions for runtime and logging (no dependencies).
h)- Distributed testing: allows distribution
of tests on slave machines.
13.How do
you read data from excel ?
Ans-
FileInputStream fis = new FileInputStream(“path of excel file”);
Workbook wb = WorkbookFactory.create(fis);
Sheet
s = wb.getSheet(wb);
String
value = s.getRow(rowNum).getCell(cellNum).getStringCellValue();
Example for Read and write data from Excel Please ClickHere
Example for Read and write data from Excel Please ClickHere
14.How do
you handle popups ?
Ans- To handle alert popups, we need to 1st switch control
to alert popups then click on ok or cancel then move control back to 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 cancle.
Then move the control back to main web page-
driver.switchTo().window(mainPage)?to switch back to main
page
15.What is
the use of Xpath ?
Ans – It is used to find the webElement in web page. It is
very useful to identify the dynamic web elements.
16.Different
types of locators ?
Ans- There are 8 types of locators and all are the static
methods of the By class.
By.id(), By.name(), By.tagName(),
By.class(), By.linkText(), By.partialLinkText(), By.xpath, By.cssSelector().
17.Selenium Framework that you are using in your current project?
Ans- Hybrid
Driven Framework.
18.How do
you identify the Xpath of element on your browser?
Ans- to find the xpath , we use Firebug addons on firefox
browser and to identify the xpath written we use Firepath addons.
Syntax-
//htmltag[@attname='attvalue'] or //html[text()='textvalue']
Or
//htmltag[contains(text(),'textvalue')] or
//htmltag[contains(@attname,'attvalue')]
19.Selenium
function used for retrieving the attribute or value?
Ans-
getAttribute(), getText().
20.How do
you differentiate check box if more than one check box is existed in your
application?
Ans- By writing the xpath in dynamic way.
21.Difference
between Assert and Verify?
Verify- it is also used to verify the result. If the test case fail then it will not stop the execution of that test case.
22.What is
the alternate way to click on login button?
Ans- Use submit() method but it can be used only when attribute type=submit.
23.How do
you verify if the checkbox/radio is checked or not ?
Ans- isSelected();
ex-
driver.findElement(By.id("Rr")).isSelected(); // return type is boolean.
24.How to
get the href of a link / get the source of image
Ans- use getAttribute() method.
25.Count the
number of links in a page.
Ans- use the locator By.tagName and find the elements for
the tag //a then use loop to count the number of elements found.
Syntax- int count = 0;
List<webElement> link = driver.findElements(By.tagName(“a”));
for(int i=0;
i<=link.size(); i++){
count
= count+1;
}
System.out.println(count);
? this will print the number of links in a page.
26. How to
check all checkboxes in a page
Ans- List<webElement>
chkBox =
driver.findElements(By.xpath(“//htmltag[@attbute='checkbox']”));
for(int i=0;
i<=chkBox.size(); i++){
chkBox.get(i).click();
}
27. How do
you handle browser popup?
Ans- to handle browser popups , we need to move the control
from one browser popup to other.
Syntax- Iterator<String> it =
driver.getWindowHandles().iterator();
String
parent = it.next();
String
child = it.next();
driver.switchTo().window(child);
//to move control to child browser
driver.switchTo().window(parent);
//to move control back to parent browser
28.How do
you handle elements present inside frame?
Ans- to handle elements present in frame, 1st we need to
move the control to frame then we can handle elements of frame.
Syntax to move control to frame-
driver.switchTo().frame(webElement);
and to move the control back to main page -
driver.switchTo().defaultContent();
29.How do
you handle Javascript alert/confirmation popup?
Ans- To handle alert popups, we need to 1st switch control
to alert popups then click on ok or cancle then move control back to 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 cancle.
Then move the control back to main web page-
driver.switchTo().window(mainPage); ? to switch back to main
page.
30.How do
you launch IE/chrome browser?
Ans- before launching IE or Chrome browser we need to set
the System property.
To open IE browser ?
System.setProperty(“ie.webdriver.driver”,”path
of the iedriver.exe file ”);
WebDriver driver = new InternetExplorerDriver();
To open Chrome browser ?
System.setProperty(“chrome.webdriver.driver”,”path of the
chromeDriver.exe file ”);
WebDriver driver = new ChromeDriver();
31.How to
perform right click using WebDriver?
Ans- use Actions class.
Actions act = new Actions(driver);
act.moveToElement(webElement).perform();
act.contextClick().perform();
32.How do
perform drag and drop using WebDriver?
Ans- use Action class.
Actions act = new Actions(driver);
WebElement source = driver.findElement(By.xpath(“ -----”));
WebElement target = driver.findElement(By.xpath(“ -----”));
act.dragAndDrop(source,target).perform();
33.How to
send ENTER/TAB keys in WebDriver?
And- use click() or submit() [submit() can be used only when
type='submit'])method for ENTER.
Or act.sendKeys(Keys.ENTER);
For Tab-
act.sendKeys(Keys.TAB);
34.Example for method overload in WebDriver
Ans- frame(string),
frame(int), frame(WebElement)
35. How do
you upload a file?
Ans-
driver.findElement(By.xpath(“input field”)).sendKeys(“path of the file
which u want to upload”).
36. How do
you click on a menu item in a drop down menu?
Ans- 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 class then we can simply find the path
of that element and click on that to select.
37.what is difference between
assertEqual and verify?
Ans- assertEqual- It is a static method of the Assert class.
it is used to verify the result. If the test case fail then it will stop the
execution of the test case there itself and move the execution to other test
case.
Verify- it is also used to verify the result. If the test
case fail then it will not stop the execution of that test case.
38.How do
you simulate browser back and forward?
Ans- driver.navigate().back();
driver.navigate().forward();
39.How do
you get the current page URL?
Ans- driver.getCurrentUrl();
40. What is
an xpath?
Ans- its an
locator used to identify the web element on any web page.
41.What is
the difference between ‘/’ and ‘//’
Ans //- it is used to search in the entire
structue,
/- it
is used to identify the immediate child.
42.What is
the difference between findElement and findElements?
Ans- Both
methods used to find the webElement in a web page.
findElement() - 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 return List of WebElements.
43.How do you achieve synchronization in
WebDriver?
Ans- driver.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS);
44.Explain
implicit and explicit wait?
Ans- implicit wait- is like to wait for specific time only
when element is not found. If element found then wait time is 0.
example:
driver.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS);
here max wait time is 10 sec.
explicit wait- Thread.sleep(time); is like to wait for
specific time either element is found or not. If element found then also wait
for specified time.
45.Write the
code for Reading and Writing to Excel through Selenium?
Ans- FileInputStream fis = new FileInputStream(“path of excel file”);
Workbook wb = WorkbookFactory.create(fis);
Sheet
s = wb.getSheet(wb);
String
value= s.getRow(rowNum).getCell(cellNum).getStringCellValue(); // read
s.getRow(rowNum).getCell(cellNum).setCellValue(); //write
FileOutputStream fos = new FileOutputStream(“path of file”); //write
wb.write(fos);
//write
46.How do
get typed text from a textbox?
Ans-
driver.findElement(By.xpath("//input[@id='username']")).getAttribute("value"));
47.What are
the different exceptions you get when working with WebDriver?
Ans-
ElementNotVisibleException,
ElementNotSelectableException,
NoAlertPresentException,
NoSuchAttributeException,
NoSuchWindowException,
TimeoutException,
WebDriverException etc.
48.What are the languages supported by
WebDriver?
Ans- Python, Ruby, C# and Java are all supported directly by
the development team. There are also
webdriver implementations for PHP and Perl.
49.What are the limitations of Selenium IDE?
Ans- a)- It does not
supports looping or conditional statements. Tester has to use native languages
to write logic in the test case.
b)- It does not
supports test reporting, you have to use selenium RC with some external
reporting plugin like TestNG or JUint to get test execution report.
c)- Error handling is also not supported depending on the
native language for this.
50.What are
the browsers supported by Selenium IDE?
Ans- Mozilla FireFox
only. Its an Firefox add on.
51.How
do you clear the contents of a textbox in selenium
Ans- use clear() method.
52.What is a
Framework?
Ans- 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
re-usability
* Non Technical
testers
*can be involved in code, Training period of using the tool
can be reduced, Involves Data wherever
appropriate.
There are five types of framework used in software
automation testing:
* 1-Data Driven
Automation Framework
* 2-Method Driven
Automation Framework
* 3-Modular
Automation Framework
* 4-Keyword
Driven Automation Framework
* 5-Hybrid
Automation Framework = 1+2+3
53.Different
components of your Framework?
Ans- Library- Assertion, ConfigLibrary, GenericLibrary,
ProjectSpecificLibrary, Modules.
Drivers
folder, Jars folder, excel file.
54.Can you
explain the Framework flow with a diagram?
Ans- yes we can. (Explain above classes in flow.)
55.How do
you accommodate project specific methods in your framework?
Ans- 1st go through all the manual test cases and identify
the steps which are repeating. Note down such steps and make them as methods
and write into ProjectSpecificLibrary.
56.How is
the failure handled in your framework?
Ans- We can execute the failure test case and identify the
where is the exact issue. If this is a code issue then we raise the bug/defect
for the developer and if its an script issue then we check the script and
correct it.
57.What kind
of reports are generated by your framework?
Ans- Three kinds of report-
* TestNG report
* Eclipse Console
report
* HTML report.
58. What are
the prerequisites to run selenium webdriver?
Ans-
* JDK
* Eclipse
*
WebDriver(selenium standalone jar file)
* Browser
* application to
be tested.
59.What are
the advantages of selenium webdriver?
Ans-
* It supports
with all browsers like Firefox, IE, Chrome, Safari, Opera etc.
* Doesn’t required
to start server before executing the test script.
* It actual core
API which has binding in a range of languages.
* It supports of
moving mouse cursors.
* It support to
test iphone/Android applications.
60.What is WebDriverBackedSelenium?
Ans- 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.
61.How to
invoke an application in webdriver?
Ans- driver.get(“url”);
62.What is
Selenium Grid?
Ans- 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 running different browsers
and operating systems. Essentially, Selenium-Grid support distributed test
execution. It allows
for running your tests in a distributed test execution
environment.
63.How to
get the number of frames on a page?
Ans- List <WebElement> framesList =
driver.findElements(By.xpath("//iframe"));
int
numOfFrames = frameList.size();
64.How to verify that an element is not
present on a page?
Ans : try {
driver.findElement(locatorKey);
return
true;
}
catch (org.openqa.selenium.NoSuchElementException e) {
return
false;
}
65.How
do you simulate scroll down action?
Ans- Selenium not care the element is on the screen or need
to scroll down. but if you mean the element will dynamic added when scroll
down, you must simulate scroll down action.
66. what is
the command line we have to write inside a .bat file to execute a selenium
project when we are using testing.
Ans- java -cp
bin;jars/* org.testng.TestNG testng.xml
67. I have
2000+ images in my application with different dimensions.
Now
the req. is all images needs to be changed with 100X100 dimensions.
To
verify that all images are changed to specified dimensions, Is
there any way with the help of any automation tool or we need to check manually
2000+ images ?
Ans- I don't think so, we can do this by using selenium
WebDriver. We have to do this manually.
68.How to
verify the presence of the success message on a page?
Ans- getText();
69.Which is the package which is to
be imported while working with webdriver?
Ans- org.openqa.selenium
70. How to
check if an element is visible on the web page?
Ans-
driver.findElement(By.xpath("//input[@id='username']")).isDisplayed();
71.How to
check if a button is enabled on the page?
Ans- use getAttribute() method to get the value of attribute
which developer introduced in the web page to identify whether button is
enabled or disabled.
ex-
if(driver.findElement(By.xpath("//button[text()='OK']")).getAttribute("aria-disabled").equals("false")){
Globals.driver.findElement(By.className("x-panel-btns")).findElement(By.xpath("//button[text()='OK']")).click();
}else{
Globals.driver.findElement(By.className("x-panel-btns")).findElement(By.xpath("//button[text()='Cancel']")).click();
}
72.How to
check if a text is highlighted on the page?
Ans- 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("background-color");
System.out.println(color);
System.out.println(backcolor);
Here if both color and backcolor different then that means
that element is in different color.
73. What is
the selenium's recording language?
Ans- Selenium's recording language is "Html".
74.How do you handle Ajax controls using Selenium?
We can handle Ajax Controls by using wait for condition command.
We can handle Ajax Controls by using wait for condition command.
75. How to check the checkbox or radio button is
selected?
Ans- use isSelected() method to identify.
76. How to
get the title of the page?
Ans- getTitle();
77. How do u
get the width of the textbox?
Ans- Not sure.
78.How do u get the attribute of the web
element?
Ans-
driver.getElement(By.tagName("img")).getAttribute("src")
will get 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 propety").
79. How
to check whether a text is underlined or not?
Ans- identify by getCssValue(“border-bottom”) or sometime
getCssValue(“text-decoration”)method if the cssValue is there for that
webElement or not. 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 FirefoxDriver();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.get("https://www.google.co.in/?gfe_rd=ctrl&ei=bXAwU8jYN4W6iAf8zIDgDA&gws_rd=cr");
String
cssValue=
driver.findElement(By.xpath("//a[text()='Hindi']")).getCssValue("text-decoration");
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("text-decoration");
System.out.println("value over"+cssValue1);
driver.close();
}
}
80.How to
change the URL on a webpage using selenium web driver?
Ans-
driver.get(“url1”);
driver.get(“url2”);
81.How to
verify the presence of tooltips for a link?
Ans- webeElement.getAttribute("title");
82. How to
hover the mouse on an element?
Ans- Actions act
= new Actions(driver);
act.moveToElement(webelement);
83.What is
the use of getOptions() method?
Ans- getOptions() is used to get the selected option from
the dropdown list.
84.What is
the use of deSelectAll() method?
Ans- it is used to deselect all the options which have been
selected from the dropdown list.
85.Is
WebElement an interface or a class?
Ans- Interface.
86. FirefoxDriver is class or an interface and from where is it inherited?
Ans- FirefoxDriver is a class. It implements all the methods
of WebDriver interface.
87.Which is the super interface of webdriver?
Ans- SearchContext.
88.What is the difference b/w close()
and quit()?
Ans- close() - it will close the browser where the control
is.
quit()- it will close all the browsers opened by WebDriver.
89.What is
the difference b/w getWindowHandles() and getWindowHandle() ?
Ans- getWindowHandles()- is used to get the address of all
the open browser which we can store in Iterator<String> type.
getWindowHandle()- is used to get the address of the current
browser where the conrol is.
90. What is
the use of contextClick() ?
Ans- It is used to right click.
91. How to
press Shift+Tab?
Ans- Please ClickHere
92. How to
perform double click using webdriver?
Ans- Actions act
= new Actions(driver);
act.doubleClick(webelement);
93.What is
the use of AutoIt?
Ans- Some times while doing testing with selenium, we get
stuck by some interruptions like a window based pop up. But selenium fails to
handle this as it has support for only web based application. To overcome this
problem we need to use AutoIT along with selenium script. AutoIT is a third
party tool to handle window based applications. The scripting language used is
VBScript.
94.How to
type text in a new line inside a text area?
Ans- element.sendKeys(“abhishek_line1.\n abhishek_Line2”);
use ? \n for new line.
95.How to
switch back from a frame?
Ans- driver.switchTo().defaultContent();
96.While
explaining the framework ensure that ur covering
1.What
is frame work
2.
Which frame work?
3. Why
This Frame work?
4.
Architecture
5.
Explanation of every component of frame work
6.
Process followed in frame work
7. How
& when u execute the frame work?
8.
Code (u must write code and explain)
9.
Result and reporting
10. u should be able to explain it for 20 Minutes
10. u should be able to explain it for 20 Minutes
97. What is
Datadriven framework & Keyword Driven?
Ans- Datadriven
framework- In this Framework , while Test case logic resides in Test Scripts,
the Test Data is separated and kept outside the Test Scripts.Test Data is read
from the external files (Excel File) and are loaded into the variables inside
the Test Script. Variables are used both for Input values and for Verification
values.To know more Please ClickHere.
Keyword Driven- The Keyword-Driven or Table-Driven framework requires the development of data tables and keywords, independent of the test automation tool used to execute them . Tests can be designed with or without the Application. In a keyword-driven test, the functionality of the application-under-test is documented in a table as well as in step-by-step instructions for each test.
Keyword Driven- The Keyword-Driven or Table-Driven framework requires the development of data tables and keywords, independent of the test automation tool used to execute them . Tests can be designed with or without the Application. In a keyword-driven test, the functionality of the application-under-test is documented in a table as well as in step-by-step instructions for each test.
98.How do
you send ENTER/TAB keys in webdriver?
Ans- use click() or submit() [submit() can be used only when
type='submit'])method for ENTER.
Or
act.sendKeys(Keys.ENTER);
For Tab-
act.sendKeys(Keys.TAB);
99. How do
you take screen shot?
Ans-
File srcFile =
((TakeScreenshot)driver).getScreenshotAs(OutputType.FILE); //now we can do
anything with this screenshot
like copy this to any folder-
FileUtils.copyFile(srcFile,new File(“folder name where u want
to copy/file_name.png”));
100. What is
the benefit of using TestNG?
Ans-
1- TestNG allows us to execute of test cases based on group.
2- In TestNG Annotations are easy to understand
3-Parallel execution of Selenium test cases is possible in
TestNG.
4- Three kinds of report generated
5- order of execution can be changed
6- failed test cases can be executed
7- without having main function we can execute the test
method.
8- An xml file can be generated to execute the entire test
suite. In that xml file we can rearrange our execution order and we can also
skip the execution of particular test case.
No comments:
Post a Comment