Last active
December 17, 2015 10:49
-
-
Save DominikDary/5597616 to your computer and use it in GitHub Desktop.
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
private Element findElementByXpath(String expr, String source) throws Exception { | |
String xml = JsonXmlUtil.toXml(new JSONObject(source)); | |
InputSource is = new InputSource(new StringReader(xml)); | |
XPath xPath = XPathFactory.newInstance().newXPath(); | |
XPathExpression xpathExpr = xPath.compile(expr); | |
return (Element) xpathExpr.evaluate(is, XPathConstants.NODE); | |
} |
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
{ | |
"ref": 2131165195, | |
"l10n": { | |
"matches": 0 | |
}, | |
"displayed": false, | |
"name": "id/visibleTextView", | |
"value": "Text is sometimes displayed", | |
"shown": false, | |
"label": "null", | |
"type": "android.widget.TextView", | |
"rect": { | |
"origin": { | |
"y": 307, | |
"x": 126 | |
}, | |
"size": { | |
"width": 175, | |
"height": 19 | |
} | |
} |
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
@Test | |
public void testShouldBeAbleToFindHiddenElementAndGetShownState() throws Exception { | |
Element textView = | |
findElementByXpath("//TextView[@name='id/visibleTextView']", driver.getPageSource()); | |
Assert.assertEquals(textView.getAttribute("shown"), "false"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment