2016-05-20 7 views
1

yandex HtmlElementsフレームワークを試して、いくつかの同様のブロックを含むページを構築することにしました。意図は、すべてのメソッドを持つ別のクラスの単一ブロックを記述し、メインページのそれらのリストを反復することでした。同様のHtmlElementsブロックをページ内にインクルードして繰り返します。

セクションクラス

@FindBy(xpath = ".//div[@class='score-section']") 
public class Section extends HtmlElement { 

     @Timeout(10) 
     @FindBy(xpath = ".//div[@class='account-title']") 
     private WebElement accountTitle; 

     public void printValues() { 
      System.out.println(accountTitle.getText()); 
     } 

Pageクラス

public class MainPage extends BasePage { 
public MainPage(WebDriver driver) { 
    super(driver); 
    PageFactory.initElements(new HtmlElementDecorator(new HtmlElementLocatorFactory(driver)), this); 
    } 

List<Section> sections; 

public void iterateOverSections() { 
    for (Section section : sections) { 
     section.printValues(); 
    } 
} 

は、しかし、私はaccountTitleためにはNoSuchElementExceptionを取得

https://github.com/yandex-qatools/htmlelementsの例に続いて、私は次のよう作られました。

同様のブロックからページを構築することはできますか?

答えて

1

あなたのコードに問題は見られません。テストするhtmlページを表示できますか?

+0

実際、すべてが機能します。問題は、私がテストのために選んだ特定のWeb要素です。私はちょうど別の要素を使って、それが見つかった。 –