Selenium Interview Questions

Ques 1. How do I copy a content from webpage and paste it in notepad in selenium and validate

Ans. using "driver.getAttribute("text");" to read text or label. Using "driver.getAttribute("valeu");" to read text box values.


Ques 2. Why do some projects use selenium with Java and some with c#? Are there any dvantages/disadvantages

Ans. Yes, You can do some project use selenium with java and C#. Many people prefer java these days in Market. Because We have very good support for Java with Selenium. Java is a platform independent. Java is taught in most of the colleges and schools since it’s free.


Ques 3. Can someone help me with one scenario to Automate: It's like, I am clicking on next button it is redirecting to next page but on next page some button is visible but loader on page is still loading I want to wait until that loader stop. How to wait until the loader stop?

Ans. WebDriverWait wait = new WebDriverWait(driver, 30); WebElement element = wait.until( ExpectedConditions.visibilityOfElementLocated(By.xpath("someButton")));


Ques 4. Which is better way of creating object repository in POM? 1. Page wise 2. In .properties file

Ans. Defining WebElements in Page Wise will be the Best.


Ques 5. how to get the value against supplier dropdown

Ans. u can try this WebElement ele=driver.findElement(By.xpath("//select[@id='editQuoteItemSupplierId']/option"); String value=ele.getAttribute("value");


Ques 6. What is best possible way to access a web element whose name Or case selector is keeps on changing. What should be xpath?

Ans. In such cases, you can use xpath using contains(). Might be some part of property of webelements remains same. You can even try with xpath using starts-with


Ques 7. I can go with customized xpath with the help of sibling or parent relationships

Ans. If u have some static element to decide xpath relative to it ... Then yes , go with that. Provided ur xpath doesnt ends up being too complex


Ques 8. What are the threads in testng? What is use of it?

Ans. TestNG provides multiple ways to execute tests in separate threads. In testng.xml, if we set 'parallel' attribute on the tag to 'tests', testNG will run all the '@Test' methods in tag in the same thread, but each tag will be in a separate thread. This helps us to run test methods / classes / tests in parallel.


Ques 9. We have 3 class is class a,class b and class c, how do we use methods present in classes a and b in c without creating an abject of class a and b

Ans. If we declare the method s of class A and B as static then in class c we can call those methods by using class name without creating any object. Without using class name and create object of a and b is it possible to call those methods into class c


Ques 10. Can I have two pom file and if yes how to execute two pom file separately from cmd. And How to execute both from cmd

Ans. Yes we can have multiple pom.xml files. And Wats the use of two.POM.xml


Post Question Details