2017-05-17 12 views
2

人。私はQAテスターです。私はSeleniumとJavaでオートメーションを学んでいます。なぜProfilePageクラスにジェネリックとコンストラクタを追加する必要があるのか​​理解できません。 だからPageオブジェクトクラスを作成することができます:「なぜ私はジェネリックを使用する必要があります「ProfilePage」をした後BasePageObjectを拡張」とその理由:そこで質問がある継承クラスのジェネリックとコンストラクタ

public class ProfilePage extends BasePageObject<ProfilePage> { 

private By editProfileButton = By.xpath("//button[@id='editProfile']"); 
private By advancededitProfileButton = By.xpath("//a[@class='dice-btn-link']"); 
private By profileContactNameText = By.xpath("//h1[@class='profile-contact-name']"); 

protected ProfilePage(WebDriver driver) { 
    super(driver); 
} 



public boolean isCorrectProfileLoaded(String correctProfileName){ 
    if (getText(profileContactNameText).equals(correctProfileName)){ 
    return true; 
}else 
    return false; 
    } 
} 

public class BasePageObject { 

protected WebDriver driver; 

protected void getPage(String url){ 
    driver.get(url); 

} 

private WebElement find(By element) { 
    return driver.findElement(element); 
} 

protected void type(String text, By element){ 
    find(element).sendKeys(text); 
} 
} 

今すぐプロフィールページ用のクラスを作成することができます作成する必要がありますprotected ProfilePage(WebDriver driver) { super(driver); }

ありがとうございます!

答えて

0

あなたの疑問は正当だと思います。セレンに関する限り、BasePageObjectは型パラメータを持たず、WebDriverパラメータを期待するコンストラクタもありません。

com.wikia.webdriver.pageobjectsfactory.pageobject以外のパッケージに別のBasePageObjectが存在する可能性はありますか?

「はい」の場合は、それが理由です。それは少し混乱します。
これ以外の場合、ProfilePageはコンパイルされません。

+0

はい!ありがとうございました!私は別のパッケージから同じ名前のクラスを開いたことを忘れてしまった! –

関連する問題