ºÝºÝߣ

ºÝºÝߣShare a Scribd company logo
Copyright ? SELA Software & Education Labs, Ltd. | 14-18 Baruch Hirsch St., Bnei Brak 51202, Israel | www.selagroup.com
Cross Browser Platform in Automation
Testing
Oren Ashkenazy
Mail: orena@sela.co.il
Blog: http://blogs.microsoft.co.il/oren604/
Cross Platform Browser Testing
Intro to Selenium
Selenium Architecture
Selenium IDE
Selenium WebDriver
JavaScriptExecuter
WebDriverJS
Selenium Server
Agenda
Cross platform Browser Testing
Advantages¡­
? Greater Test Coverage
? Increased Reusability
? Business advantage
? Secure Deployment To Production
Test Plan
Multiple Test Plan Capacity Work
? ?????? ?? ??????????????
=
¡­
The Solution¡­
Selenium Architecture
Code Behind
Browser Drivers
C# Java Ruby Python 2
WebDriver API
IE Firefox Chrome Safari
Demo
Selenium IDE ¨C Record & Running A
Test
Demo
VS & Selenium Webdriver
IWebDriver Basic Methods
Actions
Clear();
Click();
FindElement(string);
Array/List FindElements(string,string¡­);
SendKeys(string);
Submit();
Explore
GetAttribute(); (Id, ClassName, etc)
GetCSSValue(); (font-size, color, etc)
Enable;
Selected();
Size();
Text;
IJavaScriptExecuter
Demo
Execute JS with Selenium WebDriver
Execute JS with Selenium WebDriver
Get the running browser agent/webdriver type
IJavaScriptExecutor js = (IJavaScriptExecutor)driver;
String BrowserAgent =
(String)((IJavaScriptExecutor)driver).ExecuteScript("
return navigator.userAgent;");
Execute JS with Selenium WebDriver
Pass browserAgent to the test method
public void FillAcountHolderData(IWebDriver driver, User user, string BrowserAgent)
{
if (BrowserAgent.Contains(¡°FireFox¡±)
} { // todo¡­.
}
if (BrowserAgent.Contains(¡°Chrome¡±)
{ // todo¡­.
}
}
Cross Platform Testing
Reference for automation browser platforms:
https://code.google.com/p/selenium/w/list?q=label:WebDriver
WebDriverJS
+ =
The difference between WebDriver to
WebDriverJS
Sync
Asynchronous
C# Java Ruby
JavaScript
Demo
WebDriverJS
Open source web testing frameworks
Selenium Server - Agenda
What Is Selenium Server?
What Is Selenium Grid?
Setting the hub (Server)
Setting the node (Client)
Using DesiredCapabilities
What Is Selenium Server?
Selenium
Code
Remote
Control
Selenium
Sever
IEFirefoxChromeSafari
Drivers
What Is Selenium Grid?
Selenium
Code
Remote
Control
Hub
Selenium Sever
(Win 7 +
Chrome)
Selenium Sever
(Win 8 + IE)
Selenium Sever
(Centos +
Firefox)
Chrome
Driver
IEDriver
Firefox
Driver
Demo
Setting the Hub
Install & Configure
? What to Install?
o JRE (Java Runtime Environment)
o Selenium Server (JAR File)
? How To Configure The Hub?
o Run CMD
o Go to the path you downloaded the Jar file: CD ¡°Path Name¡±
o Type the command: java -jar ¡°jar file name¡± -role hub
o After running this command you will receive an output of the
selenium server address (The default address is
http://127.0.0.1:4444
o Leave CMD window open while you want the selenium server
process to keep running
Demo
Setting up a server node
Setting up a server node
? How to configure?
o Run CMD
o Go to the path you downloaded the Jar file: CD ¡°Path
Name¡±
o Type the command: java -jar ¡°Jar File Name¡± -role node
-hub http://localhost:4444/grid/register
o Validate the node server is up by going to:
http://localhost:4444/grid/console
Demo
Running a Test
Use the RemoteWebDriver and
the DesiredCapabilities object to define which
browser, version and platform you wish to use
private IWebDriver driver = new RemoteWebDriver (new
Uri("http://localhost:4444/wd/hub"),
DesiredCapabilities.Firefox());
Running a test using the grid
In this example the test will run on machine/s that
have IOS and Firefox driver
private IWebDriver driver = new RemoteWebDriver(new
Uri("http://localhost:4444/wd/hub"),
new DesiredCapabilities("Firefox", "", new
Platform(PlatformType.Mac)));
Using a specific configuration
Selenium Grid Wiki
More information:
https://code.google.com/p/selenium/wiki/Grid2
Questions

More Related Content

Cross platform browser automation tests sdp

  • 1. Copyright ? SELA Software & Education Labs, Ltd. | 14-18 Baruch Hirsch St., Bnei Brak 51202, Israel | www.selagroup.com Cross Browser Platform in Automation Testing Oren Ashkenazy Mail: orena@sela.co.il Blog: http://blogs.microsoft.co.il/oren604/
  • 2. Cross Platform Browser Testing Intro to Selenium Selenium Architecture Selenium IDE Selenium WebDriver JavaScriptExecuter WebDriverJS Selenium Server Agenda
  • 3. Cross platform Browser Testing Advantages¡­ ? Greater Test Coverage ? Increased Reusability ? Business advantage ? Secure Deployment To Production
  • 5. Multiple Test Plan Capacity Work ? ?????? ?? ?????????????? =
  • 8. Selenium Architecture Code Behind Browser Drivers C# Java Ruby Python 2 WebDriver API IE Firefox Chrome Safari
  • 9. Demo Selenium IDE ¨C Record & Running A Test
  • 10. Demo VS & Selenium Webdriver
  • 11. IWebDriver Basic Methods Actions Clear(); Click(); FindElement(string); Array/List FindElements(string,string¡­); SendKeys(string); Submit(); Explore GetAttribute(); (Id, ClassName, etc) GetCSSValue(); (font-size, color, etc) Enable; Selected(); Size(); Text;
  • 13. Demo Execute JS with Selenium WebDriver
  • 14. Execute JS with Selenium WebDriver Get the running browser agent/webdriver type IJavaScriptExecutor js = (IJavaScriptExecutor)driver; String BrowserAgent = (String)((IJavaScriptExecutor)driver).ExecuteScript(" return navigator.userAgent;");
  • 15. Execute JS with Selenium WebDriver Pass browserAgent to the test method public void FillAcountHolderData(IWebDriver driver, User user, string BrowserAgent) { if (BrowserAgent.Contains(¡°FireFox¡±) } { // todo¡­. } if (BrowserAgent.Contains(¡°Chrome¡±) { // todo¡­. } }
  • 16. Cross Platform Testing Reference for automation browser platforms: https://code.google.com/p/selenium/w/list?q=label:WebDriver
  • 18. The difference between WebDriver to WebDriverJS Sync Asynchronous C# Java Ruby JavaScript
  • 20. Open source web testing frameworks
  • 21. Selenium Server - Agenda What Is Selenium Server? What Is Selenium Grid? Setting the hub (Server) Setting the node (Client) Using DesiredCapabilities
  • 22. What Is Selenium Server? Selenium Code Remote Control Selenium Sever IEFirefoxChromeSafari Drivers
  • 23. What Is Selenium Grid? Selenium Code Remote Control Hub Selenium Sever (Win 7 + Chrome) Selenium Sever (Win 8 + IE) Selenium Sever (Centos + Firefox) Chrome Driver IEDriver Firefox Driver
  • 25. Install & Configure ? What to Install? o JRE (Java Runtime Environment) o Selenium Server (JAR File) ? How To Configure The Hub? o Run CMD o Go to the path you downloaded the Jar file: CD ¡°Path Name¡± o Type the command: java -jar ¡°jar file name¡± -role hub o After running this command you will receive an output of the selenium server address (The default address is http://127.0.0.1:4444 o Leave CMD window open while you want the selenium server process to keep running
  • 26. Demo Setting up a server node
  • 27. Setting up a server node ? How to configure? o Run CMD o Go to the path you downloaded the Jar file: CD ¡°Path Name¡± o Type the command: java -jar ¡°Jar File Name¡± -role node -hub http://localhost:4444/grid/register o Validate the node server is up by going to: http://localhost:4444/grid/console
  • 29. Use the RemoteWebDriver and the DesiredCapabilities object to define which browser, version and platform you wish to use private IWebDriver driver = new RemoteWebDriver (new Uri("http://localhost:4444/wd/hub"), DesiredCapabilities.Firefox()); Running a test using the grid
  • 30. In this example the test will run on machine/s that have IOS and Firefox driver private IWebDriver driver = new RemoteWebDriver(new Uri("http://localhost:4444/wd/hub"), new DesiredCapabilities("Firefox", "", new Platform(PlatformType.Mac))); Using a specific configuration
  • 31. Selenium Grid Wiki More information: https://code.google.com/p/selenium/wiki/Grid2

Editor's Notes

  • #4: Greater Coverage ¨C More time for QA doing manual exploratory/risk-based testing. Increased Reusability ¨C Tests can be ran across different platforms and environments Business advantage ¨C we get to more users the more platform we support
  • #9: Selenium webdriver has 3 layers of architecture: Code Behind is the language we can use it¡¯s code to run selenium commands. These commands communicate with the WebDriver, the WebDriver contains set of common library which allow to send command to respective drivers through HTML and DOM. The driver listens to the commands from the code and simulate it on a real browser.
  • #13: 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. Why we use it? To enhance the capabilities of the existing scripts by performing javascript injection into our application under test. In simple words ?¡°Javascript can be executed within the browser with the help of JavaScript Executor.¡±
  • #18: As mentioned, WebDriver has a number of bindings for various languages like Ruby, Python etc. JavaScript being the language of choice for the web, is the latest one to make it to the list. So as you might guess, WebDriverJS is simply a wrapper over the JSON wire protocol exposing high level functions to make our life easy.
  • #21: WebdriverIO Selenium 2.0 bindings for NodeJS NightWatch Selenium 2.0 bindings for NodeJS with build in assertion framework PhantomJS ¨C No browser required Headless web testing. Page automation.?Access and manipulate?web pages with the standard DOM API, or with usual libraries like jQuery. Screen capture. Programmatically?capture web contents, including CSS, SVG and Canvas. Build server-side web graphics apps, from a screenshot service to a vector chart rasterizer. Network monitoring. Automate performance analysis, track?page loading?and export as standard HAR format.
  • #23: Selenium Sever allow us to run selenium tests on remote machines. The command will be send to the server and the server will execute the test by the selected driver.
  • #24: In Selenium Grid mode we have a network of servers that receives the commands through network hub, each set of command to a specific selenium server. Selenium Grid allows you to : Scale by distributing tests on several machines ( parallel execution ) Manage multiple environments from a central point, making it easy to run the tests against a vast combination of browsers / OS. Minimize the maintenance time for the grid by allowing you to implement custom hooks to leverage virtual infrastructure for instance.