Scenario Base Automation Interview Questions || Automation Interview Questions
1. Different Exception in Automation
- TimeOut Exception - Did not perform action on time
- No Such Element Exception - Element not found, Element not located Implecit wait
- Element not visible Exception - Element not visible on page Explict wait
- Stale Element Exception
- webelements not located reload page or Attchement of DOM
2. What is exception Test in Selenium
- When you write @Test method if you are expecting some exception which will throw while executing the script then you have to write this exception in
@Test(expectedException=NoSuchElementException.class)
3. Which Files can be use as data source for different framework?
- Excel, xml, text, csv, json, property
4. How to send alt, shift, control key in selenium WebDrivers?
- By using Action class we can perform action
Keys.control + "a"
keys.control + "c"
Keys.ALT, Keys.SHIFT, Keys.CONTROL
5. How to switch to new window (new tab) which opens up after you click on A link ?
- Handle by using getwindow handles
Set<String> wid = driver.getwindowHandles();
Iterator<String> it = wid.iterator();
String pwid = it.next();
String cwid = it.next();
driver.switchTo.Window(cwid);
String title = driver.gettitle();
driver.close();
driver.switchTo().Window(pwid);
String ctitle = driver.gettitle();
driver.close();
6. How to upload file using selenium webdrivers?
- Webelement inputtype = driver.findElement(By.id("1"));
inputtype.sendkeys("Path of file");
7. How can we enter text withour using sendkeys? (Most IMP, Scenario Base Question)
- By using Java script executor
JavascriptExecutor jse = (JavascriptExecutor) driver;
jse.executeScript("document.getElementById("Login").value=Test Text without sendkeys");
8. Explain How you will login into any site if it is showing any authentication popup for username and password?
- When open any site then its displaying authentication popup for credentials by achrive using webdrivers wait
WebDriverWait w1 = new WebDriverWait(WebDriver driver, Duration.ofSeconds(20));
Alert a1 = w1.until(ExpectedConditions.alertIsPresent());
a1.authenticateUsing(New UserAndPassword(**Username**,**Password**));
9. How to you can find broken link in a page using selenium webdrivers?
- Store links by using <a> tag and check whether it is respose code is 200 then its ok if it is not then broken link
10. What is Parameterization in TestNG? How to Pass Paramers using TestNG.xml?
- @Test
@Paramers("browser")
public void get_browser(String browser){
if(browser.equals("chrome"))
{
WebDriverManager.chromedriver().setup()
driver = new ChromeDriver();
}
if(browser.equals("firefox)
{
WebDriverManager.firefoxdriver().setup();
driver = new forefoxdriver();
}
}
<suit>
<Test name="Cross Browser Test">
<Parameter name="browser" value="chrome"></parameter>
<classes>
<class name="packagename.class name"></class>
</classes>
</Test>
</suit>
11. Explain Data Providers in TestNG, Data provider method for multiple function and classes?
- We can achive using test data in excel, By usung Object[] assign paramter list
Data provider create seprate class and use that class in other methods
12. How to skip A method or a code block in TestNG?
- @Test(enabled=false) using we can skip @Test tag
13. What is soft Assertion in selenium? How can test case as fail by using Soft Assertion?
- Soft Assertion & Hard Assertion
- Soft Assertion can't stop execution its not throw exception
- At end write assertAll() method end of the code (it thows all exception)
14. What is Grouping Test in TestNG?
- Grouping is use for Segregate the test cases
15. How does TestNG dependent On Method use?
- It is dependednt on previous method, if previous method is pass then its exceute
@Test(dependsOnMethod="previous method name")
16. Is automation testing is Black Box or Whitebox testing?
- it is both black & white box testing
17. What is the need of database automation testing? is it possible to perform database TestNG with selenium?
- By using JDBC Connection, JDBC is an SQL Base java API that allow for connectivity between the java programming and various database.
- with JDBC we can execute db query
Connect Database
- DriverManager.getCOnnection(URL, "Userid","Password");
Load JDBC driver
Class.forName("com.mysql.jdbc.Driver");
18. Can we automate captcha or Recptcha? When we do for go for manual rather than Automation testing?
- Its not possible it is use for authentication perpose whether is Human or robot(automate)
20. What coding Standard every Automation engineer should use them?
- Follow proepr naming conventions
- Optimize the code, soft assert, Hard Assertion, AssertAll
- Do proper exception handling
- Do not use hard coded values
- Do not use Thread.sleep()
- Remove all comment code before push code to commit
- Ensure to implement a proper code review process
- Use relative xpath
- use proper comment
21. How to capture screenshot in selenium
- File Src ((Takescreenshot)driver).getScreenshotAs(OutputType.File);
- File destination = new File("filepath/filename.png");
- FileUtils.copyfile(Src,destination);
22. How to scroll page in selenium?
- we can scroll by using java script executor
JavascriptExecutor js = new (javascriptexecutor) driver;
js.exeutescript("arguement[0].scrollIntoView(true), element);
Comments
Post a Comment