实际上,我想获得一个用于页面对象模式的@FindBy
元素。@FindBy与Arquillian石墨烯
我有2个类,第一个是我的页面对象名为TestPage
和第二个名为PageSaveTest
(我的测试发生在那里,并调用TestPage
)。
我也尝试使用@FindBy
与xpath
和id
。
>>这是我TestPage
import java.util.List;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
public class TestPage {
// get autocomplete input
@FindBy(css = "input[id*='supplierOps_input']")
private WebElement autocompleteSupplierOps;
// getter
public WebElement getAutocompleteSupplierOps() {
return autocompleteSupplierOps;
}
}
>>这是我PageSaveTest
// How i "inject" my TestPage
@Page
TestPage testpage;
[...]
// My test
WebElement autocomplete = testpage.getAutocompleteSupplierOps();
String keys = "OP";
autocomplete.sendKeys(keys); // >>>>>>> Error throwed here !
List<WebElement> listSugg = testpage.getSuggestionsSupplierOps();
错误消息:
org.openqa.selenium.NoSuchElementException : Returned node was not an HTML element.
我的想法:
我觉得麻烦来自@FindBy
。但我使用this example来建立我的TestPage和我的测试和this one too。
问题:有人可以向我解释@FindBy
如何工作,并在我的例子中使用?关于石墨烯的文档很差。
编辑:
我已经修改我的吸气剂TestPage(上图),我试过id属性值的简单打印像
public WebElement getAutocompleteSupplierOps() {
System.out.println(">>>> "+autocompleteSupplierOps.getAttribute("id"));
return autocompleteSupplierOps;
}
但仍是同样的错误,@FindBy
被打开。
Another @FindBy spec在此问题中添加。
更新:
我已经固定我的选择,但确实存在具有像驾驶员会话probleme:
page2.getAutocompleteSupplierOps();
PAGE 1 ----------------------------------> PAGE 2
driver id:1 ----------------------------------> driver id:2
driver.showPageSource() is empty
return no element found <---------------------- driver.findElement() -> not found
我用三种不同的方式,在@FindBy
中, @Drone WebDriver
最后是什么@Lukas Fryc
建议给我。
我已经更新了我的OP。请看看。 – e1che 2013-05-03 09:47:33