Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Selenium Grid on Azure and LambdaTest

kazweda
November 19, 2019

Selenium Grid on Azure and LambdaTest

macOSからNode.js+webdriverでAzure上に立てたSelenium Grid(hub + node)を使ってブラウザテストの自動化を試してみました。あわせてLambdaTestというサービスも利用してみました。それと、各種ブラウザを動かすためのwebdriverの組み込みにいろいろ手間取ったので、参考になりそうなサイトをまとめました。

kazweda

November 19, 2019
Tweet

More Decks by kazweda

Other Decks in Programming

Transcript

  1. 結果(Node.jsで試したこと) • Local環境で Node.js + webdriver Chrome, Firefox, Safari •

    Azure上のVM(Win10)でSelenium Grid Chrome, Firefox, Edge_HTML, Internet Explorer • LambdaTestアカウント登録 Chrome
  2. Selenium Grid on Azure AzureでVMを立てる - Windows 10 Pro 必要なものをインストール

    - JRE, Selenium Server, ... ネットワークの設定 - Port:4444 を受信可能に
  3. テスト自動化環境 - LambdaTest Cross Browser Testing Cloud Perform Automated and

    Live Interactive Cross Browser Testing on 2000+ Real Browsers and Operating Systems Online
  4. テスト自動化環境 - LambdaTest( code 1/3 ) // 基本設定 const webdriver

    = require('selenium-webdriver'); By = webdriver.By, until = webdriver.until; const USERNAME = '{username}'; const KEY = '{accessKey}'; const GRID_HOST = 'hub.lambdatest.com/wd/hub';
  5. テスト自動化環境 - LambdaTest( code 2/3 ) // テスト環境の設定 const capabilities

    = { platform: 'windows 10', browserName: 'chrome', version: '67.0', resolution: '1280x800', network: true, visual: true, console: true, video: true, name: 'Test 1', build: 'NodeJS build' }; // 接続先の設定 const gridUrl = 'https://' + USERNAME + ':' + KEY + '@' + GRID_HOST; // driverの設定 const driver = new webdriver .Builder() .usingServer(gridUrl) .withCapabilities(capabilities) .build();
  6. テスト自動化環境 - LambdaTest( code 3/3 ) // 実行部分 driver.get('https://www.google.com/ncr').then(function() {

    driver.findElement(webdriver.By.name('q')) .sendKeys('LambdaTest\n').then(function() { driver.getTitle().then(function(title) { setTimeout(function() { console.log(title); driver.quit(); }, 5000); }); }); }); } searchTextOnGoogle();
  7. geckodriverを導入してfirefoxのリモートテスト https://github.com/mozilla/geckodriver/releases/tag/v0.26.0 Known problems ??? Windows: You must still have

    the Microsoft Visual Studio redistributable runtime installed on your system for the binary to run. This is a known bug which we weren't able fix for this release. x64: vc_redist.x64.exe をダウンロードしてVM(Windows 10)にインストール。
  8. 参考資料 - Microsoft WebDriver Install Microsoft WebDriver https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/ Microsoft Edge

    (EdgeHTML) Microsoft WebDriver for Microsoft Edge version 18 is a Windows Feature on Demand. To install run the following in an elevated command prompt: DISM.exe /Online /Add-Capability /CapabilityName:Microsoft.WebDriver~~~~0.0.1.0
  9. ブラウザテストの自動化 - まとめ(妄想) • SaaS(LambdaTestとか...)を活用 ◦ 環境構築のコストダウン • ブラウザや機種に依存しそうなコードを避ける ◦

    そのスクリプト本当に必要ですか? • Edge(Chromium)が普及すれば心配が減るかも ◦ OSの違いはブラウザで吸収されるべき • Edge(Chromium)でテストできるなら ◦ Azure(Win10)はなくても良かった?
  10. 参考資料, ToDo • NodeJSサンプル • WebDriver on macOS • Edge(Chromium)

    support • Free VM - Microsoft • IE Test on Mac • モバイル実機+自動テスト • Browser Engines
  11. 参考資料 - WebDriverやNodeJSサンプルなど Selenium - Web Browser Automation https://www.seleniumhq.org/ selenium-webdriver

    - npm https://www.npmjs.com/package/selenium-webdriver Quick Guide To Run Node.js Test - LambdaTest https://www.lambdatest.com/support/docs/quick-guide-to-run-node-js-tests-on-lambdatest-selenium-grid/ Selenium testing with NodeJS - BrowserStack https://www.browserstack.com/automate/node Microsoft WebDriver https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/
  12. 参考資料 - Mozilla gecko driver for macOS https://firefox-source-docs.mozilla.org/testing/geckodriver/Notarization.html macOS notarization

    To bypass the notarization requirement on macOS if you have downloaded the geckodriver .tar.gz via a web browser, you can run the following command in a terminal: % xattr -r -d com.apple.quarantine geckodriver
  13. 参考資料 - Edge(Chromium) support Add new WebDriver support for Edge

    - JAVA https://github.com/SeleniumHQ/selenium/pull/7164 このスレッドの終わりの方に、 > What about JavaScript client for Selenium/Edge Chromium? Javascript is not our top priority for now, but there will definitely be more languages support in the future.
  14. 参考資料 - Free virtual machines - Microsoft Free virtual machines

    from IE8 to MS Edge - Microsoft Edge Development https://developer.microsoft.com/en-us/microsoft-edge/tools/vms/ • IE8 on Win7 • IE9 on Win7 • IE10 on Win7 • IE11 on Win81 • MSEdge on Win10 Windows Virtual Machine with Vagrant https://fishilico.github.io/generic-config/windows/vagrant.html
  15. 参考資料 - IE test on Mac Device 7 Ways to

    Test Your Website on Internet Explorer on a Mac Device https://dzone.com/articles/7-ways-you-can-test-your-website-on-internet-explo • Remote IE • Testing tools • Virtual Box • Hidden Safari Menu • WineBottler for Mac • VMWare • Boot Camp
  16. 参考資料 - Comparison of browser engines Wikipedia https://en.wikipedia.org/wiki/Comparison_of_browser_engines • WebKit

    (Safari) • Blink (Chrome, Edge_Chromium, Opera) • Gecko (Firefox, Thunderbird) • Edge_HTML • ...