Last active
May 13, 2017 00:15
-
-
Save marcelofarias/98f7531fa4d9ab9c5620fcdd3defc461 to your computer and use it in GitHub Desktop.
Sencha Test + Protractor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
ST.configureContext({ | |
init: function () { | |
var me = this, | |
webdriver = require('selenium-webdriver'), | |
protractor = require('protractor/built/ptor').protractor, | |
driverProviders = require('protractor/built/driverProviders'), | |
plugins = require('protractor/built/plugins'), | |
cfg = me.driverConfig, | |
host = cfg.host, | |
port = cfg.port, | |
caps = cfg.desiredCapabilities, | |
driver, browser, initProperties, config, originalExpect, | |
blockingProxyUrl = null; | |
// TODO user/password | |
driver = me.driver = new webdriver.Builder() | |
.withCapabilities(caps) | |
.usingServer('http://' + host + ':' + port + '/wd/hub') | |
.build(); | |
require('jasminewd2').init(driver.controlFlow(), webdriver); | |
// TODO this/driverConfig | |
config = { | |
allScriptsTimeout: 30 * 1000 | |
}; | |
initProperties = { | |
baseUrl: config.baseUrl, | |
rootElement: config.rootElement, | |
untrackOutstandingTimeouts: config.untrackOutstandingTimeouts, | |
params: config.params, | |
getPageTimeout: config.getPageTimeout, | |
allScriptsTimeout: config.allScriptsTimeout, | |
debuggerServerPort: config.debuggerServerPort, | |
ng12Hybrid: config.ng12Hybrid, | |
waitForAngularEnabled: true | |
}; | |
browser = new protractor.ProtractorBrowser( | |
driver, | |
initProperties.baseUrl, | |
initProperties.rootElement, | |
initProperties.untrackOutstandingTimeouts, | |
blockingProxyUrl | |
); | |
browser.plugins_ = new plugins.Plugins({}); | |
browser.ready = | |
browser.ready | |
.then(function () { | |
return browser.waitForAngularEnabled(initProperties.waitForAngularEnabled); | |
}) | |
.then(function () { | |
return driver.manage().timeouts().setScriptTimeout(initProperties.allScriptsTimeout); | |
}) | |
.then(function () { | |
return browser; | |
}); | |
protractor.browser = browser; | |
protractor.$ = browser.$; | |
protractor.$$ = browser.$$; | |
protractor.element = browser.element; | |
protractor.by = protractor.By = protractor.ProtractorBrowser.By; | |
protractor.ExpectedConditions = browser.ExpectedConditions; | |
global.browser = browser; | |
global.$ = browser.$; | |
global.$$ = browser.$$; | |
global.element = browser.element; | |
global.by = global.By = protractor.By; | |
global.ExpectedConditions = protractor.ExpectedConditions; | |
global.protractor = protractor; | |
return browser.get(me.subjectUrl); | |
}, | |
stop: function () { | |
return protractor.browser.quit(); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment