зеркало из https://github.com/microsoft/appium.git
Коммит
b31c85ee2a
|
@ -14,7 +14,7 @@ module.exports = function(grunt) {
|
|||
|
||||
grunt.initConfig({
|
||||
jshint: {
|
||||
all: ['*.js', 'app/*.js', 'app/test/unit/*.js', 'instruments/*.js', 'test/functional/*.js', 'test/unit/*.js', 'test/functional/appium/*.js', 'test/functional/testapp/*.js', 'test/functional/uicatalog/*.js', 'test/helpers/*.js', 'app/uiauto/appium/app.js', 'app/uiauto/appium/binding.js', 'app/uiauto/element.js', 'app/uiauto/appium/utility.js', 'app/uiauto/lib/instruments_client.js', 'app/uiauto/lib/status.js']
|
||||
all: ['*.js', 'app/*.js', 'app/test/unit/*.js', 'instruments/*.js', 'test/functional/*.js', 'test/unit/*.js', 'test/functional/appium/*.js', 'test/functional/testapp/*.js', 'test/functional/uicatalog/*.js', 'test/functional/webview/*.js', 'test/helpers/*.js', 'app/uiauto/appium/app.js', 'app/uiauto/appium/binding.js', 'app/uiauto/element.js', 'app/uiauto/appium/utility.js', 'app/uiauto/lib/instruments_client.js', 'app/uiauto/lib/status.js']
|
||||
, options: {
|
||||
laxcomma: true
|
||||
, es5: true
|
||||
|
@ -36,6 +36,9 @@ module.exports = function(grunt) {
|
|||
, UICatalog: {
|
||||
functional: ['test/functional/uicatalog/*.js']
|
||||
}
|
||||
, WebViewApp: {
|
||||
functional: ['test/functional/webview/*.js']
|
||||
}
|
||||
}
|
||||
, mochaTestConfig: {
|
||||
options: {
|
||||
|
|
|
@ -55,17 +55,17 @@ $.extend(au, {
|
|||
value: 'Unsupported orientation: ' + orientation
|
||||
};
|
||||
}
|
||||
var newOrientation = au.getScreenOrientation();
|
||||
var newOrientation = au.getScreenOrientation().value;
|
||||
if (newOrientation == orientation) {
|
||||
return {
|
||||
status: codes.Success.code
|
||||
, value: newOrientation
|
||||
};
|
||||
} else {
|
||||
console.log("returning error");
|
||||
return {
|
||||
status: codes.UnknownError.code
|
||||
, value: "Orientation change did not take effect"
|
||||
, value: "Orientation change did not take effect: expected " +
|
||||
orientation + " but got " + newOrientation
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ $.extend(au, {
|
|||
|
||||
, lookup: function(selector, ctx) {
|
||||
if (typeof selector === 'string') {
|
||||
var _ctx = this.mainWindow
|
||||
var _ctx = this.mainApp
|
||||
, elems = [];
|
||||
|
||||
if (typeof ctx === 'string') {
|
||||
|
|
|
@ -130,20 +130,6 @@ describeWd('calc app', function(h) {
|
|||
//});
|
||||
|
||||
|
||||
// TOFIX: THIS TEST ALWAYS RETURNS 'undefined' orientation
|
||||
// LOOKS like UIATargetClass.setDeviceOrientation is not working properly with simulator?
|
||||
//var testOrientation = function(specOrientation) {
|
||||
//it('should get and set the screen orientation - ' + specOrientation, function(done) {
|
||||
//h.driver.setOrientation(specOrientation, function(err, orientation) {
|
||||
//assert.equal(orientation, specOrientation);
|
||||
//h.driver.getOrientation(function(err, orientation) {
|
||||
//assert.equal(orientation, specOrientation);
|
||||
//done();
|
||||
//});
|
||||
//});
|
||||
//});
|
||||
//};
|
||||
//_.each(["PORTRAIT", "LANDSCAPE"], testOrientation);
|
||||
|
||||
it('should be able to get text of a button', function(done) {
|
||||
h.driver.elementsByTagName('button', function(err, els) {
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
/*global it:true */
|
||||
"use strict";
|
||||
|
||||
var describeWd = require("../../helpers/driverblock.js").describeForApp('UICatalog')
|
||||
, should = require('should');
|
||||
|
||||
describeWd('window handles', function(h) {
|
||||
it('getting handles should do nothing when no webview open', function(done) {
|
||||
h.driver.windowHandles(function(err, handles) {
|
||||
should.not.exist(err);
|
||||
handles.length.should.equal(0);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
|
@ -0,0 +1,21 @@
|
|||
/*global it:true */
|
||||
"use strict";
|
||||
|
||||
var describeWd = require("../../helpers/driverblock.js").describeForApp('WebViewApp')
|
||||
, _ = require('underscore')
|
||||
, should = require('should');
|
||||
|
||||
describeWd('orientation', function(h) {
|
||||
var testOrientation = function(specOrientation) {
|
||||
it('should get and set - ' + specOrientation, function(done) {
|
||||
h.driver.setOrientation(specOrientation, function(err, orientation) {
|
||||
orientation.should.eql(specOrientation);
|
||||
h.driver.getOrientation(function(err, orientation) {
|
||||
orientation.should.eql(specOrientation);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
_.each(["PORTRAIT", "LANDSCAPE"], testOrientation);
|
||||
});
|
|
@ -1,7 +1,7 @@
|
|||
/*global it:true */
|
||||
"use strict";
|
||||
|
||||
var describeWd = require("../../helpers/driverblock.js").describeForApp('UICatalog')
|
||||
var describeWd = require("../../helpers/driverblock.js").describeForApp('WebViewApp')
|
||||
, should = require('should');
|
||||
|
||||
describeWd('window handles', function(h) {
|
||||
|
@ -12,57 +12,32 @@ describeWd('window handles', function(h) {
|
|||
done();
|
||||
});
|
||||
});
|
||||
it('getting handles should do nothing when no webview open', function(done) {
|
||||
it('getting list should work after webview open', function(done) {
|
||||
h.driver.windowHandles(function(err, handles) {
|
||||
should.not.exist(err);
|
||||
handles.length.should.equal(0);
|
||||
handles.length.should.be.above(0);
|
||||
done();
|
||||
});
|
||||
});
|
||||
it('getting list should work after webview open', function(done) {
|
||||
h.driver.elementByName('Web, Use of UIWebView', function(err, el) {
|
||||
should.not.exist(err);
|
||||
el.click(function(err) {
|
||||
should.not.exist(err);
|
||||
h.driver.windowHandles(function(err, handles) {
|
||||
should.not.exist(err);
|
||||
handles.length.should.be.above(0);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
it('setting window should work', function(done) {
|
||||
h.driver.elementByName('Web, Use of UIWebView', function(err, el) {
|
||||
h.driver.windowHandles(function(err, handles) {
|
||||
should.not.exist(err);
|
||||
el.click(function(err) {
|
||||
handles.length.should.be.above(0);
|
||||
h.driver.window(handles[0], function(err) {
|
||||
should.not.exist(err);
|
||||
h.driver.windowHandles(function(err, handles) {
|
||||
should.not.exist(err);
|
||||
handles.length.should.be.above(0);
|
||||
h.driver.window(handles[0], function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
});
|
||||
});
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
it('clearing window should work', function(done) {
|
||||
h.driver.elementByName('Web, Use of UIWebView', function(err, el) {
|
||||
h.driver.windowHandles(function(err, handles) {
|
||||
should.not.exist(err);
|
||||
el.click(function(err) {
|
||||
handles.length.should.be.above(0);
|
||||
h.driver.window(handles[0], function(err) {
|
||||
should.not.exist(err);
|
||||
h.driver.windowHandles(function(err, handles) {
|
||||
h.driver.frame(null, function(err) {
|
||||
should.not.exist(err);
|
||||
handles.length.should.be.above(0);
|
||||
h.driver.window(handles[0], function(err) {
|
||||
should.not.exist(err);
|
||||
h.driver.frame(null, function(err) {
|
||||
should.not.exist(err);
|
||||
done();
|
||||
});
|
||||
});
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -188,8 +163,8 @@ describeWd('getSize', function(h) {
|
|||
loadWebView(h.driver, function() {
|
||||
h.driver.elementById('i_am_an_id', function(err, element) {
|
||||
element.getSize(function(err, size) {
|
||||
size.width.should.eql(964);
|
||||
size.height.should.eql(30);
|
||||
size.width.should.eql(304);
|
||||
size.height.should.eql(20);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -198,26 +173,12 @@ describeWd('getSize', function(h) {
|
|||
});
|
||||
|
||||
var loadWebView = function(driver, cb) {
|
||||
driver.elementByName('Web, Use of UIWebView', function(err, el) {
|
||||
driver.windowHandles(function(err, handles) {
|
||||
should.not.exist(err);
|
||||
el.click(function(err) {
|
||||
handles.length.should.be.above(0);
|
||||
driver.window(handles[0], function(err) {
|
||||
should.not.exist(err);
|
||||
driver.windowHandles(function(err, handles) {
|
||||
should.not.exist(err);
|
||||
handles.length.should.be.above(0);
|
||||
driver.elementByTagName('textField', function(err, elem) {
|
||||
elem.sendKeys("http://www.saucelabs.com/test/guinea-pig", function(err) {
|
||||
should.not.exist(err);
|
||||
driver.keys("\uE007", function(err) {
|
||||
should.not.exist(err);
|
||||
driver.window(handles[0], function(err) {
|
||||
should.not.exist(err);
|
||||
spinTitle('I am a page title - Sauce Labs', driver, cb);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
spinTitle('I am a page title - Sauce Labs', driver, cb);
|
||||
});
|
||||
});
|
||||
};
|
Загрузка…
Ссылка в новой задаче