Selenium Java Webdriver:将字符串添加到Xpath

我有一段Java,我想一个语句中添加一个String:

@and ("^I want to change fieldnumber \"([^\"]*)\" , remove whats inside and add the following text: \"([^\"]*)\"$") public void testscenario12345(String number, String text) throws Throwable { driver.findElement(By.xpath("//*[contains(@name,'template:view::item:view:1:item:')]")).clear(); driver.findElement(By.xpath("//*[contains(@name,'template:view::item:view:1:item:')]")).sendKeys(text); 

如何在上面的代码中添加数字字符串? 为了澄清,如果我在黄瓜中插入“4”,我希望驱动程序通过Xpath找到元素,其中@name包含模板:view:4:item:view:1:item:

关于什么

 driver.findElement(By.xpath("//*[contains(@name,\"template:view:" + number+ ":item:view:1:item:\")]")).clear(); 

你可能需要将数字设为const,这意味着:

 public void testscenario12345(final String number, String text) throws Throwable {