understanding selenium/rc, webdriver architecture and developing the page object test automation...
TRANSCRIPT
![Page 1: Understanding Selenium/RC, Webdriver Architecture and developing the page object test automation framework](https://reader030.vdocuments.net/reader030/viewer/2022032514/55d4d742bb61ebe0488b46e7/html5/thumbnails/1.jpg)
Selenium WorkshopSelenium Workshop
By Atirek GuptaBy Atirek Gupta
![Page 2: Understanding Selenium/RC, Webdriver Architecture and developing the page object test automation framework](https://reader030.vdocuments.net/reader030/viewer/2022032514/55d4d742bb61ebe0488b46e7/html5/thumbnails/2.jpg)
Out of scopeOut of scope
When and why to do functional test automation.
Test specification.
Test data management.
Detailed architecture of Browser.
Going deeper into Java Script
Build tools, CI and VCS
![Page 3: Understanding Selenium/RC, Webdriver Architecture and developing the page object test automation framework](https://reader030.vdocuments.net/reader030/viewer/2022032514/55d4d742bb61ebe0488b46e7/html5/thumbnails/3.jpg)
AgendaAgenda
Origin of Selenium
Understanding same origin policy
Interacting with HTML using JavaScript
How Selenium-RC and WebDriver works
Locators
More about Selenium and WebDriver
Overview of how browser works
Exploring WebDriver API’s with examples
Building test automation framework using Java and WebDriver
![Page 4: Understanding Selenium/RC, Webdriver Architecture and developing the page object test automation framework](https://reader030.vdocuments.net/reader030/viewer/2022032514/55d4d742bb61ebe0488b46e7/html5/thumbnails/4.jpg)
Origin of SeleniumOrigin of Selenium
Selenium first came to life in 2004.
Selenium was written in pure JavaScript.
These scripts are injected into the web page, thus simulating user activity.
Limitations due to browser security policy called SOP(Same origin policy).
![Page 5: Understanding Selenium/RC, Webdriver Architecture and developing the page object test automation framework](https://reader030.vdocuments.net/reader030/viewer/2022032514/55d4d742bb61ebe0488b46e7/html5/thumbnails/5.jpg)
HTML DOM Tree of ObjectsHTML DOM Tree of Objects
![Page 6: Understanding Selenium/RC, Webdriver Architecture and developing the page object test automation framework](https://reader030.vdocuments.net/reader030/viewer/2022032514/55d4d742bb61ebe0488b46e7/html5/thumbnails/6.jpg)
Interacting with HTML using Interacting with HTML using JavaScriptJavaScript
JavaScript is a scripting language designed primarily for adding interactivity to Web pages.
Some JavaScript methods and interaction with browser e.g. document.getElementById(“id”).innerHtml =
“Some text” document.getElementById(“id”).click
Let’s do some hands on.
![Page 7: Understanding Selenium/RC, Webdriver Architecture and developing the page object test automation framework](https://reader030.vdocuments.net/reader030/viewer/2022032514/55d4d742bb61ebe0488b46e7/html5/thumbnails/7.jpg)
Understanding same origin Understanding same origin policy policy
![Page 8: Understanding Selenium/RC, Webdriver Architecture and developing the page object test automation framework](https://reader030.vdocuments.net/reader030/viewer/2022032514/55d4d742bb61ebe0488b46e7/html5/thumbnails/8.jpg)
How Selenium RC How Selenium RC worksworks
![Page 9: Understanding Selenium/RC, Webdriver Architecture and developing the page object test automation framework](https://reader030.vdocuments.net/reader030/viewer/2022032514/55d4d742bb61ebe0488b46e7/html5/thumbnails/9.jpg)
How How WebDriver WebDriver
worksworks
• It uses the browser’s native support for automation (different for each browser)
![Page 10: Understanding Selenium/RC, Webdriver Architecture and developing the page object test automation framework](https://reader030.vdocuments.net/reader030/viewer/2022032514/55d4d742bb61ebe0488b46e7/html5/thumbnails/10.jpg)
Browser SupportBrowser Support
Selenium-WebDriver supports the following browsers along with the operating systems these browsers are compatible with.
Google Chrome
Internet Explorer 6, 7, 8, 9, 10 - 32 and 64-bit where applicable
Firefox: latest ESR, previous ESR, current release, one previous release
Safari,Opera
HtmlUnit, Phantomjs
Android (with Selendroid or appium), iOS (with ios-driver or appium)
![Page 11: Understanding Selenium/RC, Webdriver Architecture and developing the page object test automation framework](https://reader030.vdocuments.net/reader030/viewer/2022032514/55d4d742bb61ebe0488b46e7/html5/thumbnails/11.jpg)
How Browser WorksHow Browser Works
![Page 12: Understanding Selenium/RC, Webdriver Architecture and developing the page object test automation framework](https://reader030.vdocuments.net/reader030/viewer/2022032514/55d4d742bb61ebe0488b46e7/html5/thumbnails/12.jpg)
LocatorsLocators
CSS
XPath
![Page 13: Understanding Selenium/RC, Webdriver Architecture and developing the page object test automation framework](https://reader030.vdocuments.net/reader030/viewer/2022032514/55d4d742bb61ebe0488b46e7/html5/thumbnails/13.jpg)
More about Selenium-More about Selenium-WebDriverWebDriver
How does WebDriver know if the page is completely loaded?
When document.readyState is “complete”
![Page 14: Understanding Selenium/RC, Webdriver Architecture and developing the page object test automation framework](https://reader030.vdocuments.net/reader030/viewer/2022032514/55d4d742bb61ebe0488b46e7/html5/thumbnails/14.jpg)
More about Selenium-More about Selenium-WebDriverWebDriver
What is StaleElementReferenceException
What causes them? Page Refresh JavaScript MVC frameworks Elements being re-rendered
![Page 15: Understanding Selenium/RC, Webdriver Architecture and developing the page object test automation framework](https://reader030.vdocuments.net/reader030/viewer/2022032514/55d4d742bb61ebe0488b46e7/html5/thumbnails/15.jpg)
More about Selenium-More about Selenium-WebDriverWebDriver
Can WebDriver execute javascript commands on DOM?
WebElement element = driver.findElement(By.id("gbqfd"));
JavascriptExecutor executor = (JavascriptExecutor)driver;
executor.executeScript("arguments[0].click();", element);
![Page 16: Understanding Selenium/RC, Webdriver Architecture and developing the page object test automation framework](https://reader030.vdocuments.net/reader030/viewer/2022032514/55d4d742bb61ebe0488b46e7/html5/thumbnails/16.jpg)
More about Selenium-More about Selenium-WebDriverWebDriver
Handling : Explicit and Implicit Waits.
driver.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS)
driver.manage().timeouts().pageLoadTimeout(10, TimeUnit.SECONDS);
WebElement element = (new WebDriverWait(driver,10))
.until(ExpectedConditions.elementToBeClickable(By.Id(“id”))).click
![Page 17: Understanding Selenium/RC, Webdriver Architecture and developing the page object test automation framework](https://reader030.vdocuments.net/reader030/viewer/2022032514/55d4d742bb61ebe0488b46e7/html5/thumbnails/17.jpg)
Hands on with Hands on with WebDriver API’sWebDriver API’s
Reference -
http://selenium.googlecode.com/git/docs/api/java/index.html
![Page 18: Understanding Selenium/RC, Webdriver Architecture and developing the page object test automation framework](https://reader030.vdocuments.net/reader030/viewer/2022032514/55d4d742bb61ebe0488b46e7/html5/thumbnails/18.jpg)
Key principle for designing / Key principle for designing / building an Automation building an Automation
Framework?Framework?
Readable
Re-Usable
Maintainable
Well Abstracted
Scalable
Browser support?
Tests to be run in distributed environment or on one machine?
…
![Page 19: Understanding Selenium/RC, Webdriver Architecture and developing the page object test automation framework](https://reader030.vdocuments.net/reader030/viewer/2022032514/55d4d742bb61ebe0488b46e7/html5/thumbnails/19.jpg)
Components of frameworkComponents of framework
![Page 20: Understanding Selenium/RC, Webdriver Architecture and developing the page object test automation framework](https://reader030.vdocuments.net/reader030/viewer/2022032514/55d4d742bb61ebe0488b46e7/html5/thumbnails/20.jpg)
Let’s codeLet’s code
![Page 21: Understanding Selenium/RC, Webdriver Architecture and developing the page object test automation framework](https://reader030.vdocuments.net/reader030/viewer/2022032514/55d4d742bb61ebe0488b46e7/html5/thumbnails/21.jpg)