[英]@Findby using xpath with index
Can I use @Findby and pass certain values as parameter? 我可以使用@Findby并将某些值作为参数传递吗?
@FindBy("//div[contains(@class,'gallery_grid_image_caption gallery_grid_image_caption_padding')]"[$INDEX])
I know I can do this while using findElement. 我知道我可以在使用findElement时执行此操作。 Kindly let me know if there is a solution/work around.
如果有解决方案/解决方法,请告诉我。
What I want to do it is let's say there is a for loop and there is a list of elements in a page. 我想要做的是让我们说有一个for循环,页面中有一个元素列表。 Now let's say the only thing that is changing among these fields is the bit of the xpath.
现在让我们说在这些字段中唯一改变的是xpath的位。
//div/1
, //div/2
.... What I want to do is represent one element for all these elements and pass the ending values as parameter. //div/1
, //div/2
....我想要做的是为所有这些元素表示一个元素,并将结束值作为参数传递。
I believe what you are trying to do is something like this : 我相信你要做的是这样的:
@FindBy(xpath = "//div[contains(@class,'gallery_grid_image_caption gallery_grid_image_caption_padding')]")
public WebElement yourElement;
SO-9028757 should provide you more context. SO-9028757应该为您提供更多背景信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.