Selenium Interview Questions - Cognizant Walk-ins & Referrals

unofficial referral jobs and walk ins jobs - Follow our blog for latest referral campaings in Cognizant

Selenium Interview Questions

Selenium Interview questions for 3+ yrs - May 2018

I will be updating this post as and when I resolve each question. You can also contribute if you are aware of the answer in the below comment section.

Java & selenium
1. Testng annotation
2.exceptions faced during automation
3.pom class
4. Explain ur framework
5.progrm to get value from dynamic web table
6.difference between interface and abstract class write example program
7. Write Java code for a prime number
8. Write Java code for multiplication n division without using operator
9.what is the max  working hour you have stretched to ?tell abt the most hectic release u were involved
10. Few questions abt agile methodology
11.are you familiar with Jenkins ?
12.Oops concept --polymorphism with an example

Manual:
1.Explain Test plan
2. When do u say Test execution is complete
3. What are Deliverables for test plan
4.Usability testing
5.Test case for a Property site
6.Severity priority example
7.Static dynamic
8.Verification in ur project
9. What u do if the requirement is very high level
10. How do u work as an only test engineer in Agile
11. How do u test the - Ve test cases
12.Exit criteria
13.Example for low priority high 14.severity bugs
15.Production sign off test cases

Common Selenium Interview Questions

1. Absolute path will start with root path (/) and Relative path will from current path (//)

2. Desired Capabilities help to set properties for the Web Driver. A typical use case would be to
set the path for the Firefox Driver if your local installation doesn't correspond to the default
settings.

3. Why we refer Firefox driver to the web driver inheritance?
web Driver driver = new FireFoxDriver();
WebDriver is an interface which contain several abstract methods such as get(...), findElamentBy(...) etc.
We simply create reference of web Driver and we can assign objects (Firefox driver, CromeDriver, IEDriver, Andriod driver etc) to it.
Ex :
WebDriver driver = new FireFoxDriver();-----------(1)
If we are using (1) we can do the same thing by using
FireFoxDriver driver = new FireFoxDriver();---------(2)
We can use (1) and (2) for same purpose but if we want to switch to another browser in same program
then again we have to create the object of other class as for example
CromeDriver driver = new CromeDriver();.
creating object of several class is not good. So we create the reference of WebDriver and
we assign the objects of another class as for example
WebDriver driver; // it is created only one time in the program
driver = new FireFoxDriver();// any where in the program
driver = new CromeDriver(); // any where in the program

4.Which is the best way to locate an element?
Finding elements by ID is usually going to be the fastest option.

5.What is the difference between thread.Sleep() and selenium. Set Speed ("2000")?
If the application is taking time to load the page then we use selenium.waitforpageload(" "). This command is doesn’t wait upto the given time whenever the page load is completed.
If the application is taking time to refresh the page, then we use Thread. Sleep ( ).it is a standard wait it simply wait to the given time.
selenium.setSpeed
1. Takes a single argument in string format
Ex: selenium.setSpeed("2000") - will wait for 2 seconds
2. Runs each command in after setSpeed delay by the number of milliseconds mentioned in set Speed.
thread.sleep
1. Takes a single argument in integer format
ex: thread. Sleep(2000) - will wait for 2 seconds
3. Waits for only once at the command given at sleep.

6. What is the difference between "GET" and "NAVIGATE" to open a web page in Selenium web driver?
Get method will get a page to load or get page source or get text that's all whereas navigate
will guide through the history like refresh, back, forward.For example if we want to move
forward and do some functionality and back to the home page this can be achieved
through navigate() only. driver.get will wait till the whole page gets loaded and driver.navigate
will just redirect to that page and will not wait.

7. How we can retrieve the dynamically changing Ids?
We have a hierarchy of locators and Facebook Is dynamic in nature,so we are not able to
use "id" for identification for after that we have remaining 7 locator's for that :2. xpath ()..
3. name..4. css.. 5. link text.. 6. partiallinktext...7.tag name. so u can use any one for
identifying it. Most probably u can use "xpath" or "css-locator" and if there r tag then
link text or partial-link text. it depend on u . But we never use id's in Ajax application
because it’s not possible.

8. What is the difference between driver.Close() and driver.Quit () method?
Close() - It is used to close the browser or page currently which is having the focus.
Quit() - It is used to shut down the web driver instance or destroy the web driver instance
(Close all the windows)

9. How to scroll web element?--not browser? (drag & drop)
WebElement element=driver.findElement(By.xpath("//div[@id='draggable']"));
Actions actn=new Actions(driver);
actn.dragAndDropBy(element, 50, 50).build().perform();

10. Customize the name of file going to be downloaded?
You have to download AUTO IT.exe file and has to be install and later you have create .au3 file (in this file you have to specify the commands in VB script like your file name, where have to save, it will be easy may be 3 or 4 steps ) using AUTOIT...then right click the .au3 file you have to compile ....after that you will
get the .exe file with the name of .au3 file ..In eclipse you will give the code like this
<----ProcessBuildder ps = new ProcessBuilder("path of the .exe file of au3") .start();--->

11. How to handleinternationalisation through web driver?
FirefoxProfile profile = new FirefoxProfile();
profile.set Preference("intl.accept_languages","jp");
Web driver driver = new FirefoxDriver(profile); driver.get(google.com) will open google in
Japanese Lang

12. How to run tests in multiple browser parallel?
Is there any other option other than selenium grid?

13. How to handle Ajax popup window?
By using getWindowHandles() and obj.switchTo.window(windowid) we can handle popups using
explicit wait and driver.swtchT0.window("name") commands for your requirements.

14. How to handle autocomplete box in web driver?
driver.findElement(By.id("your searchBox")).sendKeys("your partial keyword");
Thread.sleep(3000);
List< WebElement> listItems = driver.findElements(By.xpath("your list item locator"));
for (WebElement listItemsDetails: listItems){
String listvalues = listItemsDetails.getText();
System.out.println(listvalues); System.out.println(myElement);
if (listvalues.equals(“expected value”){
listItemsDetails.click();
Thread.sleep(2000); System.out.println("third");

}

No comments:

Post a Comment