-
Notifications
You must be signed in to change notification settings - Fork 526
/
DashboardPage.java
64 lines (51 loc) · 1.81 KB
/
DashboardPage.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package io.blueocean.ath.pages.blue;
import io.blueocean.ath.BaseUrl;
import io.blueocean.ath.WaitUtil;
import org.apache.log4j.Logger;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.ui.Wait;
import javax.inject.Inject;
import javax.inject.Singleton;
@Singleton
public class DashboardPage {
private Logger logger = Logger.getLogger(DashboardPage.class);
@Inject @BaseUrl
String base;
@Inject
public DashboardPage(WebDriver driver) {
PageFactory.initElements(driver, this);
}
@FindBy(css = ".btn-new-pipeline")
public WebElement newPipelineButton;
@Inject
public WaitUtil wait;
@Inject
public WebDriver driver;
public void open() {
driver.get(base + "/blue/");
logger.info("Navigated to dashboard page");
}
public boolean isFavorite(String job) {
WebElement favorite = wait.until(driver -> {
WebElement tr = driver.findElement(By.xpath("//*[@data-pipeline=\"" + job + "\"]"));
return tr.findElement(By.cssSelector(".Checkbox.Favorite > label > input"));
});
return favorite.isSelected();
}
public void toggleFavorite(String job) {
WebElement favorite = wait.until(driver -> {
WebElement tr = driver.findElement(By.xpath("//*[@data-pipeline=\"" + job + "\"]"));
return tr.findElement(By.cssSelector(".Checkbox.Favorite > label"));
});
favorite.click();
if (isFavorite(job)) {
logger.info(String.format("Pipeline %s was favorited", job));
} else {
logger.info(String.format("Pipeline %s was unfavorited", job));
}
}
}