Selenium Interview Questions and Answers - Page 4

    0 Votes

30. How to call AutoIT script from Selenium Webdriver?

Runtime.getRuntime().exec("complete AutoIt .exe filepath");
31. Write down Selenium script to take screenshot
There are multiple ways to achieve the same, one of them is listed below :
WebDriver driver = new FirefoxDriver();
driver.get("http://www.google.com/");
File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
// Now you can do whatever you need to do with it, for example copy somewhere
FileUtils.copyFile(scrFile, new File("c:\\tmp\\screenshot.png"));

 

32. Name the fastest web driver
WebDriver driver = new HtmlUnitDriver(); //Headless browser
33. What are the Different frameworks available for JAVA Webdriver
  • Junit
  • TestNG

 

34. Best Automation Framework type preferred for Webdriver

Hybrid Framework – Its combination of both Data and Keyword Driven Framework

35. List down the basic browser commands

Get Webpage :

driver.get("wwww.google.com");

Get Title :

driver.getTitle();

Get Current URL :

driver.getCurrentUrl();

Get page source :

driver.getPageSource();

Close current window :

driver.close();

Quit the browser :

driver.quit();

36. What is TestNG?

TestNG is similar to Junit and an open source automated testing framework

37. What are the advantages of TestNG?

  • Ability to produce HTML reports
  • iAnnotations
  • Grouping and prioritizing made easy
  • Parallel execution of test
  • Parametrization

38. List annotations in TestNG

@BeforeSuite: The method will be run before all tests in this suite.
@AfterSuite: The method will be run after all tests in suite.
@BeforeTest: The method will be run before any test method belonging to the classes.
@AfterTest: The method will be run after all the test methods belonging to the classes.
@BeforeGroups: The list of groups that this configuration method will run before.
@AfterGroups: The list of groups that this configuration method will run after.
@BeforeClass: The method will be run before the first test method in the current class is invoked.
@AfterClass: The method will be run after all the test methods in the current class have been run.
@BeforeMethod: The method will be run before each test method.
@AfterMethod: The method will be run after each test method.
@Test: The method is a part of a test case.

39. Whar are the exceptions faced in Webdriver

Some of the exceptions faced are :

  • ElementNotVisibleException,
  • ElementNotSelectableException,
  • NoAlertPresentException,
  • NoSuchAttributeException,
  • NoSuchWindowException,
  • TimeoutException,
  • WebDriverException etc

40. Explain the ways to handle radio button

For radio button click :

WebElement radioButton = driver.findElement(By.id("radioID"));

radioButton.click();

To check if the radio button is selected :

List radioButton = driver.findElements(By.name("radioName")); 
boolean rValue = radioButton.get(0).isSelected();

NOTE : rValue will be set to true if selected, else false.

41. Explain the ways to handle Dropdown list

Selection :

dropDown.selectByVisibleText
dropDown.selectByIndex

Deselect :

dropDown.deselectAll();
dropDown.deselectByIndex(index);
dropDown.deselectByValue(value);
dropDown.deselectByVisibleText(text);

Page 4 of 4

Popular Videos

communication

How to improve your Interview, Salary Negotiation, Communication & Presentation Skills.

Got a tip or Question?
Let us know

Related Articles

Software Testing Interview Questions and Answers
Automation Testing Interview Questions and Answers