Run Selenium Tests With Microsoft Test Manager

Post on 16-Apr-2017

280 views 5 download

transcript

Daniel Herkendherken@browseemall.comhttp://www.browseemall.com

Selenium Tests Using Microsoft Test Manager

MTM & Selenium

Today we will cover

1. What is Microsoft Test Manager?2. What is Selenium?3. Requirements & Setup4. Selenium on Test Agent5. BrowseEmAll on Test Agent

Introduction

What is Microsoft Test Manager?Microsoft Test Manager (MTM) is the test management framework by Microsoft. It support manual and automated testing side-by-side.

Supported by all major browser vendors:

What is Selenium?

Free and open source browser automation framework.

What is Selenium?

How does it work?

Your Code

What is Selenium?

How does it work?

Your Code Selenium

What is Selenium?

How does it work?

Your Code Selenium

IEDriver

EdgeDriver

FirefoxDriver

ChromeDriver

What is Selenium?

How does it work?

Your Code Selenium

IEDriver

EdgeDriver

FirefoxDriver

ChromeDriver

Internet Explorer

MicrosoftEdge

Firefox

Chrome

Supports automation of all major browsers:

What is Selenium?

Which browsers are supported?

Selenium language bindings are available for:

• Java• C#• Ruby• Python• JavaScript• Perl (third-party)• PHP (third-party)

What is Selenium?

Which programming languages are supported?

• Create new tests in Test Manager• Map tests to Unit Tests• Create Environment• Assign to Test Plan in Test Manager

Requirements & Setup

Configure Test Plan:

Requirements & Setup

Demo

• Install Java: https://java.com/en/download/ • Install Firefox: https://www.mozilla.org• Install Google Chrome: https://www.google.com/chrome/browser/desktop/• Add c:\Selenium to your PATH

Selenium on Test Agent

Requirements

o Internet Explorer Driver:• Download (32bit or 64bit) http://www.seleniumhq.org/download/• Extract to c:\Selenium

o Chrome Driver:• Download https://sites.google.com/a/chromium.org/chromedriver/• Extract to c:\Selenium

o Firefox Driver:• Download https://github.com/mozilla/geckodriver/releases• Extract to c:\Selenium

Selenium on Test Agent

Installing Drivers

Selenium on Test Agent[TestMethod] public void GoogleForSelenium() {      // Launch new instance for Firefox      IWebDriver driver = new FirefoxDriver();     

// Navigate to google      driver.Navigate().GoToUrl("http://www.google.com");     

// Find the input field for the search query      IWebElement inputField = driver.FindElement(By.Name("q"));     

// Add some text to the input field      inputField.SendKeys("Selenium");     

// Submit the search      inputField.Submit();     

// Google uses JS to render the results page so we need to wait       var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));      wait.Until(o => o.Title.StartsWith("Selenium", StringComparison.OrdinalIgnoreCase));     

// Use asserts like you would in unit tests      Assert.IsTrue(driver.Title.StartsWith("Selenium", StringComparison.OrdinalIgnoreCase));     

// close down the browser      driver.Quit(); }

Selenium on Test Agent

Demo

o Internet Explorer Driver:• Download (32bit or 64bit) http://www.seleniumhq.org/download/• Extract to c:\Selenium

o Chrome Driver:• Download https://sites.google.com/a/chromium.org/chromedriver/• Extract to c:\Selenium

o Firefox Driver:• Download https://github.com/mozilla/geckodriver/releases• Extract to c:\Selenium

BrowseEmAll on Test Agent

Installing Drivers

BrowseEmAll on Test Agent[TestMethod] public void GoogleForSeleniumOnGrid() {      // Launch new instance for Firefox      IWebDriver driver = new RemoteWebDriver(new Uri("http://localhost:4444/wd/hub"), DesiredCapabilities.Firefox());     

// Navigate to google      driver.Navigate().GoToUrl("http://www.google.com");     

// Find the input field for the search query      IWebElement inputField = driver.FindElement(By.Name("q"));     

// Add some text to the input field      inputField.SendKeys("Selenium");     

// Submit the search      inputField.Submit();     

// Google uses JS to render the results page so we need to wait       var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));      wait.Until(o => o.Title.StartsWith("Selenium", StringComparison.OrdinalIgnoreCase));     

// Use asserts like you would in unit tests      Assert.IsTrue(driver.Title.StartsWith("Selenium", StringComparison.OrdinalIgnoreCase));     

// close down the browser      driver.Quit(); }

BrowseEmAll on Test Agent

Demo

Questions?

Q & A