Top 20 Advanced Selenium Webdriver Coding Interview Questions of 2019
Question 1 - How to handle Alerts or Pop-Ups using Selenium Webdriver?
Answer - Alerts or javascript pop-ups can be handled by using commands of org.openqa.selenium.Alert class in Selenium Webdriver.
Read details - Alert Handling
Answer - Multiple browser tabs can be handled using Keys enumerator and switchTo() method.
Read details - Multiple Browser Tabs Handling
Question 3 - How to Achieve Code Reuseablity & Maintainablility in Selenium Code?
Answer - Code re-usability can be achieved by creating page methods (action methods) and use those methods in your test method code instead of direct selenium commands.
Read details - Code Re-usability in Selenium
Question 4 - How to Handle Dynamic Web Table in Selenium WebDriver?
Answer - We can handle dynamic web table by preparing dynamic xpath of table at runtime.
Question 5 - How to Extract Table Data/Read Table Data Using Selenium WebDriver?
Answer - We can extract table data by preparing dynamic xpath of table at runtime.
Read details - Extract Table Data
Question 6 - How to Take Partial Screenshot in Selenium Webdriver?
Answer - Partial screenshot can be taken by using org.openqa.selenium.Point class of Selenium. We can get height and width of the element by using Point class.
Read details - Take Partial Screenshot
Question 7 - How to take screenshot in Selenium Webdriver?
Answer - Screenshot can be taken by using org.openqa.selenium.TakesScreenshot class of Selenium.
Read details - Take Screenshot in Selenium
Question 8 - What is Actions class? What are its commands?
Answer - Actions class is used to handle Keyboard and Mouse Events. You need to import org.openqa.selenium.interactions.Actions in order to use Actions class.
Read details - Selenium Actions Class and It's Commands
Question 9 - How to upload a file in Selenium Webdriver?
Answer - Selenium can't directly interact with window dialogues but we can interact with them by keyboard interactions using Selenium's Keys class or Java's Robot class.
Read details - Upload File using Robot Class in Selenium
Question 10 - How to do Mouse hover in Selenium Webdriver?
Answer - Actions Class's Mouse Hover Command
Question 11 - What is TestNG? How it can be integrated with Selenium?
Answer - Selenium-TestNG Integration
Question 12 - How to create setup and teardown methods in TestNG?
Answer - Read - Selenium-TestNG Program Example
Question 13 - What is the difference b/w @BeforeClass, @BeforeMethod and @AfterClass, @AfterMethod in TestNG?
Answer - TestNG Annotations
Question 14 - How to set priority of test methods in TestNG?
Question 15 - How to scroll vertically and horizontally using Selenium Webdriver?
Answer - Scroll can be done in selenium using org.openqa.selenium.JavascriptExecutor
Example -
// Create object of JavascriptExecutor
JavascriptExecutor js = (JavascriptExecutor) driver;
// Vertical Scroll
js.executeScript("javascript:window.scrollBy(0,350)");
// Horizontal Scroll
js.executeScript("javascript:window.scrollBy(250,0)");
Question 16 - How to download file using Selenium Webdriver?
Answer - You can download a file using Robot class.
Example -
/* Download file by clicking on Save button of window dialog
*/ // Create object of Robot class Robot r = new Robot(); // Press Alt and S key, it will shift the focus to 'Save' button of Windows dialog r.keyPress(KeyEvent.VK_ALT); r.keyPress(KeyEvent.VK_S); // Now, release S and Alt key r.keyRelease(KeyEvent.VK_S); r.keyRelease(KeyEvent.VK_ALT); // Press Enter Key as Focus is on Save button, so it will be r.keyPress(KeyEvent.VK_ENTER); // Release Enter key r.keyRelease(KeyEvent.VK_ENTER);
Question 17 - How to switch to Nth browser window in Selenium Webdriver?
Answer - Code example -
Case 1:
// Create a Set and store all window handle ids in it SetAllWindowHandles = driver.getWindowHandles(); String window1 = (String) AllWindowHandles.toArray()[0]; String window2 = (String) AllWindowHandles.toArray()[1]; // Switch to window with id 2 driver.switchTo().window(window2);
Case 2 :
/* Moving Between all Windows */ for (String handle : driver.getWindowHandles()) { driver.switchTo().window(handle); }
Question 18 - How to handle ajax elements using Selenium Webdriver?
Answer - When we do Google search and a list of options matching to our keyword displayed on it's own without refreshing the page, is an example of ajax search. We can handle ajax elements using Explicit Wait in Selenium.
Read details - Automating Google Search using Explicit Wait
Question 19 - How to switch frames in Selenium Webdriver?
Answer - Code example -
// Move to frame
driver.switchTo().frame("Target Web element")
Question 20 - How to find broken links of a web page using Selenium Webdriver?
Top Posts -
- How to learn Selenium Webdriver in just 4 weeks
- Future of Selenium Automation testing as a career option
- Features and Future of Selenium Webdriver
- Most widely used automation testing tools
- Which has better career opportunities, Selenium Webdriver or QTP?
- What is the difference between Selenium IDE and Webdriver?
Subscribe FB Group Techlistic.com
Join Telegram channel at https://t.me/techlistic
Feel free to ask queries or share your thoughts in comments or email me.
The information which you have provided is very good. It is very useful who is looking for selenium interview questions
ReplyDeleteThe blog which you have posted is more impressive... thanks for sharing with us...
ReplyDeleteSelenium Training in Chennai
Selenium Course in Chennai
selenium certification in chennai
Best selenium Training Institute in Chennai
Selenium Training in Velachery
Selenium training in Adyar
Python Training in Chennai
Software testing training in chennai
JAVA Training in Chennai
Great blog thanks for sharing Instagram and Facebook have provided an amazing place for new brands to grow and flourish. We can find the perfect niche for your brand on the best social media marketing in chennai. Marketing through social media brings forth global audience without all these physical boundaries.
ReplyDeleteNice blog thanks for sharing Run your salon business successfully by tying up with the best beauty shop in Chennai - The Pixies Beauty Shop. With tons of prestigious brands to choose from, and amazing offers we’ll have you amazed.
ReplyDeleteExcellent blog thanks for sharing Set up a aesthetic work environment that employees love to spend time in and relieve their stress. Your company needs the best corporate gardening service in Chennai and Karuna Nursery Gardens in happy to oblige you in the endeavour to make your infrastructure something worth flaunting about.
ReplyDelete
ReplyDeleteغسيل خزانات بمكة شركة غسيل خزانات بمكة
غسيل خزانات بجدة شركة غسيل خزانات بجدة
غسيل خزانات بالدمام شركة غسيل خزانات بالدمام