Last active
August 21, 2016 14:53
-
-
Save acdcjunior/e0ea8e8446e299dc4d46 to your computer and use it in GitHub Desktop.
What XPath version does a given Selenium WebDriver support?
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 String getXPathVersion(WebDriver context) { | |
try { | |
By.xpath("/nobody[@attr=lower-case('A')]").findElement(context); | |
return "2.0"; | |
} catch (Exception e) { | |
return "1.0"; | |
} | |
} |
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 String getXPathVersion(WebDriver context) { | |
try { | |
By.xpath("/nobody[@attr=('A'||'')]").findElement(context); | |
return "3.0"; | |
} catch (Exception e) { | |
try { | |
By.xpath("/nobody[@attr=lower-case('A')]").findElement(context); | |
return "2.0"; | |
} catch (Exception e) { | |
return "1.0"; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See: http://acdcjunior.github.io/xpath-2-3-version-selenium-webdriver-support.html