click below
click below
Normal Size Small Size show me how
Selenium and TestNg
| Question | Answer |
|---|---|
| benefits of Selenium | - works with different programming languages (Python, Java, C#) -open source, free tool - can work on different browsers and operating systems |
| different locators | id, xPath, name, ClassName, Text, PartialText |
| difference between / and // | / selects only immediate child elements // selects all descendant elements anywhere in the documents |
| Page Object Model | design pattern in our frameworks to enhancee code maintainability, readability and reusability - seperation of concerns, page class and reusability |
| difference between CSS and xPath | xPath is slower and can go from parent to child and child to parent CSS is faster, can't go from child to parents but only parent to child |
| syntax of explicit wait for waiting element to be clickable | -applied to specific element with specific conditions - ElementToBeClickable, ElementToBeVisible, ElementToBeSelectable |
| handle dropdown | Select Object, and then SelectByIndex, SelectByVaule, and SelectByVisibleText |
| handle pop-ups | Alert.alert=switch.To.Alert Alert.Accept |
| difference between implicitily and explicitly wait | Implicit wait applied to all findElement methods to all elements to be loaded Explicit wait applied to specific element with specific condition |
| handle scroll up and scroll down | javascript executor then scroll up-down certain amount, click, navigate |
| difference between findElement and findElements method | -findElements finds single element and returns WebElement -findElements finds mulitple elements and returns list of webelements |
| handle pop-up window | alert.dismiss, or alert.accept |
| handle multiple windows | get main window ID and all window IDs, loop through each id and check which of those is not equal to main window id then switch to that window |
| upload file | find element by id then "file upload", send keys using file address, "file submit" and click |
| handle iFrames | by index, by ID, and by webElement |
| What is Maven and what are the benifits (TestNG) | -open source build automation and project management tool, promotes reproducibility and consistency within testing environment |
| manage your dependencies (TestNG) | using Maven |
| what Maven commands do you know (TestNG) | mvn Install. mvn Test, mvn clean and mvn compile |
| explain TestNg annotations you use in your project | -Test, Before/After method, Before/After class, Before/After test, Before/AFter suite and dataprovider |
| how do you prioritize test methods in automation (TestNG) | using @Test |
| how to run tests through Maven (TestNG) | using Maven surefire plugin |
| how do you generate report in TestNG | run "mvn test" command in terminal and it triggers sure-fire plugin that has location for testing.xml file to run tests - after execution html report under target folder |
| how dataprovider works in TestNg | Data Driver Testing, helps run test method multiple times with different sets of data |
| what is testing.xml file and why its needed | runner file that has classes with included groups - provides single location to define and organize test suites, group test cases into suites to use, and has exessive control over how its run |
| where to store configuration data (TestNG) | properties file |
| POM Desing Pattern and advantages (TestNG) | -used to store web element of each page to seperate classes - helps with code maintainability and reusability - have webelements and reusable methods in classes |
| difference between Hard assertion and Soft assertion (TestNG) | - hard assertion will stop test method at line where assertion fails - soft assertion will keep executing other assertions even if first failed, fails only when reaching .assertAll |
| TestBase class (TestNG) | before method and after method in class and inherit that class from test classes to avoid code duplication |
| how to group test cases (TestNG) | using @Test and defining groups thrrough <group> tag, such as smoke or regression |
| why we create WebDriver driver= new ChromeDriver(): instead ChromeDriver=new ChromeDriver(); (TestNG) | benefits in terms of flexibility and code reusability |
| rerun failed tests (TestNG) | testing-failed.xml file |