Presentation is loading. Please wait.

Presentation is loading. Please wait.

Tata Consultancy Services1 WebDriver Basics Submitted By : Akhil K Gagan Deep Singh Naveenrajha H M Poornachandra Meduri Shubham Utsav Sunil Kumar G Vivek.

Similar presentations


Presentation on theme: "Tata Consultancy Services1 WebDriver Basics Submitted By : Akhil K Gagan Deep Singh Naveenrajha H M Poornachandra Meduri Shubham Utsav Sunil Kumar G Vivek."— Presentation transcript:

1 Tata Consultancy Services1 WebDriver Basics Submitted By : Akhil K Gagan Deep Singh Naveenrajha H M Poornachandra Meduri Shubham Utsav Sunil Kumar G Vivek M S

2 Tata Consultancy Services2 Introduction to WebDriver  WebDriver is used to automate Web and Android applications testing.  It is designed to provide a simpler, more concise programming interface.  Addresses some limitations in the Selenium-RC.  WebDriver also enables you to use a programming language in creating your test scripts.

3 Tata Consultancy Services3 What is WebDriver?  WebDriver is a web automation framework that allows you to execute your tests against different browsers.  Programming languages supported by WebDriver. Java.NET php Python Perl Ruby

4 Tata Consultancy Services4 Architecture  WebDriver's architecture is simpler than Selenium RC's.  It controls the browser from the OS level  All you need are your programming language's IDE (which contains your Selenium commands) and a browser.

5 Tata Consultancy Services5 WebDriver Features  Multi-browser testing including improved functionality for browsers not well-supported by Selenium Remote control (selenium 1.0)  Handling multiple frames, multiple browser windows, pop-ups, and alerts.  Complex Page navigation.  Advanced user navigation such as Drag-and-drop.  AJAX-based UI elements

6 Tata Consultancy Services6 Setting up Webdriver Please refer the attached video.(Setting up WebDriver.mp4)

7 Tata Consultancy Services7 Setting up WebDriver for other browers. Go to http://www.seleniumhq.org/download/http://www.seleniumhq.org/download/ Servers can be downloaded for other browsers like Opera, Chrome,Internet Explorer. Once these are installed,they need to be added to the referenced libraries in Eclipse. Then path must be set for each browse,giving the location of the exe file. Then create an instance of WebDriver. WebDriver driver=new OperaDriver(); WebDriver driver=new ChromeDriver();

8 Tata Consultancy Services8 A Simple Web Driver Script

9 Tata Consultancy Services9 Finding Elements Locating elements in WebDriver is done by using the "findElement(By.locator())" method. VariationDescriptionExample By.classNamefinds elements based on the value of the "class" attribute findElement(By.className("someClassName")) By.cssSelectorfinds elements based on the driver's underlying CSS findElement(By.cssSelector("input#email")) By.idlocates elements by the value of their "id" attribute findElement(By.id("someId")) By.linkTextfinds a link element by the exact text it displays findElement(By.linkText("REGISTRATION")) By.namelocates elements by the value of the "name" attribute findElement(By.name("someName")) By.partialLinkTextlocates elements that contain the given link text findElement(By.partialLinkText("REG")) By.tagNamelocates elements by their tag name findElement(By.tagName("div")) By.xpathlocates elements via XPathfindElement(By.xpath("//someXpath“))

10 Tata Consultancy Services10 A more Complex Script

11 Tata Consultancy Services11 Eg:- We fetch the values of a drop down into an array and use that variable to select the values into drop down Select dropDown = new Select(driver.findEleme nt(By.xpath("//*[@id='f rm:searchForm:departTim e0']"))); It selects the drop down element using it's Xpath and List dropvalues = dropDown.getOptions(); Collarates the options into the array using the List function. dropDown.selectByVisibl eText(dropvalues.get(i).getText()); Displays the options sequentially one by one.

12 Tata Consultancy Services12 Page Elements Instantiating Web ElementsAcess a particular element byinstantiating a WebElement object or by driver.findElement(By.locat or()). Clicking on an elementThe click() ethod is used to simulate the clicking of any element. Ge() commands fetch important information.  get()  getTitle()  GetPageSource()  getText()

13 Tata Consultancy Services13 Assert Commands When an "assert" command fails then test execution will be aborted. Assert is best used when the check value has to pass for the test to be able to continue to run. Like a log-in. Some Commands are: assertAlertPresent – checks whether an alert is present AssertAllButtons – compares the buttons present on the screen with the provided values in the test

14 Tata Consultancy Services14 assertChecked – verifies whether the particular checkbox is checked assertEditable – verifies the Edit box whether it is possible to key in values into the edit box assertSelectedValue – compares the given value with the selected value in the specified dropdown

15 Tata Consultancy Services15 Verify Commands When a "verify" command fails then test will continue executing and logging the failure. Verify is best used to check non critical things. Like the presence of a headline element Some Commands are: VerifyTextPresent : Verifies expected text is somewhere on the page VerifyElementPresent : verifies an expected UI element, as defined by its HTML tag, is present on the page

16 Tata Consultancy Services16 Clicking the Image Image links are images that act as references to other sites or sections within the same page. Since they are images we cannot use,the By.linkText() and By.partialLinkText() methods because image links basically have no link text at all.In this case we should resort to using either By.cssSelector or By.xpath.The first method is more preferred because of its simplicity.

17 Tata Consultancy Services17 Summary WebDriver is a tool for testing web applications across different browsers using different programming languages. WebDriver is faster than Selenium RC because of its simpler architecture. WebDriver's API is more concise than Selenium RC's. Webdriver supprots almost all browsers. Webdriver is used to automate Web and Android application testing. Webdriver also enables you to use a programming language in creating your test scripts. Webdriver is a webautomation framework that allows you to execute your tests against different browsers.

18 Tata Consultancy Services18 Webdriver controls the browser fromt he OS level. Locating elements in WebDriver is done by using the "findElement(By.locator())" method Image links are images that act as references to other sites or sections within the same page. When an "assert" command fails then test execution will be aborted. Assert is best used when the check value has to pass for the test to be able to continue to run. When a "verify" command fails then test will continue executing and logging the failure. Verify is best used to check non critical things.

19 Tata Consultancy Services19 THANK YOU


Download ppt "Tata Consultancy Services1 WebDriver Basics Submitted By : Akhil K Gagan Deep Singh Naveenrajha H M Poornachandra Meduri Shubham Utsav Sunil Kumar G Vivek."

Similar presentations


Ads by Google