Click here to load reader
Upload
doron-segal
View
181
Download
0
Embed Size (px)
Citation preview
Selenium
Doron Segal • 03.03.2016
what is Seleinum
What?Selenium automates browsers.
Selenium HubSelenium-Grid (Also called Selenium-Hub) allows you run tests on different machines against different browser in parallel.
Selenium web driverSelenium WebDriver is the machine thats going to run the test for example Chrome-WebDriver, Firefox and etc...
Let’s start...So,
● Let’s think about the components (we have 3 here)
○ Your tests (in our case Javascript tests)
○ Selenium Hub (Running in mesos)
○ Selenium WebDriver firefox and chrome
selenium grid architecture diagram (General)
selenium grid architecture diagram (OpenTable)
Doron’s Mac
Selenium Grid
Selenium WebDriver
Selenium WebDriver
Selenium WebDriver
Links● Selenium Hub:
○ Github: https://github.com/opentable/Selenium-Hub
○ TeamCity Build: http://teamcity.otenv.com/project.html?projectId=Umami_SeleniumHub
○ Mesos Instance: http://selenium-hub.pp-uswest2.otenv.com/grid/console
● Selenium WebDriver
○ Chrome
■ TeamCity: http://teamcity.otenv.com/project.html?projectId=Umami_SeleniumHub_SeleniumNodeChrome
■ Github: https://github.com/opentable/Selenium-Node-Chrome
○ FireFox
■ TeamCity: http://teamcity.otenv.com/project.html?projectId=Umami_SeleniumHub_SeleniumFirefoxNode
■ Github: https://github.com/opentable/Selenium-Node-FireFox
Questions?About● How Selenium Grid/Hub is working?● How’s the node get the tests?● how it’s run?● etc..
Great let’s continue...
Demo TimePart 1
First Demo● Github: https://github.com/doron2402/webdriver.git● First Test - wiki.js
○ scenario: go to http://en.wikipedia.org/wiki/Wiki and find how many links we have inside the page○ We will be using the Hub: http://selenium-hub.pp-uswest2.otenv.com/wd/hub○ We will be running two instances `Chrome` and `Firefox`
● Second Test○ Scenario: Google my name find my personal website click on the link and get the title○ We will be using the Hub: http://selenium-hub.pp-uswest2.otenv.com/wd/hub○ We will be running two instances and `Firefox`
Let’s run it `node wiki.js ` & `node googleSearch.js`
...var browser = new webdriver.Builder() .usingServer('http://selenium-hub.pp-uswest2.otenv.com/wd/hub') .withCapabilities({'browserName': 'chrome'}) .build();
browser.get('http://en.wikipedia.org/wiki/Wiki');browser.findElements(webdriver.By.css('[href^="/wiki/"]')).then(function(links){ console.log('Browser1: Found', links.length, 'Wiki links.' ) browser.quit();});........
First Demo (wiki)
...var webdriver = require('selenium-webdriver');var browser = new webdriver.Builder() .usingServer('http://selenium-hub.pp-uswest2.otenv.com/wd/hub') .withCapabilities({'browserName': 'firefox' }) .build();
browser.get('https://www.google.com');browser.findElement(webdriver.By.name('q')).sendKeys('doron segal');browser.findElement(webdriver.By.name('btnG')).click();browser.wait(findTutsPlusLink, 2000).then(clickLink).then(logTitle).then(closeBrowser, handleFailure);........
First Demo (Google)
Demo Timepart 2
Let’s kick it up a notch
● Angular App● Protractor● Karama● Github: https://github.com/opentable/angular-tests.git● `npm start` to run the project (we will need to update my ip address for the selenium node to access my local computer)● `npm run protractor` to execute the test (we need to pass my ip address)● Let’s add a test...
Code
Write test on your local computer
Run
Run tests against the Hub
Merge
Merge your code to Master
Test
Run test from TeamCity
Deploy
When all tests passed we can deploy to prod
Next stepsUpgradeWe should upgrade our protractor version to the latest
ApproachWe should always think about acceptance/E2E tests, It’s part of deploying feature.
InnovateTests should always be innovate.
KISS
Tests should be simple to write & run.
Thanks& QA
1. Links - you can find in the slideshow
2. I’ll give everyone access to the slideshow
3. Hope you’ll enjoy