16

Click here to load reader

Selenium

Embed Size (px)

Citation preview

Page 1: Selenium

Selenium

Doron Segal • 03.03.2016

Page 2: Selenium

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...

Page 3: Selenium

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

Page 4: Selenium

selenium grid architecture diagram (General)

Page 5: Selenium

selenium grid architecture diagram (OpenTable)

Doron’s Mac

Selenium Grid

Selenium WebDriver

Selenium WebDriver

Selenium WebDriver

Page 6: Selenium

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

Page 7: Selenium

Questions?About● How Selenium Grid/Hub is working?● How’s the node get the tests?● how it’s run?● etc..

Great let’s continue...

Page 8: Selenium

Demo TimePart 1

Page 9: Selenium

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`

Page 10: Selenium

...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)

Page 11: Selenium

...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)

Page 12: Selenium

Demo Timepart 2

Page 13: Selenium

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...

Page 14: Selenium

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

Page 15: Selenium

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.

Page 16: Selenium

Thanks& QA

1. Links - you can find in the slideshow

2. I’ll give everyone access to the slideshow

3. Hope you’ll enjoy