Skip to content

Commit

Permalink
Commenting up some experimental code
Browse files Browse the repository at this point in the history
  • Loading branch information
matusmacik committed Jun 26, 2018
1 parent 44f248b commit dfbee32
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 51 deletions.
Expand Up @@ -4,14 +4,6 @@
import com.evolveum.midpoint.schrodinger.component.LoggedUser;
import com.evolveum.midpoint.schrodinger.page.LoginPage;
import org.apache.commons.lang3.Validate;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.TimeoutException;
import org.openqa.selenium.support.ui.FluentWait;
import org.openqa.selenium.support.ui.Wait;

import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static java.util.concurrent.TimeUnit.SECONDS;

/**
* Created by Viliam Repan (lazyman).
*/
Expand All @@ -33,7 +25,7 @@ public MidPoint(EnvironmentConfiguration environment) {

private void init() {
environment.validate();
System.setProperty("webdriver.chrome.driver", "C:\\Users\\matus\\chromedriver\\chromedriver.exe"); // TODO workaround, find proper way how to resolve
//System.setProperty("webdriver.chrome.driver", "C:\\Users\\matus\\chromedriver\\chromedriver.exe"); // TODO workaround, find proper way how to resolve
System.setProperty("selenide.browser", environment.getDriver().name().toLowerCase());
System.setProperty("selenide.baseUrl", environment.getBaseUrl());

Expand All @@ -44,15 +36,15 @@ public LoginPage login() {
return new LoginPage();
}

public static FluentWait waitWithIgnoreMissingElement() {

FluentWait wait = new FluentWait(environment.getDriver())
.withTimeout(TIMEOUT_MEDIUM, MILLISECONDS)
.pollingEvery(100, MILLISECONDS)
.ignoring(NoSuchElementException.class).ignoring(org.openqa.selenium.TimeoutException.class);

return wait;
}
// public static FluentWait waitWithIgnoreMissingElement() {
//
// FluentWait wait = new FluentWait(environment.getDriver())
// .withTimeout(TIMEOUT_MEDIUM, MILLISECONDS)
// .pollingEvery(100, MILLISECONDS)
// .ignoring(NoSuchElementException.class).ignoring(org.openqa.selenium.TimeoutException.class);
//
// return wait;
// }


public MidPoint logout() {
Expand Down
Expand Up @@ -17,29 +17,17 @@
package com.evolveum.midpoint.schrodinger.component.common.table;

import com.codeborne.selenide.Condition;
import com.codeborne.selenide.Selenide;
import com.codeborne.selenide.SelenideElement;
import com.evolveum.midpoint.schrodinger.MidPoint;
import com.evolveum.midpoint.schrodinger.component.Component;
import com.evolveum.midpoint.schrodinger.component.common.ConfirmationModal;
import com.evolveum.midpoint.schrodinger.component.common.Paging;
import com.evolveum.midpoint.schrodinger.component.common.Search;
import com.evolveum.midpoint.schrodinger.util.Schrodinger;
import com.google.common.base.Function;
import com.google.common.base.Predicate;
import org.openqa.selenium.By;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.TimeoutException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.support.ui.FluentWait;
import org.openqa.selenium.support.ui.Wait;

import javax.annotation.Nullable;
import java.util.concurrent.TimeUnit;


import static com.codeborne.selenide.Selenide.$;
import static com.codeborne.selenide.Selenide.Wait;

/**
* Created by Viliam Repan (lazyman).
Expand Down Expand Up @@ -76,29 +64,18 @@ public boolean currentTableContains(String name) {
// TODO Catching the exception in such way might be a problem, find solution with wait+pooling interval


FluentWait wait = MidPoint.waitWithIgnoreMissingElement();
Boolean isPresent = (Boolean) wait.until(new Function() {
@Nullable
@Override
public Boolean apply(@Nullable Object o) {
// FluentWait wait = MidPoint.waitWithIgnoreMissingElement();
// Boolean isPresent = (Boolean) wait.until(new Function() {
// @Nullable
// @Override
// public Boolean apply(@Nullable Object o) {
//
// return $(Schrodinger.byElementValue("Span", name)).is(Condition.visible);
// }
// });

return $(Schrodinger.byElementValue("Span", name)).is(Condition.visible);
}
});

return isPresent; //$(Schrodinger.byElementValue("Span", name)).waitUntil(Condition.visible, MidPoint.TIMEOUT_DEFAULT).is(Condition.visible);
return $(Schrodinger.byElementValue("Span", name)).is(Condition.visible);

}
// private boolean isDisplayed(SelenideElement e) {
// try {
// Predicate<WebDriver> isAppear = condition -> e.is(Condition.appears);
// Selenide.Wait()
// .withTimeout(MidPoint.TIMEOUT_DEFAULT, TimeUnit.SECONDS)
// .until(isAppear,Boolean.class);
// return true;
// } catch (TimeoutException th) {
// return false;
// }
// }

}

0 comments on commit dfbee32

Please sign in to comment.