Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Xpath implementation moved into bootstrap java project. XPath now les…
…s buggy and adheres to the full xpath spec. Finding by XPath now operates on the uncompressed xml hierarchy. Fixes #3307
- Loading branch information
Showing
11 changed files
with
379 additions
and
67 deletions.
There are no files selected for viewing
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
8 changes: 8 additions & 0 deletions
8
...s/android/bootstrap/src/io/appium/android/bootstrap/exceptions/PairCreationException.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package io.appium.android.bootstrap.exceptions; | ||
|
||
/** | ||
* For trying to create a ClassInstancePair and something goes wrong. | ||
*/ | ||
public class PairCreationException extends Throwable { | ||
public PairCreationException(String msg) { super(msg); } | ||
} |
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
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
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
23 changes: 23 additions & 0 deletions
23
lib/devices/android/bootstrap/src/io/appium/android/bootstrap/utils/ClassInstancePair.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package io.appium.android.bootstrap.utils; | ||
|
||
/** | ||
* Created by jonahss on 8/12/14. | ||
*/ | ||
public class ClassInstancePair { | ||
|
||
private String androidClass; | ||
private String instance; | ||
|
||
public ClassInstancePair(String clazz, String inst) { | ||
androidClass = clazz; | ||
instance = inst; | ||
} | ||
|
||
public String getAndroidClass() { | ||
return androidClass; | ||
} | ||
|
||
public String getInstance() { | ||
return instance; | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
lib/devices/android/bootstrap/src/io/appium/android/bootstrap/utils/XMLCleanser.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package io.appium.android.bootstrap.utils; | ||
|
||
import java.io.*; | ||
import java.util.regex.Matcher; | ||
import java.util.regex.Pattern; | ||
|
||
public class XMLCleanser { | ||
|
||
// | ||
private static Pattern pattern = Pattern.compile("(<\\S*)(\\s*[#\\$]+[#\\$\\s]*)(\\S*>)"); | ||
private static Matcher matcher = pattern.matcher(""); | ||
|
||
|
||
public static void cleanFile(File dumpFile) throws IOException { | ||
// the xml for windowHierarchy is all on one line. Adding newlines and rewriting to a file is probably just as | ||
// inefficient as reading the whole file into memory for when we cleanse it | ||
|
||
BufferedReader reader = new BufferedReader(new FileReader(dumpFile)); | ||
String line, wholeFile = ""; | ||
while ((line = reader.readLine()) != null) { | ||
line = cleanLine(line); | ||
wholeFile = wholeFile + line; | ||
} | ||
reader.close(); | ||
|
||
BufferedWriter writer = new BufferedWriter(new FileWriter(dumpFile)); | ||
writer.write(wholeFile); | ||
writer.close(); | ||
|
||
} | ||
|
||
public static String cleanLine(String line) { | ||
|
||
matcher.reset(line); | ||
return matcher.replaceAll("$1.$3"); | ||
} | ||
|
||
} |
Oops, something went wrong.