index.js 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. // Docs aren't that great to find. Mostly JAVA based. Here are few helpful resources:
  2. // - https://www.browserstack.com/automate/node#testing-frameworks
  3. // - http://seleniumhq.github.io/selenium/docs/api/javascript/module/selenium-webdriver/firefox/index_exports_Driver.html
  4. // - https://github.com/SeleniumHQ/selenium/blob/c10e8a955883f004452cdde18096d70738397788/javascript/node/selenium-webdriver/test/upload_test.js
  5. //
  6. // - https://github.com/SeleniumHQ/selenium/wiki/WebDriverJs
  7. // - http://seleniumhq.github.io/selenium/docs/api/javascript/
  8. // - http://seleniumhq.github.io/selenium/docs/api/javascript/module/selenium-webdriver/firefox/index.html
  9. // - http://selenium.googlecode.com/git/docs/api/javascript/namespace_webdriver_By.html
  10. // - http://selenium.googlecode.com/git/docs/api/javascript/class_webdriver_WebElement.html
  11. require('babel-register')
  12. var webdriver = require('selenium-webdriver')
  13. var remote = require('selenium-webdriver/remote')
  14. var username = process.env.SAUCELABS_USERNAME
  15. var accessKey = process.env.SAUCELABS_ACCESS_KEY
  16. // if accessKey is supplied as env variable, this is a remote Saucelabs test
  17. var isRemoteTest = accessKey ? true : ''
  18. var host = isRemoteTest ? 'http://uppy.io' : 'http://localhost:4000'
  19. // FYI: old Chrome on Windows XP,
  20. // Opera 12 on Linux — didn’t pass
  21. var platforms = [
  22. // { browser: 'Opera', version: '12.15', os: 'Linux' },
  23. // { browser: 'iphone', version: '9.2', os: 'OS X 10.10' },
  24. // { browser: 'Safari', version: '8.0', os: 'OS X 10.10' },
  25. { browser: 'Internet Explorer', version: '10.0', os: 'Windows 8' },
  26. { browser: 'Internet Explorer', version: '11.103', os: 'Windows 10' },
  27. { browser: 'Firefox', version: '34.0', os: 'Windows 7' },
  28. { browser: 'Chrome', version: '48.0', os: 'Windows XP' },
  29. { browser: 'Firefox', version: '38.0', os: 'Linux' }
  30. ]
  31. var tests = [
  32. require('./multipart.spec.js'),
  33. require('./i18n.spec.js'),
  34. require('./dragdrop.spec.js')
  35. ]
  36. function buildDriver (platform) {
  37. var driver
  38. if (isRemoteTest) {
  39. driver = new webdriver
  40. .Builder()
  41. .withCapabilities({
  42. 'browserName': platform.browser,
  43. 'platform': platform.os,
  44. 'version': platform.version,
  45. 'username': username,
  46. 'accessKey': accessKey
  47. })
  48. .usingServer('http://' + username + ':' + accessKey +
  49. '@ondemand.saucelabs.com:80/wd/hub')
  50. .build()
  51. driver.setFileDetector(new remote.FileDetector())
  52. } else {
  53. driver = new webdriver
  54. .Builder()
  55. .forBrowser('firefox')
  56. .build()
  57. }
  58. return driver
  59. }
  60. if (isRemoteTest) {
  61. platforms.forEach(function (platform) {
  62. tests.forEach(function (test) {
  63. var driver = buildDriver(platform)
  64. test(driver, platform, host)
  65. })
  66. })
  67. } else {
  68. tests.forEach(function (test) {
  69. var driver = buildDriver()
  70. test(driver, { browser: 'Firefox', version: 'Version', os: 'Local' }, host)
  71. })
  72. }