+ All Categories
Home > Technology > Selenium WebDriver: Tips and Tricks

Selenium WebDriver: Tips and Tricks

Date post: 15-Apr-2017
Category:
Upload: edureka
View: 606 times
Download: 3 times
Share this document with a friend
14
www.edureka.co/testing-with-selenium-webdriver Selenium WebDriver: Tips and Tricks
Transcript
Page 1: Selenium WebDriver: Tips and Tricks

www.edureka.co/testing-with-selenium-webdriver

Selenium WebDriver: Tips and Tricks

Page 2: Selenium WebDriver: Tips and Tricks

www.edureka.co/testing-with-selenium-webdriver

What will you learn today?

Locating web elements the better way

How to use waits?

Handling Ajax

Using Page Object Pattern

Writing code in generic way

Page 3: Selenium WebDriver: Tips and Tricks

www.edureka.co/testing-with-selenium-webdriver

Locating Web Elements

Page 4: Selenium WebDriver: Tips and Tricks

www.edureka.co/testing-with-selenium-webdriver

Locating Web Elements

Locating web elements on the web page is the fundamental thing while testing an application and there are lots of ways to achieve that, some of them are shown below

Page 5: Selenium WebDriver: Tips and Tricks

www.edureka.co/testing-with-selenium-webdriver

Which approach should I use?

Which approach should I use to

locate elements?

Page 6: Selenium WebDriver: Tips and Tricks

www.edureka.co/testing-with-selenium-webdriver

Handling waits the better way

Page 7: Selenium WebDriver: Tips and Tricks

www.edureka.co/testing-with-selenium-webdriver

Handling waits the better way

Most of the time while testing applications with Selenium your test scripts will fail because it could not find the element on the web page.

There are many ways to handle this problem.

Thread.sleep()

Implicit Wait

Explicit Wait ( e.g. WebDriverWait )

Page 8: Selenium WebDriver: Tips and Tricks

www.edureka.co/testing-with-selenium-webdriver

Testing AJAX based Applications

Page 9: Selenium WebDriver: Tips and Tricks

www.edureka.co/testing-with-selenium-webdriver

Testing AJAX based application with Selenium

Almost all of the new web applications use AJAX to load data dynamically based on user interaction. Since the AJAX changes the DOM dynamically and we don’t know how much time it will take to complete the AJAX call. The best way to test the AJAX based applications is to wait until AJAX call completes entirely

Page 10: Selenium WebDriver: Tips and Tricks

www.edureka.co/testing-with-selenium-webdriver

Using Page Object Pattern

Page 11: Selenium WebDriver: Tips and Tricks

www.edureka.co/testing-with-selenium-webdriver

Page Object Pattern

Page Object Pattern enhances test maintenance and reduces code duplication. When application changes, tests don’t change and only the code within the page object need to be changed

In Page Object Pattern each page is defined as its own class

Page 12: Selenium WebDriver: Tips and Tricks

www.edureka.co/testing-with-selenium-webdriver

Writing Generalized Test Cases

Page 13: Selenium WebDriver: Tips and Tricks

www.edureka.co/testing-with-selenium-webdriver

Writing Generalized Test Cases

Suppose you are writing test cases for testing a Flight Reservation Site (e.g. http://www.goibibo.com/ )

What If you have to test other similar Flight Reservation sites (e.g. http://www.makemytrip.com/ or http://www.cleartrip.com/ etc.).All these sites are designed in a similar way, its always a good idea to write test cases in a generalized way so that they can easily be refactored to test similar scenarios.

Page 14: Selenium WebDriver: Tips and Tricks

www.edureka.co/testing-with-selenium-webdriver

Thank You …

Questions/Queries/Feedback

Recording and presentation will be made available to you within 24 hours


Recommended