Tools QA
Tools QA
Tools QA
1 driver.navigate().back();
2
3 driver.navigate().forward();
Ques 16) How do you get the current page URL ?
1 driver.getCurrentUrl();
Ques 17) What is the difference between ‘/’ and ‘//’ ?
Ans- //- it is used to search in the entire structure.
/- it is used to identify the immediate child.
Ques 18) What is the difference between findElement and findElements?
Ans- Both methods are abstract method of WebDriver interface and 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.
Ques 19) How do you achieve synchronization in WebDriver ?
Ans- We can use implicit wait.
Syntax- driver.manage().timeouts().implicitlyWait(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 with each and every line of the script automatically.
It is not required to write every time. Just write it once after opening the browser.
Ques 20) Write the code for Reading and Writing to Excel through Selenium ?
1 driver.findElement(By.xpath("xpath of box")).clear();
Ques 25) 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 , its basically combination of different frameworks.
(1+2+3).
Ques 26) What are the prerequisites to run selenium webdriver?
Ans- JDK, Eclipse, WebDriver(selenium standalone jar file), browser, application to be
tested.
Ques 27) What are the advantages of selenium webdriver?
Ans- 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 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 support to test iphone/Android applications.
Ques 28) What is WebDriverBackedSelenium ?
Ans- WebDriverBackedSelenium is a kind of class name where we can create an object
for it as below:
1 Selenium wbdriver= 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.
Ques 29) How to invoke an application in webdriver ?
1 driver.get(“url”); or driver.navigate().to(“url”);
Ques 30) 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, different browsers and operating systems. Essentially, Selenium-Grid support
distributed test execution. It allows for running your tests in a distributed test execution
environment.
Ques 31) How to get the number of frames on a page ?
1 driver.findElement(By.xpath("xpath of elemnt")).isDisplayed();
Ques 36) How to check if a button is enabled on the page ?
Ans- Use isEnabled() method. The return type of the method is boolean. So if it return
true then button is enabled else not enabled.
1 driver.findElement(By.xpath("xpath of button")).isEnabled();
Ques 37) How to check if a text is highlighted on the page ?
Ans- To identify weather color for a field is different or not-
1 String color = driver.findElement(By.xpath("//a[text()='Shop']")).getCssValue("color");
2
3 String backcolor = driver.findElement(By.xpath("//a[text()='Shop']")).getCssValue("background-color");
4
5 System.out.println(color);
6
7 System.out.println(backcolor);
Here if both color and back color different then that means that element is in different
color.
Ques 38) How to check the checkbox or radio button is selected ?
Ans- Use isSelected() method to identify. The return type of the method is boolean. So
if it return true then button is selected else not enabled.
1 driver.findElement(By.xpath("xpath of button")).isSelected();
Ques 39) How to get the title of the page ?
Ans- Use getTitle() method.
1 Syntax- driver.getTitle();
Ques 40) How do u get the width of the textbox ?
1 driver.get(“url1”);
2
3 driver.get(“url2”);
Ques 44) How to hover the mouse on an element ?
Part2
Ques 1) Can we enter text without using sendKeys() ?
Ans – Yes we can enter text without using sendKeys() method. We have to use
combination of javascript and wrapper classes with WebDriver extension class, check
the below code-
1 Syntax- http://username:password@url
2
3 ex- http://creyate:jamesbond007@alpha.creyate.com
Ques 5) What is the name of Headless browser.
Ans- HtmlUnitDriver.
Ques 6) Open a browser in memory means whenever it will try to open a
browser the browser page must not come and can perform the operation
internally.
Ans- use HtmlUnitDriver.
ex-
1 public class Memory {
2
3 public static void main(String[] args) {
4
5 HtmlUnitDriver driver = new HtmlUnitDriver(true);
6
7 driver.setJavascriptEnabled(false);
8
9 driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
10
11 driver.get("https://www.google.co.in/");
12
13 System.out.println(driver.getTitle());
14
15 }
16
17 }
Ques 7) What are the benefits of using TestNG ?
Ans-
a) TestNG allows us to execute of test cases based on group.
b) In TestNG Annotations are easy to understand.
c) Parallel execution of Selenium test cases is possible in TestNG.
d) Three kinds of report generated(Customization, PDF & Email)
e) Order of execution can be changed
f) Failed test cases can be executed
g) Without having main function we can execute the test method.
h) 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.
Ques 8) How do you take screen shot without using EventFiringWebDriver ?
Ans-
1 act.sendKeys(Keys.RETURN);
For Tab-
1 act.sendKeys(Keys.ENTER);
where act is Actions class type. ( Actions act = new Actions(driver); )
Ques 10) 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.
Keyword Driven framework- 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.
Ques 11) While explaining the framework, what are points which should be
covered ?
Ans-
a) What is the frame work.
b) Which frame work you are using.
c) Why This Frame work.
d) Architecture.
e) Explanation of every component of frame work.
f) Process followed in frame work.
g) How & when u execute the frame work.
h) Code (u must write code and explain).
i) Result and reporting .
j) You should be able to explain it for 20 Minutes.
Ques 12) How to switch back from a frame ?
Ans- use method defaultContent().
1 Syntax – driver.switchTo().defaultContent();
Ques 13) How to type text in a new line inside a text area ?
Ans- Use \n for new line.
1 try{
2
3 Assert.assertEquals(expUserName, actUserName);
4
5 }catch(Exception e){
6
7 Syste.out.println(“name is invalid”);
8
9 }