Merge pull request #406 from jlipps/master

fix misc android issues raised by testsuite
This commit is contained in:
Sebastian Tiedtke
2013-04-08 18:55:59 -07:00
4 changed files with 16 additions and 8 deletions

View File

@@ -39,7 +39,7 @@ describeWd('basic', function(h) {
h.driver.elementByLinkText("foobar", function(err) {
should.exist(err);
err.status.should.equal(13);
err.cause.value.origValue.should.eql("link text is not a supported selector strategy");
err.cause.value.origValue.should.eql("Strategy link text is not valid.");
h.driver.elementByName("Animation", function(err, el) {
should.not.exist(err);
should.exist(el);

View File

@@ -27,6 +27,8 @@ describeWd('gestures', function(h) {
});
});
it('should click via x/y pct', function(done) {
// this test depends on having a certain size screen, obviously
// I use a nexus something or other phone style thingo
h.driver.execute("mobile: tap", [{x: 0.6, y: 0.8}], function(err) {
should.not.exist(err);
var next = function() {
@@ -34,7 +36,7 @@ describeWd('gestures', function(h) {
should.not.exist(err);
els[1].text(function(err, text) {
should.not.exist(err);
text.should.equal("Assets");
text.should.equal("Morse Code");
done();
});
});
@@ -106,7 +108,7 @@ describeWd('gestures', function(h) {
h.driver.elementByName("Views", function(err) {
// shouldn't be visible
should.exist(err);
h.driver.flick(0, -500, function(err) {
h.driver.flick(0, -100, function(err) {
should.not.exist(err);
h.driver.elementByName("Views", function(err, el) {
should.not.exist(err);

View File

@@ -1,6 +1,7 @@
package io.appium.android.bootstrap;
import io.appium.android.bootstrap.exceptions.AndroidCommandException;
import io.appium.android.bootstrap.exceptions.UnallowedTagNameException;
import java.util.ArrayList;
import java.util.HashMap;
@@ -35,10 +36,10 @@ public class AndroidElementClassMap {
* @throws AndroidCommandException
*/
public static String match(String selector_text)
throws AndroidCommandException {
throws AndroidCommandException, UnallowedTagNameException {
final AndroidElementClassMap inst = AndroidElementClassMap.getInstance();
if (inst.unallowed.contains(selector_text)) {
throw new AndroidCommandException(selector_text);
throw new UnallowedTagNameException(selector_text);
} else {
final String mappedSel = inst.map.get(selector_text);
if (mappedSel != null) {

View File

@@ -12,6 +12,7 @@ import io.appium.android.bootstrap.exceptions.AndroidCommandException;
import io.appium.android.bootstrap.exceptions.ElementNotFoundException;
import io.appium.android.bootstrap.exceptions.ElementNotInHashException;
import io.appium.android.bootstrap.exceptions.InvalidStrategyException;
import io.appium.android.bootstrap.exceptions.UnallowedTagNameException;
import io.appium.android.bootstrap.selector.Strategy;
import java.util.ArrayList;
@@ -61,7 +62,7 @@ public class Find extends CommandHandler {
+ " with the contextId: " + contextId);
final Boolean multiple = (Boolean) params.get("multiple");
final boolean isXpath = strategy.equals("xpath");
final boolean isXpath = strategy.equalsIgnoreCase("xpath");
if (isXpath) {
final JSONArray xpathPath = (JSONArray) params.get("path");
@@ -83,6 +84,8 @@ public class Find extends CommandHandler {
return getErrorResult(e.getMessage());
} catch (final ElementNotFoundException e) {
return getErrorResult(e.getMessage());
} catch (final UnallowedTagNameException e) {
return getErrorResult(e.getMessage());
} catch (final ElementNotInHashException e) {
return getErrorResult(e.getMessage());
} catch (final UiObjectNotFoundException e) {
@@ -101,6 +104,8 @@ public class Find extends CommandHandler {
} catch (final ElementNotFoundException e) {
return new AndroidCommandResult(WDStatus.NO_SUCH_ELEMENT,
e.getMessage());
} catch (final UnallowedTagNameException e) {
return getErrorResult(e.getMessage());
} catch (final AndroidCommandException e) {
return getErrorResult(e.getMessage());
} catch (final ElementNotInHashException e) {
@@ -173,7 +178,7 @@ public class Find extends CommandHandler {
*/
private UiSelector getSelector(final Strategy strategy, final String text,
final Boolean many) throws InvalidStrategyException,
AndroidCommandException {
AndroidCommandException, UnallowedTagNameException {
UiSelector sel = new UiSelector();
switch (strategy) {
@@ -225,7 +230,7 @@ public class Find extends CommandHandler {
*/
private UiSelector getSelectorForXpath(final JSONArray path,
final String attr, String constraint, final boolean substr)
throws AndroidCommandException {
throws AndroidCommandException, UnallowedTagNameException {
UiSelector s = new UiSelector();
JSONObject pathObj;
String nodeType;