从 @Find 中使用的 WebElement 获取 By.XPath(how=How.XPATH, using=”//a[.=“Test”]”)
出于调试和报告目的,我想从 WebElement 获取 @Find 的使用部分,这可能吗?在调试中,我可以进入 WebElement 并通过其 LocatorHandle 查看其 By.XPATH,因此必须有一种方法可以在代码期间获取它?! 我不能使用 GetAttribute,因为我假设该元素不存在,否则无需在报告中提及它。
为了可视化;)
@FindBy(how = How.XPATH, using = "//a[.='Test']")
private static WebElement btnTest;
public static String GetOrgXpath(WebElement e)
{
return getByXPath(e); // should return "//a[.='Test']"
}
否则我也接受覆盖 WebElement 并添加一个公共字符串来存储其 xpath(如果可能的话)。我的 Java KungFoo 很弱,所以不知道如何覆盖接口:)
感谢您的帮助
For debugging and reporting purposes, I would like to get the using-part of @Find from a WebElement is this possible? In debug I can go into the WebElement and see its By.XPATH via it's LocatorHandle, so there must be a way to get it during code-time?!
I cannot ofc use the GetAttribute, because I assume the element won't exist, otherwise no need to mention it in the report.
For visualization ;)
@FindBy(how = How.XPATH, using = "//a[.='Test']")
private static WebElement btnTest;
public static String GetOrgXpath(WebElement e)
{
return getByXPath(e); // should return "//a[.='Test']"
}
otherwise I would also accept to override WebElement and add a public string to store its xpath, if thats even possible. My Java KungFoo is weak, so dunno how to overwrite Interfaces :)
Thanks for your help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论