强textI试图处理使用pagefactory POM网表,但其引发的错误
如果我直接但在其他方面尽量n要粘贴的XPath它不工作
@FindBy (xpath = "//table[@id='userTable']/tbody/tr[")
WebElement before_xpath;
@FindBy (xpath = "]/td[2]")
WebElement after_xpath;
@FindBy (xpath = "//table[@id='userTable']/tbody/tr")
List<WebElement> namelist;
//Intialising PageObjects
public users_page() {
PageFactory.initElements(driver, this);
}
//Actions
public void userlist(String nm, String un, String pw, String cpw, String hub) {
List<WebElement> row =namelist;
int row_count = row.size();
System.out.println("Total no of rows " +row_count);
for(int i=1;i<row_count;i++) {
WebElement actual_xpath = before_xpath +i +actual_xpath;
System.out.println("Total " +actual_xpath);
}
}}
它是投掷误差上WebElement actual_xpath = before_xpath + 1 + actual_xpath ;.
其示出了操作员+是未定义的参数类型(一个或多个)WebElement,INT
所以我怎么能处理这
WebElement不处理,WebElement本身的级联。这里before_xpath,after_xpath是WebElement本身。
如果你想concate的东西,你在找什么(WebElement实际的XPath =前的XPath + IN + after_xpath)
应该有before_xpath的字符串数据类型,我和after_xpath。
所以,你的WebElement actual_xpath,将有正确的字符串来定位的Xpath。
此外,字符串的拼接应在XPath的正确格式。