69 lines
1.8 KiB
Java
69 lines
1.8 KiB
Java
package PageHelpers;
|
|
|
|
import Pages.AlbumPage;
|
|
|
|
import java.util.logging.Logger;
|
|
|
|
import static java.util.logging.Level.INFO;
|
|
import static java.util.logging.Level.WARNING;
|
|
|
|
public class AlbumPageHelper {
|
|
private static java.util.logging.Logger log = Logger.getLogger(SearchResultsPageHelper.class.getName());
|
|
private AlbumPage page;
|
|
public AlbumPageHelper(AlbumPage page){
|
|
this.page = page;
|
|
}
|
|
|
|
public boolean containsPreview(String preview) {
|
|
boolean containsPreview = false;
|
|
for (int i = 0; i < page.getImagesCount(); i++) {
|
|
String previewCur = page.getImageName(i);
|
|
|
|
if(preview.equals(previewCur)) {
|
|
containsPreview = true;
|
|
}
|
|
}
|
|
|
|
return containsPreview;
|
|
}
|
|
|
|
public boolean isSelectedPhoto(int elementNumber) throws InterruptedException {
|
|
|
|
int timeout = 10;
|
|
boolean isSelected = false;
|
|
for(int i=0;i<timeout;i++){
|
|
page.clickPhotoPopup();
|
|
isSelected = page.isSelectedPhoto(elementNumber);
|
|
|
|
if(isSelected) {
|
|
log.logp(INFO, getClass().getName(), "pagination", "time: " + i*200);
|
|
break;
|
|
}
|
|
Thread.sleep(200);
|
|
}
|
|
return isSelected;
|
|
}
|
|
private int tryLimit = 10;
|
|
public void clickPhotoLink(int elementNumber) {
|
|
|
|
boolean breakIt = true;
|
|
int attempt =0;
|
|
while (true&&attempt<tryLimit) {
|
|
attempt++;
|
|
breakIt = true;
|
|
try {
|
|
page.clickPhotoLink(elementNumber);
|
|
} catch (Exception e) {
|
|
log.logp(WARNING, getClass().getName(), "clickPhotoLink","Exception in clickPhotoLink method");
|
|
|
|
breakIt = false;
|
|
|
|
}
|
|
if (breakIt) {
|
|
break;
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|