selenium webdriver: tips and tricks
Post on 15-Apr-2017
616 Views
Preview:
TRANSCRIPT
www.edureka.co/testing-with-selenium-webdriver
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
www.edureka.co/testing-with-selenium-webdriver
Locating Web Elements
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
www.edureka.co/testing-with-selenium-webdriver
Which approach should I use?
Which approach should I use to
locate elements?
www.edureka.co/testing-with-selenium-webdriver
Handling waits the better way
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 )
www.edureka.co/testing-with-selenium-webdriver
Testing AJAX based Applications
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
www.edureka.co/testing-with-selenium-webdriver
Using Page Object Pattern
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
www.edureka.co/testing-with-selenium-webdriver
Writing Generalized Test Cases
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.
www.edureka.co/testing-with-selenium-webdriver
Thank You …
Questions/Queries/Feedback
Recording and presentation will be made available to you within 24 hours
top related