Thursday, November 28, 2013

Selenium Webdriver Interview Questions ---Part 2

Part 2 Selenium Webdriver Interview Questions With Answers

1.  What is webdriver?
 WebDriver is a simpler, more concise programming interface in addition to addressing some limitations in  the Selenium-RC API. Selenium-WebDriver was developed to better support dynamic web pages where elements of a page may change without the page itself being reloaded. WebDriver’s goal is to supply a well-designed object-oriented API that provides improved support for modern advanced web-app testing problems.
2.      What are the advantages of selenium2.0/webdriver?
    •         Need no server to start
    •     Easy to code
    •         Has sophisticated API to support wide verity of browsers.
    •     Supports to test dynamic UI web apps.

    3.      Difference between the selenium1.0 and selenium 2.0?
    Selenium 1.0
    Selenium 2.0/Webdriver
    1.      It ‘injected’ javascript functions into the browser when the browser was loaded and then used its javascript to drive the AUT within the browser.

    2.      Selenium server need to start to run tests
    3.      Has some loop-holes in supporting complex UI apps,Javascript security
    4.      No support for headless broswers
    1.      WebDriver makes direct calls to the browser using each browser’s native support for automation


    2.      Not needed unless tests are run on local machine.
    3.      Supports even drag and drop features and no security loop-holes
    4.      Supports htmlunit driver –headless browser runs fast



    4.      What are the Locators are there in selenium 2.0?
    It supports locators based on Id,name,xpath,dom,css,class,tagname
    5.      How to handle the Ajax Applications in Web driver?
    There are 2 types of waits webdriver supports to handle ajax applications to make webdrive sync to execution:
    Implicit wait :
    driver.manage().timeouts().implicitlyWait(20,TimeUnit.SECONDS);
    Explicit wait:   WebDriverWait, FluentWait
    WebElement strr = (new WebDriverWait(driver,30)).until(ExpectedConditions.presenceOfElementLocated(By.xpath("//*[starts-with(@id,'yui_3_4_0_1_137509')]/ul/li[2]/a")));
    This link explains better about handling ajax in webdriver.

    5.      How to handle the multiple windows in web driver?
                driver.switchTo().window(Window ID);

    6.      Difference between findelement() and findelements()?
         findELement will find the first matching element.

         findELements will all the matching elements. You'll probably need to loop through all the elements  returned.
    7.      How to handle the alerts in web driver?
        driver.switchTo().alert().accept();
     
    8.      How to take the screen shots in seelnium2.0?
                File src2 = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
                FileUtils.copyFile(src2,new File("d:\\sc2.jpeg"));
    9.      What is web driver architecture?
    Below link gives better idea of webdriver architecture:
    http://www.aosabook.org/en/selenium.html
    10.  What is the limitations of web driver?
    • Can not automate desktop applications, supports only web applications
    •  No inbuilt commands to generate good reports
    • Cannot support readily for new browsers

    No comments:

    Post a Comment

    TestNG - Can i use the 2 different data providers to same @test methods in TestNG?

    public Object [][] dp1 () { return new Object [][] { new Object [] { "a" , "b" }, new Obje...