Get Started With Selenium 3 and Selenium 3 Grid
-
Upload
daniel-herken -
Category
Software
-
view
932 -
download
2
Transcript of Get Started With Selenium 3 and Selenium 3 Grid
![Page 2: Get Started With Selenium 3 and Selenium 3 Grid](https://reader035.fdocuments.net/reader035/viewer/2022062412/58714a6f1a28ab55588b66cf/html5/thumbnails/2.jpg)
Today we will cover
1. What is Selenium?2. How to setup a testing environment3. Running your first test4. Working with Selenium Grid5. Simplify with the BrowseEmAll Grid6. Q/A Session
Introduction
![Page 3: Get Started With Selenium 3 and Selenium 3 Grid](https://reader035.fdocuments.net/reader035/viewer/2022062412/58714a6f1a28ab55588b66cf/html5/thumbnails/3.jpg)
Supported by all major browser vendors:
What is Selenium?
Free and open source browser automation framework.
![Page 4: Get Started With Selenium 3 and Selenium 3 Grid](https://reader035.fdocuments.net/reader035/viewer/2022062412/58714a6f1a28ab55588b66cf/html5/thumbnails/4.jpg)
What is Selenium?
How does it work?
Your Code
![Page 5: Get Started With Selenium 3 and Selenium 3 Grid](https://reader035.fdocuments.net/reader035/viewer/2022062412/58714a6f1a28ab55588b66cf/html5/thumbnails/5.jpg)
What is Selenium?
How does it work?
Your Code Selenium
![Page 6: Get Started With Selenium 3 and Selenium 3 Grid](https://reader035.fdocuments.net/reader035/viewer/2022062412/58714a6f1a28ab55588b66cf/html5/thumbnails/6.jpg)
What is Selenium?
How does it work?
Your Code Selenium
IEDriver
EdgeDriver
FirefoxDriver
ChromeDriver
![Page 7: Get Started With Selenium 3 and Selenium 3 Grid](https://reader035.fdocuments.net/reader035/viewer/2022062412/58714a6f1a28ab55588b66cf/html5/thumbnails/7.jpg)
What is Selenium?
How does it work?
Your Code Selenium
IEDriver
EdgeDriver
FirefoxDriver
ChromeDriver
Internet Explorer
MicrosoftEdge
Firefox
Chrome
![Page 8: Get Started With Selenium 3 and Selenium 3 Grid](https://reader035.fdocuments.net/reader035/viewer/2022062412/58714a6f1a28ab55588b66cf/html5/thumbnails/8.jpg)
Supports automation of all major browsers:
What is Selenium?
Which browsers are supported?
![Page 9: Get Started With Selenium 3 and Selenium 3 Grid](https://reader035.fdocuments.net/reader035/viewer/2022062412/58714a6f1a28ab55588b66cf/html5/thumbnails/9.jpg)
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?
![Page 10: Get Started With Selenium 3 and Selenium 3 Grid](https://reader035.fdocuments.net/reader035/viewer/2022062412/58714a6f1a28ab55588b66cf/html5/thumbnails/10.jpg)
• Install Firefox: https://www.mozilla.org• Install Google Chrome: https://www.google.com/chrome/browser/desktop/• Add c:\Selenium (or similar path on macOS / Linux) to your PATH
Setup Selenium
Requirements
![Page 11: Get Started With Selenium 3 and Selenium 3 Grid](https://reader035.fdocuments.net/reader035/viewer/2022062412/58714a6f1a28ab55588b66cf/html5/thumbnails/11.jpg)
o Internet Explorer Driver:• Download (32bit or 64bit) http://www.seleniumhq.org/download/• Extract to c:\Selenium
o Edge Driver:• Download https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/• Copy to c:\Selenium
o Chrome Driver:• Download https://sites.google.com/a/chromium.org/chromedriver/• Copy to c:\Selenium
o Firefox Driver:• Download https://github.com/mozilla/geckodriver/releases• Extract to c:\Selenium
Setup Selenium
Installing Drivers
![Page 12: Get Started With Selenium 3 and Selenium 3 Grid](https://reader035.fdocuments.net/reader035/viewer/2022062412/58714a6f1a28ab55588b66cf/html5/thumbnails/12.jpg)
A Simple Test
Running a simple Google query[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(); }
![Page 13: Get Started With Selenium 3 and Selenium 3 Grid](https://reader035.fdocuments.net/reader035/viewer/2022062412/58714a6f1a28ab55588b66cf/html5/thumbnails/13.jpg)
A Simple Test
Demo
![Page 14: Get Started With Selenium 3 and Selenium 3 Grid](https://reader035.fdocuments.net/reader035/viewer/2022062412/58714a6f1a28ab55588b66cf/html5/thumbnails/14.jpg)
A Simple Test[TestMethod] public void GoogleForSelenium_Chrome() { IWebDriver driver = new ChromeDriver(); GoogleForSelenium(driver); }
[TestMethod] public void GoogleForSelenium_Edge() { IWebDriver driver = new EdgeDriver(); GoogleForSelenium(driver); }
[TestMethod] public void GoogleForSelenium_InternetExplorer() { IWebDriver driver = new InternetExplorerDriver(); GoogleForSelenium(driver); }
public void GoogleForSelenium(IWebDriver driver) {
// Navigate to google driver.Navigate().GoToUrl("http://www.google.com");
![Page 15: Get Started With Selenium 3 and Selenium 3 Grid](https://reader035.fdocuments.net/reader035/viewer/2022062412/58714a6f1a28ab55588b66cf/html5/thumbnails/15.jpg)
A Simple Test
Demo
![Page 16: Get Started With Selenium 3 and Selenium 3 Grid](https://reader035.fdocuments.net/reader035/viewer/2022062412/58714a6f1a28ab55588b66cf/html5/thumbnails/16.jpg)
Selenium Grid can be used to run Selenium tests parallel and on multiple machines. This helps with:
• Reducing the overall time of test execution• Running tests against browsers on different operating systems
Selenium Grid
What is Selenium Grid?
![Page 17: Get Started With Selenium 3 and Selenium 3 Grid](https://reader035.fdocuments.net/reader035/viewer/2022062412/58714a6f1a28ab55588b66cf/html5/thumbnails/17.jpg)
Selenium Grid
Your Code
![Page 18: Get Started With Selenium 3 and Selenium 3 Grid](https://reader035.fdocuments.net/reader035/viewer/2022062412/58714a6f1a28ab55588b66cf/html5/thumbnails/18.jpg)
Selenium Grid
How does it work?
Your Code RemoteDriver
![Page 19: Get Started With Selenium 3 and Selenium 3 Grid](https://reader035.fdocuments.net/reader035/viewer/2022062412/58714a6f1a28ab55588b66cf/html5/thumbnails/19.jpg)
Selenium Grid
How does it work?
Your Code RemoteDriver
SeleniumHub
![Page 20: Get Started With Selenium 3 and Selenium 3 Grid](https://reader035.fdocuments.net/reader035/viewer/2022062412/58714a6f1a28ab55588b66cf/html5/thumbnails/20.jpg)
Selenium Grid
How does it work?
Your Code RemoteDriver
SeleniumHub
Selenium Node
Selenium Node
SeleniumNode
![Page 21: Get Started With Selenium 3 and Selenium 3 Grid](https://reader035.fdocuments.net/reader035/viewer/2022062412/58714a6f1a28ab55588b66cf/html5/thumbnails/21.jpg)
1. Download Java: https://www.java.com/en/download/
2. Download Selenium Standalone Server: http://www.seleniumhq.org/download/• Copy to c:\Selenium
3. Start the Hub with the command line:• java -jar selenium-server-standalone-3.0.1.jar -role hub
4. Grid console available at: http://localhost:4444/grid/console
Selenium Grid
Setup a Hub
![Page 22: Get Started With Selenium 3 and Selenium 3 Grid](https://reader035.fdocuments.net/reader035/viewer/2022062412/58714a6f1a28ab55588b66cf/html5/thumbnails/22.jpg)
1. Create a node configuration file:{ "capabilities": [{ "browserName": "firefox", "platform": "WINDOWS", "maxInstances": 1 }],"maxSession": 5,"port": 5555,"register": true}
2. Start the Node with the command line:• java -jar selenium-server-standalone-3.0.1.jar -role node -hub
http://localhost:4444/grid/register -nodeConfig node.json
Selenium Grid
Setup a Node
![Page 23: Get Started With Selenium 3 and Selenium 3 Grid](https://reader035.fdocuments.net/reader035/viewer/2022062412/58714a6f1a28ab55588b66cf/html5/thumbnails/23.jpg)
Selenium Grid[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(); }
![Page 24: Get Started With Selenium 3 and Selenium 3 Grid](https://reader035.fdocuments.net/reader035/viewer/2022062412/58714a6f1a28ab55588b66cf/html5/thumbnails/24.jpg)
Selenium Grid
Demo
![Page 25: Get Started With Selenium 3 and Selenium 3 Grid](https://reader035.fdocuments.net/reader035/viewer/2022062412/58714a6f1a28ab55588b66cf/html5/thumbnails/25.jpg)
BrowseEmAll Grid
![Page 26: Get Started With Selenium 3 and Selenium 3 Grid](https://reader035.fdocuments.net/reader035/viewer/2022062412/58714a6f1a28ab55588b66cf/html5/thumbnails/26.jpg)
BrowseEmAll Grid[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(); }
![Page 27: Get Started With Selenium 3 and Selenium 3 Grid](https://reader035.fdocuments.net/reader035/viewer/2022062412/58714a6f1a28ab55588b66cf/html5/thumbnails/27.jpg)
BrowseEmAll Grid
Demo
![Page 28: Get Started With Selenium 3 and Selenium 3 Grid](https://reader035.fdocuments.net/reader035/viewer/2022062412/58714a6f1a28ab55588b66cf/html5/thumbnails/28.jpg)
Questions?
Q & A