2
如何在HtmlElement中創建自己的TypifiedElement?如何創建自己的TypifiedElement
我創建自己的CustomElement
public class YesNoRadio extends TypifiedElement {
protected YesNoRadio(WebElement wrappedElement) {
super(wrappedElement);
}
.... // some other methods here
}
並試圖使用它,但有例外,我的基本頁面上,同時初始化元素
PageFactory.initElements(new HtmlElementDecorator(driver), this);
我例外
ru.yandex.qatools.htmlelements.exceptions.HtmlElementsException: java.lang.NoSuchMethodException: No such accessible constructor on object: com.mycompany.testing.htmlelements.company.element.YesNoRadio
at ru.yandex.qatools.htmlelements.loader.decorator.HtmlElementFactory.createTypifiedElementInstance(HtmlElementFactory.java:51)
at ru.yandex.qatools.htmlelements.loader.decorator.HtmlElementDecorator.decorateTypifiedElement(HtmlElementDecorator.java:102)
at ru.yandex.qatools.htmlelements.loader.decorator.HtmlElementDecorator.decorate(HtmlElementDecorator.java:66)
at org.openqa.selenium.support.PageFactory.proxyFields(PageFactory.java:115)
at org.openqa.selenium.support.PageFactory.initElements(PageFactory.java:107)
at ru.yandex.qatools.htmlelements.loader.decorator.HtmlElementDecorator.decorateHtmlElement(HtmlElementDecorator.java:115)
at ru.yandex.qatools.htmlelements.loader.decorator.HtmlElementDecorator.decorate(HtmlElementDecorator.java:70)
at org.openqa.selenium.support.PageFactory.proxyFields(PageFactory.java:115)
at org.openqa.selenium.support.PageFactory.initElements(PageFactory.java:107)
at com.mycompany.testing.cds.PageBase.<init>(PageBase.java:46)
哪裏是我的錯以及如何糾正init我自己的TypifiedElement? 謝謝
所有作品,當我改變構造函數'public' – Funker 2014-12-27 22:47:06
謝謝你這個答案如預期,這是100%正確的 - 你應該在你的元素公共構造。 – artkoshelev 2014-12-29 09:26:22