From df6911c6119d1597afa69141c0adf7d8d6f83664 Mon Sep 17 00:00:00 2001 From: Jonathan Lipps Date: Mon, 8 Apr 2013 18:30:21 -0700 Subject: [PATCH 1/5] fix this test to correspond to new bootstrap error msg --- test/functional/apidemos/basic.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/functional/apidemos/basic.js b/test/functional/apidemos/basic.js index 8a1d04c9b..63512835a 100644 --- a/test/functional/apidemos/basic.js +++ b/test/functional/apidemos/basic.js @@ -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); From bea5d56971a7d777855f08244e2fcfe84e48ef5d Mon Sep 17 00:00:00 2001 From: Jonathan Lipps Date: Mon, 8 Apr 2013 18:30:46 -0700 Subject: [PATCH 2/5] need to check regardless of case now for xpath to work --- .../bootstrap/src/io/appium/android/bootstrap/handler/Find.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/uiautomator/bootstrap/src/io/appium/android/bootstrap/handler/Find.java b/uiautomator/bootstrap/src/io/appium/android/bootstrap/handler/Find.java index ab5f23831..26e325f62 100644 --- a/uiautomator/bootstrap/src/io/appium/android/bootstrap/handler/Find.java +++ b/uiautomator/bootstrap/src/io/appium/android/bootstrap/handler/Find.java @@ -61,7 +61,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"); From 1002dc7ab9517e4a65ad2089838eede9400e86a4 Mon Sep 17 00:00:00 2001 From: Jonathan Lipps Date: Mon, 8 Apr 2013 18:44:40 -0700 Subject: [PATCH 3/5] make sure we throw UnallowedTagNameException in that case --- .../appium/android/bootstrap/AndroidElementClassMap.java | 5 +++-- .../src/io/appium/android/bootstrap/handler/Find.java | 9 +++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/uiautomator/bootstrap/src/io/appium/android/bootstrap/AndroidElementClassMap.java b/uiautomator/bootstrap/src/io/appium/android/bootstrap/AndroidElementClassMap.java index 81de109cf..b06b21156 100644 --- a/uiautomator/bootstrap/src/io/appium/android/bootstrap/AndroidElementClassMap.java +++ b/uiautomator/bootstrap/src/io/appium/android/bootstrap/AndroidElementClassMap.java @@ -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) { diff --git a/uiautomator/bootstrap/src/io/appium/android/bootstrap/handler/Find.java b/uiautomator/bootstrap/src/io/appium/android/bootstrap/handler/Find.java index 26e325f62..136043539 100644 --- a/uiautomator/bootstrap/src/io/appium/android/bootstrap/handler/Find.java +++ b/uiautomator/bootstrap/src/io/appium/android/bootstrap/handler/Find.java @@ -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; @@ -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; From ba5f6d44ab1416beb180925f38dd8c4a790485a0 Mon Sep 17 00:00:00 2001 From: Jonathan Lipps Date: Mon, 8 Apr 2013 18:46:45 -0700 Subject: [PATCH 4/5] update test for phone form factor --- test/functional/apidemos/gestures.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/functional/apidemos/gestures.js b/test/functional/apidemos/gestures.js index 38acfa382..d4511c4b1 100644 --- a/test/functional/apidemos/gestures.js +++ b/test/functional/apidemos/gestures.js @@ -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(); }); }); From 8417f5c653fa2df7cfdc58866e28673e5ccbd3cf Mon Sep 17 00:00:00 2001 From: Jonathan Lipps Date: Mon, 8 Apr 2013 18:52:35 -0700 Subject: [PATCH 5/5] make speed flick test less flakey --- test/functional/apidemos/gestures.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/functional/apidemos/gestures.js b/test/functional/apidemos/gestures.js index d4511c4b1..b6ad25e93 100644 --- a/test/functional/apidemos/gestures.js +++ b/test/functional/apidemos/gestures.js @@ -108,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);