www.edureka.co/testing-with-selenium-webdriverEDUREKA’S SELENIUM CERTIFICATION TRAINING
www.edureka.co/testing-with-selenium-webdriverEDUREKA’S SELENIUM CERTIFICATION TRAINING Selenium Interview Questions & Answers  Explain the different exceptions in Selenium WebDriver?  What is exception test in Selenium?1 TimeoutException Thrown when command does not complete in enough time NoSuchElementException Thrown when Element with given attribute is not found ElementNotVisibleException Thrown when Element is present in DOM but not visible StaleElementException Thrown when Element is deleted or is no longer attached to DOM Exception Test @Test(expectedException = NoSuchElementException.class)
www.edureka.co/testing-with-selenium-webdriverEDUREKA’S SELENIUM CERTIFICATION TRAINING Selenium Interview Questions & Answers  Have you used Excel Sheet in your project?2 Excel Sheet is used as Data Source for tests and also contains Data Set for DataDriven Testing Data Source - Application URL for all environments - User name and Passwords for different environments - Test Cases to be executed Data Driven Test - Data for different iterations
www.edureka.co/testing-with-selenium-webdriverEDUREKA’S SELENIUM CERTIFICATION TRAINING Selenium Interview Questions & Answers  How can you redirect browsing from a browser through some proxy?3 Selenium provides PROXY class to redirect browsing from a proxy
www.edureka.co/testing-with-selenium-webdriverEDUREKA’S SELENIUM CERTIFICATION TRAINING Selenium Interview Questions & Answers  What is POM (Page Object Model)?  What are it’s advantages?4 • Page Object Model is a design pattern to create Object Repository for web UI elements. • Each web page in the application should have corresponding page class. • Page class will find the WebElements of that web page and also contains Page methods which perform operations on those WebElements. Advantages:- • Keep operations and flows in UI separate from Verification – clean &easy to understand code • Object Repository independent of Test Cases – multiple tests use same Object Repository • Reusability of code
www.edureka.co/testing-with-selenium-webdriverEDUREKA’S SELENIUM CERTIFICATION TRAINING Selenium Interview Questions & Answers  What is Page Factory?5 • Page Factory is an inbuilt Page Object Model concept for Selenium WebDriver which is very optimized • Separation of Page Object Repository and Test Methods • Page Factory Class provides @FindBy annotation to find WebElements • @FindBy can accept tagName, partialLinkText, name, linkText, id, css, className & xpath as attributes
www.edureka.co/testing-with-selenium-webdriverEDUREKA’S SELENIUM CERTIFICATION TRAINING Selenium Interview Questions & Answers  What are the different types of WAIT statements in Selenium WebDriver?  How do you achieve synchronization in WebDriver? 6 Implicit Wait • Instructs the web driver to wait for some time by polling the DOM. • Once you have declared implicit wait it will be available for the entire life of web driver instance. By default ,the value will be 0. If you set a longer default, then the behavior will poll the DOM on a periodic basis depending on the browser/driver implementation. Explicit Wait - Instructs the execution to wait for some time until some condition is achieved. Conditions: - elementToBeClickable - elementToBeSelected - presenceOfElementLocated
www.edureka.co/testing-with-selenium-webdriverEDUREKA’S SELENIUM CERTIFICATION TRAINING Selenium Interview Questions & Answers  Write a code to wait for a particular element to be visible on a page.  Write a code to wait for an alert to appear.7 WebDriverWait wait=new WebDriverWait(driver, 20); Element = wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath( “<xpath”))); WebDriverWait wait=new WebDriverWait(driver, 20); Element = wait.until(ExpectedConditions.alertIsPresent();
www.edureka.co/testing-with-selenium-webdriverEDUREKA’S SELENIUM CERTIFICATION TRAINING Selenium Interview Questions & Answers  What is the use of JavaScript Executor?8 JavaScriptExecutor is an interface which provides mechanism to execute Javascript through selenium driver. It provides “executescript” & "executeAsyncScript" methods, to run JavaScript in the context of the currently selected frame or window JavascriptExecutor js = (JavascriptExecutor) driver; js.executeScript(Script,Arguments);
www.edureka.co/testing-with-selenium-webdriverEDUREKA’S SELENIUM CERTIFICATION TRAINING Selenium Interview Questions & Answers  How to scroll down a page using JavaScript in Selenium?  How to scroll down to a particular element?9 ((JavascriptExecutor) driver).executeScript("window.scrollBy(0,500)"); ((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView();", element);
www.edureka.co/testing-with-selenium-webdriverEDUREKA’S SELENIUM CERTIFICATION TRAINING Selenium Interview Questions & Answers  How to handle keyboard and mouse actions using Selenium?10 • Handling special keyboard and mouse events are done using the Advanced User Interactions API. • It contains the Actions and the Action Classes that are needed for executing these events. • Commonly used keyboard and mouse events provided by the Actions class. Method Description clickAndHold() Clicks (without releasing) at the current mouse location. dragAndDrop() Performs click-and-hold at the location of the source element, moves source, target() to the location of the target element, then releases the mouse.
www.edureka.co/testing-with-selenium-webdriverEDUREKA’S SELENIUM CERTIFICATION TRAINING Selenium Interview Questions & Answers  How to send ALT/SHIFT/CONTROL key in Selenium WebDriver? Method: keyDown(modifier_key) Parameters: Modifier_key (keys.ALT or Keys.SHIFT or Keys.CONTROL) Purpose: Performs a modifier key press, doesn't release the modifier key. Subsequent interactions may assume it's kept pressed Method: keyUp(modifier_key) Parameters: Modifier_key (keys.ALT or Keys.SHIFT or Keys.CONTROL) Purpose: Performs a key release. 11
www.edureka.co/testing-with-selenium-webdriverEDUREKA’S SELENIUM CERTIFICATION TRAINING Selenium Interview Questions & Answers  How to send ALT/SHIFT/CONTROL key in Selenium WebDriver?11
www.edureka.co/testing-with-selenium-webdriverEDUREKA’S SELENIUM CERTIFICATION TRAINING Selenium Interview Questions & Answers  How to take screenshots in Selenium WebDriver?12
www.edureka.co/testing-with-selenium-webdriverEDUREKA’S SELENIUM CERTIFICATION TRAINING Selenium Interview Questions & Answers  How to set the size of browser window using Selenium?13 driver.manage().window().maximize(); - To maximize the window System.out.println(driver.manage().window().getSize()); Dimension d = new Dimension(420,600); driver.manage().window().setSize(d); - To resize the current window to the given dimension ((IJavascriptExecutor)driver).executeScript("window.resizeTo(1024, 768);"); - To set window to a particular size
www.edureka.co/testing-with-selenium-webdriverEDUREKA’S SELENIUM CERTIFICATION TRAINING Selenium Interview Questions & Answers  How to handle a dropdown in Selenium WebDriver?  How to select a value from dropdown?14 <select id="mySelect"> <option value="option1">France</option> <option value="option2">Italy</option> <option value="option3">Spain</option> </select> WebElement mySelectElement = driver.findElement(By.id("mySelect")); Select dropdown= new Select(mySelectElement); OR Select dropdown = new Select(driver.findElement(By.id("mySelect"))); 1. dropdown.selectByVisibleText("Italy"); 2. dropdown.selectByIndex(2); 3. dropdown.selectByValue(“option3”)
www.edureka.co/testing-with-selenium-webdriverEDUREKA’S SELENIUM CERTIFICATION TRAINING Selenium Interview Questions & Answers  How to switch to a new window (new tab) which opens up after you click on a link?15 driver.switchTo().window(<windowName>); driver.switchTo().frame(<iframeName>); driver.switchTo().alert(); If window name is not available String handle= driver.getWindowHandle(); for (String handle : driver.getWindowHandles()) { driver.switchTo().window(handle);}
www.edureka.co/testing-with-selenium-webdriverEDUREKA’S SELENIUM CERTIFICATION TRAINING Selenium Interview Questions & Answers  How can you fetch an attribute from an element?  How to retrieve typed text from a textbox?16 WebElement eLogin = driver.findElement(By.name(“Login”); String LoginClassName = eLogin.getAttribute("classname"); WebElement eLogin = driver.findElement(By.name(“Login”); String LoginText = Login.GetText ();
www.edureka.co/testing-with-selenium-webdriverEDUREKA’S SELENIUM CERTIFICATION TRAINING Selenium Interview Questions & Answers  How do you upload a file using Selenium WebDriver?17 <input type="file" name="uploaded_file" size="50" class="pole_plik"> element = driver.find_element_by_id(”uploaded_file") element.send_keys("C:myfile.txt")
www.edureka.co/testing-with-selenium-webdriverEDUREKA’S SELENIUM CERTIFICATION TRAINING Selenium Interview Questions & Answers  Can we enter text without using sendKeys()?18 Yes, text can be entered by using JavascriptExecutor. JavascriptExecutor jse = (JavascriptExecutor) driver; jse.executeScript("document.getElementById(‘Login').value=‘Test text without sendkeys");
www.edureka.co/testing-with-selenium-webdriverEDUREKA’S SELENIUM CERTIFICATION TRAINING Selenium Interview Questions & Answers  Explain how you will login into any site if it is showing any authentication popup for password and username?19 WebDriverWait wait = new WebDriverWait(driver, 10); Alert alert = wait.until(ExpectedConditions.alertIsPresent()); alert.authenticateUsing(new UserAndPassword(**username**, **password**));
www.edureka.co/testing-with-selenium-webdriverEDUREKA’S SELENIUM CERTIFICATION TRAINING Selenium Interview Questions & Answers  Explain how you can find broken links in a page using Selenium WebDriver?20 • Hyperlinks have anchor tags <a> • Get value of ‘href’ for all anchor tags on page from page source • Send a http request to each href • Analyze response to be equal to 200 - OK
www.edureka.co/testing-with-selenium-webdriverEDUREKA’S SELENIUM CERTIFICATION TRAINING Selenium Interview Questions & Answers  Which technique should you consider using throughout the script “if there is neither frame id nor frame name”?21 If neither id nor name is present for frame, then select frame by Index. Example:- Select a frame by its (zero-based) index. That is, if a page has three frames, the first frame would be at index "0", the second at index "1" and the third at index "2". Once the frame has been selected, all subsequent calls on the WebDriver interface are made to that frame. driver.switchTo().frame(int arg0);
www.edureka.co/testing-with-selenium-webdriverEDUREKA’S SELENIUM CERTIFICATION TRAINING Selenium Interview Questions & Answers  What is the significance of testng.xml?22 A test suite is a collection of test cases. In TestNG, we cannot define a suite in testing source code, but it is represented by one XML file, as suite is the feature of execution. It also allows flexible configuration of the tests to be run. A suite can contain one or more tests and is defined by the <suite> tag. - Allows execution of multiple test cases from multiple classes - Allows parallel execution - Allows execution of test cases in groups where a single test can belong to multiple groups
www.edureka.co/testing-with-selenium-webdriverEDUREKA’S SELENIUM CERTIFICATION TRAINING Selenium Interview Questions & Answers  What is parameterization in TestNG?  How to pass parameters using testng.xml?23 TestNG allows to define to parameters in the testng.xml file and then reference those parameters in Test Cases. public class ParameterizedTest1{ @Test @Parameters("myName") public void parameterTest(String myName) { System.out.println("Parameterized value is : " + myName); } }
www.edureka.co/testing-with-selenium-webdriverEDUREKA’S SELENIUM CERTIFICATION TRAINING Selenium Interview Questions & Answers <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" > <suite name=”CustomSuite"> <test name=”CustomTest”> <parameter name="myName" value=”John"/> <classes> <class name="ParameterizedTest1" /> </classes> </test> </suite>  What is parameterization in TestNG?  How to pass parameters using testng.xml?23
www.edureka.co/testing-with-selenium-webdriverEDUREKA’S SELENIUM CERTIFICATION TRAINING Selenium Interview Questions & Answers  Explain data providers in TestNG using an example. Can I call a single data provider method for multiple functions and classes?24 - DataProviders are used to pass complex parameters or parameters that need to be created from Java (complex objects, objects read from a property file or a database, etc…) - @DataProvider marks a method as supplying data for a test method. The annotated method must return an Object[] where each Object[] can be assigned to parameter list of the test method. - @Test method that wants to receive data from this DataProvider needs to use a DataProvider name equals to the name of this annotation. Yes same DataProvidor can be used in multiple functions and classes by declaring data provider in separate class and reusing it in multiple classes
www.edureka.co/testing-with-selenium-webdriverEDUREKA’S SELENIUM CERTIFICATION TRAINING Selenium Interview Questions & Answers  How to skip a method or a code block in TestNG?25 TestNG provides paramter to @Test annotation to enable or disable a test @Test(enabled = false) @Test(enabled = true) Default value is true
www.edureka.co/testing-with-selenium-webdriverEDUREKA’S SELENIUM CERTIFICATION TRAINING Selenium Interview Questions & Answers  What is soft assertion in Selenium?  How can you mark a test case as failed by using soft assertion?26 - Soft Assertions are customized error handler provided by TestNG - Soft Assertions do not through exceptions when assertion fails and continue with next test step - Used for multiple assertions To mark a test as failed with soft assertions call assertAll() method at the end of the test
www.edureka.co/testing-with-selenium-webdriverEDUREKA’S SELENIUM CERTIFICATION TRAINING Selenium Interview Questions & Answers  How does TestNG allow you to state dependencies?27 Dependency is a feature in TestNG that allows a test method to depend on a single or a group of test methods. Method dependency only works if the “depend-on-method” is part of the same class or any of the inherited base class (i.e. while extending a class). @Test(dependsOnMethods = { "initEnvironmentTest" })
www.edureka.co/testing-with-selenium-webdriverEDUREKA’S SELENIUM CERTIFICATION TRAINING Selenium Interview Questions & Answers  Explain it with an example.28
www.edureka.co/testing-with-selenium-webdriverEDUREKA’S SELENIUM CERTIFICATION TRAINING Selenium Interview Questions & Answers  Explain what is Group Test in TestNG?29
www.edureka.co/testing-with-selenium-webdriverEDUREKA’S SELENIUM CERTIFICATION TRAINING Selenium Interview Questions & Answers  What are different types of frameworks?  Which files can be used as data source for different frameworks?30 - Data Driven Framework - Keyword Driven Framework - Hybrid Framework Dataset can be provided using excel, xml, text, csv, etc type of file Framework Example
www.edureka.co/testing-with-selenium-webdriverEDUREKA’S SELENIUM CERTIFICATION TRAINING More Questions??
www.edureka.co/testing-with-selenium-webdriverEDUREKA’S SELENIUM CERTIFICATION TRAINING Course Details & Customer Reviews Go to www.edureka.co/testing-with-selenium-webdriver Get Edureka Certified in Selenium Today! Radha Muthian says, “I learned Selenium WebDriver and the course was very helpful to automate the Web Applications. The lifetime access of classes helps a lot to refer back and download the codes.” Vijay Krishnan says, “I have attended Selenium Web driver Certification with Edureka. The trainer has explained all the concepts of the course in detail manner which was very easy to understand. Worth for the money spent!!!!” Tom Tully says, “I wanted to learn Selenium Webdriver in a live, real course, not self paced, so there would be pressure on me to finish. Edureka accomplished this at a price far lower than an in-person class, and as far as I know they are the only internet class that has live lectures on this subject. Teacher was very knowledgeable. I learned basic use of Selenium. No problem with me being in US and teacher in India. They have US 800 number.” Suhas Kashyap says, “The online Course(Selenium Webdriver), which I took from Edureka was interactive and also helped me to improve my knowledge on selenium. Further helped me in changing the job as well. Thanks Edureka Team... :).”
www.edureka.co/testing-with-selenium-webdriverEDUREKA’S SELENIUM CERTIFICATION TRAINING

Selenium Interview Questions and Answers | Selenium Tutorial | Selenium Training | Edureka

  • 1.
  • 2.
    www.edureka.co/testing-with-selenium-webdriverEDUREKA’S SELENIUM CERTIFICATIONTRAINING Selenium Interview Questions & Answers  Explain the different exceptions in Selenium WebDriver?  What is exception test in Selenium?1 TimeoutException Thrown when command does not complete in enough time NoSuchElementException Thrown when Element with given attribute is not found ElementNotVisibleException Thrown when Element is present in DOM but not visible StaleElementException Thrown when Element is deleted or is no longer attached to DOM Exception Test @Test(expectedException = NoSuchElementException.class)
  • 3.
    www.edureka.co/testing-with-selenium-webdriverEDUREKA’S SELENIUM CERTIFICATIONTRAINING Selenium Interview Questions & Answers  Have you used Excel Sheet in your project?2 Excel Sheet is used as Data Source for tests and also contains Data Set for DataDriven Testing Data Source - Application URL for all environments - User name and Passwords for different environments - Test Cases to be executed Data Driven Test - Data for different iterations
  • 4.
    www.edureka.co/testing-with-selenium-webdriverEDUREKA’S SELENIUM CERTIFICATIONTRAINING Selenium Interview Questions & Answers  How can you redirect browsing from a browser through some proxy?3 Selenium provides PROXY class to redirect browsing from a proxy
  • 5.
    www.edureka.co/testing-with-selenium-webdriverEDUREKA’S SELENIUM CERTIFICATIONTRAINING Selenium Interview Questions & Answers  What is POM (Page Object Model)?  What are it’s advantages?4 • Page Object Model is a design pattern to create Object Repository for web UI elements. • Each web page in the application should have corresponding page class. • Page class will find the WebElements of that web page and also contains Page methods which perform operations on those WebElements. Advantages:- • Keep operations and flows in UI separate from Verification – clean &easy to understand code • Object Repository independent of Test Cases – multiple tests use same Object Repository • Reusability of code
  • 6.
    www.edureka.co/testing-with-selenium-webdriverEDUREKA’S SELENIUM CERTIFICATIONTRAINING Selenium Interview Questions & Answers  What is Page Factory?5 • Page Factory is an inbuilt Page Object Model concept for Selenium WebDriver which is very optimized • Separation of Page Object Repository and Test Methods • Page Factory Class provides @FindBy annotation to find WebElements • @FindBy can accept tagName, partialLinkText, name, linkText, id, css, className & xpath as attributes
  • 7.
    www.edureka.co/testing-with-selenium-webdriverEDUREKA’S SELENIUM CERTIFICATIONTRAINING Selenium Interview Questions & Answers  What are the different types of WAIT statements in Selenium WebDriver?  How do you achieve synchronization in WebDriver? 6 Implicit Wait • Instructs the web driver to wait for some time by polling the DOM. • Once you have declared implicit wait it will be available for the entire life of web driver instance. By default ,the value will be 0. If you set a longer default, then the behavior will poll the DOM on a periodic basis depending on the browser/driver implementation. Explicit Wait - Instructs the execution to wait for some time until some condition is achieved. Conditions: - elementToBeClickable - elementToBeSelected - presenceOfElementLocated
  • 8.
    www.edureka.co/testing-with-selenium-webdriverEDUREKA’S SELENIUM CERTIFICATIONTRAINING Selenium Interview Questions & Answers  Write a code to wait for a particular element to be visible on a page.  Write a code to wait for an alert to appear.7 WebDriverWait wait=new WebDriverWait(driver, 20); Element = wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath( “<xpath”))); WebDriverWait wait=new WebDriverWait(driver, 20); Element = wait.until(ExpectedConditions.alertIsPresent();
  • 9.
    www.edureka.co/testing-with-selenium-webdriverEDUREKA’S SELENIUM CERTIFICATIONTRAINING Selenium Interview Questions & Answers  What is the use of JavaScript Executor?8 JavaScriptExecutor is an interface which provides mechanism to execute Javascript through selenium driver. It provides “executescript” & "executeAsyncScript" methods, to run JavaScript in the context of the currently selected frame or window JavascriptExecutor js = (JavascriptExecutor) driver; js.executeScript(Script,Arguments);
  • 10.
    www.edureka.co/testing-with-selenium-webdriverEDUREKA’S SELENIUM CERTIFICATIONTRAINING Selenium Interview Questions & Answers  How to scroll down a page using JavaScript in Selenium?  How to scroll down to a particular element?9 ((JavascriptExecutor) driver).executeScript("window.scrollBy(0,500)"); ((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView();", element);
  • 11.
    www.edureka.co/testing-with-selenium-webdriverEDUREKA’S SELENIUM CERTIFICATIONTRAINING Selenium Interview Questions & Answers  How to handle keyboard and mouse actions using Selenium?10 • Handling special keyboard and mouse events are done using the Advanced User Interactions API. • It contains the Actions and the Action Classes that are needed for executing these events. • Commonly used keyboard and mouse events provided by the Actions class. Method Description clickAndHold() Clicks (without releasing) at the current mouse location. dragAndDrop() Performs click-and-hold at the location of the source element, moves source, target() to the location of the target element, then releases the mouse.
  • 12.
    www.edureka.co/testing-with-selenium-webdriverEDUREKA’S SELENIUM CERTIFICATIONTRAINING Selenium Interview Questions & Answers  How to send ALT/SHIFT/CONTROL key in Selenium WebDriver? Method: keyDown(modifier_key) Parameters: Modifier_key (keys.ALT or Keys.SHIFT or Keys.CONTROL) Purpose: Performs a modifier key press, doesn't release the modifier key. Subsequent interactions may assume it's kept pressed Method: keyUp(modifier_key) Parameters: Modifier_key (keys.ALT or Keys.SHIFT or Keys.CONTROL) Purpose: Performs a key release. 11
  • 13.
    www.edureka.co/testing-with-selenium-webdriverEDUREKA’S SELENIUM CERTIFICATIONTRAINING Selenium Interview Questions & Answers  How to send ALT/SHIFT/CONTROL key in Selenium WebDriver?11
  • 14.
    www.edureka.co/testing-with-selenium-webdriverEDUREKA’S SELENIUM CERTIFICATIONTRAINING Selenium Interview Questions & Answers  How to take screenshots in Selenium WebDriver?12
  • 15.
    www.edureka.co/testing-with-selenium-webdriverEDUREKA’S SELENIUM CERTIFICATIONTRAINING Selenium Interview Questions & Answers  How to set the size of browser window using Selenium?13 driver.manage().window().maximize(); - To maximize the window System.out.println(driver.manage().window().getSize()); Dimension d = new Dimension(420,600); driver.manage().window().setSize(d); - To resize the current window to the given dimension ((IJavascriptExecutor)driver).executeScript("window.resizeTo(1024, 768);"); - To set window to a particular size
  • 16.
    www.edureka.co/testing-with-selenium-webdriverEDUREKA’S SELENIUM CERTIFICATIONTRAINING Selenium Interview Questions & Answers  How to handle a dropdown in Selenium WebDriver?  How to select a value from dropdown?14 <select id="mySelect"> <option value="option1">France</option> <option value="option2">Italy</option> <option value="option3">Spain</option> </select> WebElement mySelectElement = driver.findElement(By.id("mySelect")); Select dropdown= new Select(mySelectElement); OR Select dropdown = new Select(driver.findElement(By.id("mySelect"))); 1. dropdown.selectByVisibleText("Italy"); 2. dropdown.selectByIndex(2); 3. dropdown.selectByValue(“option3”)
  • 17.
    www.edureka.co/testing-with-selenium-webdriverEDUREKA’S SELENIUM CERTIFICATIONTRAINING Selenium Interview Questions & Answers  How to switch to a new window (new tab) which opens up after you click on a link?15 driver.switchTo().window(<windowName>); driver.switchTo().frame(<iframeName>); driver.switchTo().alert(); If window name is not available String handle= driver.getWindowHandle(); for (String handle : driver.getWindowHandles()) { driver.switchTo().window(handle);}
  • 18.
    www.edureka.co/testing-with-selenium-webdriverEDUREKA’S SELENIUM CERTIFICATIONTRAINING Selenium Interview Questions & Answers  How can you fetch an attribute from an element?  How to retrieve typed text from a textbox?16 WebElement eLogin = driver.findElement(By.name(“Login”); String LoginClassName = eLogin.getAttribute("classname"); WebElement eLogin = driver.findElement(By.name(“Login”); String LoginText = Login.GetText ();
  • 19.
    www.edureka.co/testing-with-selenium-webdriverEDUREKA’S SELENIUM CERTIFICATIONTRAINING Selenium Interview Questions & Answers  How do you upload a file using Selenium WebDriver?17 <input type="file" name="uploaded_file" size="50" class="pole_plik"> element = driver.find_element_by_id(”uploaded_file") element.send_keys("C:myfile.txt")
  • 20.
    www.edureka.co/testing-with-selenium-webdriverEDUREKA’S SELENIUM CERTIFICATIONTRAINING Selenium Interview Questions & Answers  Can we enter text without using sendKeys()?18 Yes, text can be entered by using JavascriptExecutor. JavascriptExecutor jse = (JavascriptExecutor) driver; jse.executeScript("document.getElementById(‘Login').value=‘Test text without sendkeys");
  • 21.
    www.edureka.co/testing-with-selenium-webdriverEDUREKA’S SELENIUM CERTIFICATIONTRAINING Selenium Interview Questions & Answers  Explain how you will login into any site if it is showing any authentication popup for password and username?19 WebDriverWait wait = new WebDriverWait(driver, 10); Alert alert = wait.until(ExpectedConditions.alertIsPresent()); alert.authenticateUsing(new UserAndPassword(**username**, **password**));
  • 22.
    www.edureka.co/testing-with-selenium-webdriverEDUREKA’S SELENIUM CERTIFICATIONTRAINING Selenium Interview Questions & Answers  Explain how you can find broken links in a page using Selenium WebDriver?20 • Hyperlinks have anchor tags <a> • Get value of ‘href’ for all anchor tags on page from page source • Send a http request to each href • Analyze response to be equal to 200 - OK
  • 23.
    www.edureka.co/testing-with-selenium-webdriverEDUREKA’S SELENIUM CERTIFICATIONTRAINING Selenium Interview Questions & Answers  Which technique should you consider using throughout the script “if there is neither frame id nor frame name”?21 If neither id nor name is present for frame, then select frame by Index. Example:- Select a frame by its (zero-based) index. That is, if a page has three frames, the first frame would be at index "0", the second at index "1" and the third at index "2". Once the frame has been selected, all subsequent calls on the WebDriver interface are made to that frame. driver.switchTo().frame(int arg0);
  • 24.
    www.edureka.co/testing-with-selenium-webdriverEDUREKA’S SELENIUM CERTIFICATIONTRAINING Selenium Interview Questions & Answers  What is the significance of testng.xml?22 A test suite is a collection of test cases. In TestNG, we cannot define a suite in testing source code, but it is represented by one XML file, as suite is the feature of execution. It also allows flexible configuration of the tests to be run. A suite can contain one or more tests and is defined by the <suite> tag. - Allows execution of multiple test cases from multiple classes - Allows parallel execution - Allows execution of test cases in groups where a single test can belong to multiple groups
  • 25.
    www.edureka.co/testing-with-selenium-webdriverEDUREKA’S SELENIUM CERTIFICATIONTRAINING Selenium Interview Questions & Answers  What is parameterization in TestNG?  How to pass parameters using testng.xml?23 TestNG allows to define to parameters in the testng.xml file and then reference those parameters in Test Cases. public class ParameterizedTest1{ @Test @Parameters("myName") public void parameterTest(String myName) { System.out.println("Parameterized value is : " + myName); } }
  • 26.
    www.edureka.co/testing-with-selenium-webdriverEDUREKA’S SELENIUM CERTIFICATIONTRAINING Selenium Interview Questions & Answers <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" > <suite name=”CustomSuite"> <test name=”CustomTest”> <parameter name="myName" value=”John"/> <classes> <class name="ParameterizedTest1" /> </classes> </test> </suite>  What is parameterization in TestNG?  How to pass parameters using testng.xml?23
  • 27.
    www.edureka.co/testing-with-selenium-webdriverEDUREKA’S SELENIUM CERTIFICATIONTRAINING Selenium Interview Questions & Answers  Explain data providers in TestNG using an example. Can I call a single data provider method for multiple functions and classes?24 - DataProviders are used to pass complex parameters or parameters that need to be created from Java (complex objects, objects read from a property file or a database, etc…) - @DataProvider marks a method as supplying data for a test method. The annotated method must return an Object[] where each Object[] can be assigned to parameter list of the test method. - @Test method that wants to receive data from this DataProvider needs to use a DataProvider name equals to the name of this annotation. Yes same DataProvidor can be used in multiple functions and classes by declaring data provider in separate class and reusing it in multiple classes
  • 28.
    www.edureka.co/testing-with-selenium-webdriverEDUREKA’S SELENIUM CERTIFICATIONTRAINING Selenium Interview Questions & Answers  How to skip a method or a code block in TestNG?25 TestNG provides paramter to @Test annotation to enable or disable a test @Test(enabled = false) @Test(enabled = true) Default value is true
  • 29.
    www.edureka.co/testing-with-selenium-webdriverEDUREKA’S SELENIUM CERTIFICATIONTRAINING Selenium Interview Questions & Answers  What is soft assertion in Selenium?  How can you mark a test case as failed by using soft assertion?26 - Soft Assertions are customized error handler provided by TestNG - Soft Assertions do not through exceptions when assertion fails and continue with next test step - Used for multiple assertions To mark a test as failed with soft assertions call assertAll() method at the end of the test
  • 30.
    www.edureka.co/testing-with-selenium-webdriverEDUREKA’S SELENIUM CERTIFICATIONTRAINING Selenium Interview Questions & Answers  How does TestNG allow you to state dependencies?27 Dependency is a feature in TestNG that allows a test method to depend on a single or a group of test methods. Method dependency only works if the “depend-on-method” is part of the same class or any of the inherited base class (i.e. while extending a class). @Test(dependsOnMethods = { "initEnvironmentTest" })
  • 31.
    www.edureka.co/testing-with-selenium-webdriverEDUREKA’S SELENIUM CERTIFICATIONTRAINING Selenium Interview Questions & Answers  Explain it with an example.28
  • 32.
    www.edureka.co/testing-with-selenium-webdriverEDUREKA’S SELENIUM CERTIFICATIONTRAINING Selenium Interview Questions & Answers  Explain what is Group Test in TestNG?29
  • 33.
    www.edureka.co/testing-with-selenium-webdriverEDUREKA’S SELENIUM CERTIFICATIONTRAINING Selenium Interview Questions & Answers  What are different types of frameworks?  Which files can be used as data source for different frameworks?30 - Data Driven Framework - Keyword Driven Framework - Hybrid Framework Dataset can be provided using excel, xml, text, csv, etc type of file Framework Example
  • 34.
  • 35.
    www.edureka.co/testing-with-selenium-webdriverEDUREKA’S SELENIUM CERTIFICATIONTRAINING Course Details & Customer Reviews Go to www.edureka.co/testing-with-selenium-webdriver Get Edureka Certified in Selenium Today! Radha Muthian says, “I learned Selenium WebDriver and the course was very helpful to automate the Web Applications. The lifetime access of classes helps a lot to refer back and download the codes.” Vijay Krishnan says, “I have attended Selenium Web driver Certification with Edureka. The trainer has explained all the concepts of the course in detail manner which was very easy to understand. Worth for the money spent!!!!” Tom Tully says, “I wanted to learn Selenium Webdriver in a live, real course, not self paced, so there would be pressure on me to finish. Edureka accomplished this at a price far lower than an in-person class, and as far as I know they are the only internet class that has live lectures on this subject. Teacher was very knowledgeable. I learned basic use of Selenium. No problem with me being in US and teacher in India. They have US 800 number.” Suhas Kashyap says, “The online Course(Selenium Webdriver), which I took from Edureka was interactive and also helped me to improve my knowledge on selenium. Further helped me in changing the job as well. Thanks Edureka Team... :).”
  • 36.

Editor's Notes