我有一个函数,它接受一个By元素,By by By.xpath("xpathString").在我的方法中,我使用以下语句来查找另一个WebElement
findElement(by).findElements(By.xpath(anotherXPathString))
Run Code Online (Sandbox Code Playgroud)
有没有人知道一种操纵第一种方法的方法,所以我可以将它们组合起来,这样我就可以使用一个findElement函数?我查看了Selenium By类页面,它无法将By转换为String或组合到不同的By元素.我的目标是让它看起来像
By newby = (however we will combine the two by statements);
findElements(newby);
Run Code Online (Sandbox Code Playgroud)
要么
String newXPath = (however we convert the by to a string) + anotherXPathString;
findElements(By.xpath(newXPath));
Run Code Online (Sandbox Code Playgroud)
你知道ByChained课吗?
您可以通过ByChained使用链接汇总.
请参阅:javadoc(http://selenium.googlecode.com/svn/trunk/docs/api/java/org/openqa/selenium/support/pagefactory/ByChained.html)
希望能帮助到你.
| 归档时间: |
|
| 查看次数: |
2530 次 |
| 最近记录: |