-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactorÐ: add the BaseModel and the @findby annotation
- Loading branch information
1 parent
3a64662
commit f4c57c1
Showing
7 changed files
with
76 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,22 @@ | ||
package practice.pineapple.model; | ||
|
||
import org.openqa.selenium.By; | ||
import org.openqa.selenium.WebDriver; | ||
import org.openqa.selenium.WebElement; | ||
import org.openqa.selenium.support.FindBy; | ||
import practice.pineapple.model.base.BasePage; | ||
|
||
public class FeedbackPage extends BasePage { | ||
|
||
private final By HEDER_REVIEWS = By.xpath("//h1"); | ||
@FindBy(xpath = "//h1") | ||
private WebElement heder1; | ||
|
||
public FeedbackPage(WebDriver driver) { | ||
|
||
super(driver); | ||
} | ||
|
||
public WebElement getHederReviews() { | ||
|
||
return getDriver().findElement(HEDER_REVIEWS); | ||
} | ||
|
||
public String getTextHederReviews() { | ||
|
||
return getText(getHederReviews()); | ||
return getText(heder1); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
src/test/java/practice/pineapple/model/base/BaseModel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package practice.pineapple.model.base; | ||
|
||
|
||
import org.openqa.selenium.WebDriver; | ||
import org.openqa.selenium.support.PageFactory; | ||
import org.openqa.selenium.support.ui.WebDriverWait; | ||
|
||
import java.time.Duration; | ||
|
||
abstract class BaseModel { | ||
|
||
private WebDriverWait wait2; | ||
private WebDriverWait wait5; | ||
private WebDriverWait wait10; | ||
|
||
private final WebDriver driver; | ||
|
||
public BaseModel(WebDriver driver) { | ||
this.driver = driver; | ||
PageFactory.initElements(driver, this); | ||
} | ||
|
||
protected WebDriver getDriver() { | ||
|
||
return driver; | ||
} | ||
|
||
public WebDriverWait getWait2() { | ||
if (wait2 == null) { | ||
wait2 = new WebDriverWait(getDriver(), Duration.ofSeconds(2)); | ||
} | ||
|
||
return wait2; | ||
} | ||
|
||
public WebDriverWait getWait5() { | ||
if (wait5 == null) { | ||
wait5 = new WebDriverWait(getDriver(), Duration.ofSeconds(5)); | ||
} | ||
|
||
return wait5; | ||
} | ||
|
||
public WebDriverWait getWait10() { | ||
if (wait10 == null) { | ||
wait10 = new WebDriverWait(getDriver(), Duration.ofSeconds(10)); | ||
} | ||
|
||
return wait10; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters