These Selenium Interview questions will help you for your interview so prepare all and share your answers in comments. Also, if you have any new questions, please let us know in comments. Questions and Answers will be selected from your comments and added to this note.
SELENIUM WEB-DRIVER INTERVIEW QA
1. How to download and Install Java?
(a) Download the correct version of Java SE JDK (from http://www.oracle.com/technetwork/java/javase/downloads/) supported by your system. i.e., 32Bit JDK for 32 bit OS(WindowsX86). 64 bit JDK for 64 bit OS(WindowsX64).
(b) Install the executable Java file and then set System Variables in Environmental Properties.
Example: JAVA_HOME: C:\Program Files\Java\jdk1.8.0_144
(c) Check for Path Variable, Give one semicolon at the end and paste the bin path of Java Folder.
Example: Java Path Variable: ;C:\Program Files\Java\jdk1.8.0_144\bin;
(d) To check go to command prompt and type java -version. If Java version details are displayed then Java Installation is complete.
2. How to configure and Setup-Eclipse, Selenium, and TestNG?
ECLIPSE: Download the correct version of Eclipse (from http://www.eclipse.org/downloads/) i.e. 32 bit Eclipse if you have 32 bit JDK. 64 bit Eclipse if you have 64 bit JDK installed. It comes as a zip file. Just extract it to a folder of your choice. Then, start the .exe file of Eclipse inside the installed folder. If Java is not Installed, Eclipse will not be able to Initialize.
SELENIUM: Download Selenium Jars (from http://www.seleniumhq.org/download/). Extract the Zip files to a folder. Right click on your project in Eclipse in Package Explorer, and click on Properties. Navigate to Java build path and add all the selenium jars under the Libraries tab. You are done. Selenium is configured.
TESTNG: Open Eclipse and Navigate to Help > Install New Software> Type “http://beust.com/eclipse” in Work With box. Click on Next and then complete the Installation Steps. TestNG Installation is done. To check, navigate to Windows> Preferences and check if TestNG is present in the left panel or not. If yes, then congrats, TestNG is Installed.
3. What is the difference between IDE, RC and Webdriver?
IDE: 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.
RC: Selenium Remote Control (RC) is a test tool that allows you to write automated web application UI tests in any programming language against any HTTP website using any mainstream JavaScript-enabled browser. You first need to launch a separate application called Selenium Remote Control (RC) Server before you can start testing. The Selenium RC Server acts as a “middleman” between your Selenium commands and your browser.
WebDriver: WebDriver is a web automation framework that allows you to execute your tests against different browsers, not just Firefox (unlike Selenium IDE). WebDriver also enables you to use a programming language in creating your test scripts (not possible in Selenium IDE).
4. How to execute test cases in IE browser using Selenium Webdriver?
(a) First of all, download latest and correct version of The Internet Explorer Driver Server for webdriver (from http://docs.seleniumhq.org/download/ ). Check for 32 bit driver and 64 bit driver.
(b) Next, in our code we need to set the system property for IE driver as
System.setProperty(“webdriver.ie.driver”, “RelativepathofIEDriver\\IEDriverServer.exe”);
(c) Then, we can create the driver object as WebDriver driver = new InternetExplorerDriver();
5. What are the Challenges with IE browser in Selenium Webdriver?
(a) The path to the driver executable must be set by the webdriver.ie.driver.
(b) Protected Mode settings are not the same for all zones.
(c) Unexpected error Browser zoom level.
(d) SendKeys types character very slow when running script in IE browser.
(e) Untrusted SSL certificate error in IE browser.
6. What is the XPath plugin for Firefox?
Firebug is Add-on to Firefox browser. You can install it by going to Firefox browser–>Tools–>Add-ons–>Extensions–>search for Firbug–>Install. Once you install firebug, you will see firebug icon in Firefox browser at top right corner.
FirePath is Add-on to Firebug, Installation process is same like firebug. Open Firefox browser –>Tools–>Add-ons–>Extensions–>search for Firepath–>Install . Once you install Firepath, Restart the Firefox browser, open any website any open Firebug. In Firebug panel you can see Firepath , from where you can get readymade Xpath which you can use in script ahead.
7. How to handle Dynamic XPath in Selenium?
Different ways of writing dynamic XPath in Selenium are:Using Single Slash
Using Double Slash
Using Single Attribute
Using Multiple Attribute
Using AND
Using OR
Using contains()
Using starts_with()
Using text()
Using last()
Using position()
Using index()
Using following xpath axes
Using preceding xpath axes
Details: https://www.softwaretestingmaterial.com/dynamic-xpath-in-selenium/
8. What is XPath plugin for Chrome?
There is a way to find the xPath in Chrome without any plugin.
(a) Right click and select “inspect” on the item you are trying to find the xpath.
(b) Right click on the highlighted area on the console.
(c) Go to Copy then click Copy xpath.
9. How to verify Page title in Selenium Webdriver?
(a) Without using TestNG or Junit.
–String actualTitle = driver.getTitle();
–String expectedTitle = “BJS – Bangalore Job Seekers”;
–if(actualTitle.equals(expectedTitle)) System.out.println(“Matched”);
–else System.out.println(“Not Matched”);
or –if(actualTitle.contains(expectedTitle)) System.out.println(“True”);
–else System.out.println(“False”);
(b) By using JUnit or TestNG framework.
–String expectedTitle = “Welcome to BJS”;
–String actualTitle =driver.getTitle();
–Assert.assertEquals(expectedTitle, actualTitle);
or Assert.assertEquals(“Welcome to BJS”, driver.getTitle());
–Assert.assertTrue(actualTitle.contains(“Welcome to “));
10. How to work with Radio button and Checkbox in Selenium Webdriver?
In order to handle Radio buttons or Check boxes, we can find all the elements with the similar input type radio or check boxes or xpaths. Then, take those to a List <WebElement> data structures. Using the index, etc we can locate the radio button or check box and perform action on it..
Example:
List<WebElement> ele = driver.findElements(By.xpath(“//*[type=’radio’]”));
System.out.println(ele.size());
ele.get(2).click();
hi,your blog is very useful. all the questions are so challenging. thank you for posting all important questions.
http://www.trainingpune.in/selenium-training-in-pune.html