Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Commit 0c808c0b authored by Catalin Comanici's avatar Catalin Comanici
Browse files

minor fixes

parent 7337c71b
No related branches found
No related tags found
No related merge requests found
......@@ -79,7 +79,7 @@
<webdriver.chrome.driver>${chrome.driver.path}</webdriver.chrome.driver>
<webdriver.gecko.driver>chromedriver.exe</webdriver.gecko.driver>
<reports.folder>./target/</reports.folder>
<data.folder>.\src\main\resources\</data.folder>
<data.folder>./src/main/resources/</data.folder>
<testdata.file>testData.json</testdata.file>
<LONG_TIMEOUT>30</LONG_TIMEOUT>
<SHORT_TIMEOUT>5</SHORT_TIMEOUT>
......
......@@ -17,7 +17,7 @@ public class PageComponent {
protected WebDriver driver;
protected WebDriverWait wait;
protected Logger log = Logger.getLogger(this.getClass());
protected By loadingBar = By.className("mat-ripple-element");
protected By loadingBar = By.cssSelector(".container .bar");
public PageComponent(WebDriver driver) {
......@@ -41,8 +41,8 @@ public class PageComponent {
int maxTimeout = PROPERTIES.SHORT_UI_TIMEOUT * 1000;
int waitedSoFar = 0;
while ((null != element.getAttribute("disabled")) && (waitedSoFar < maxTimeout)) {
waitedSoFar += 300;
waitForXMillis(300);
waitedSoFar += 100;
waitForXMillis(100);
}
}
......@@ -50,63 +50,26 @@ public class PageComponent {
int maxTimeout = PROPERTIES.SHORT_UI_TIMEOUT * 1000;
int waitedSoFar = 0;
while ((null == element.getAttribute("disabled")) && (waitedSoFar < maxTimeout)) {
waitedSoFar += 300;
waitForXMillis(300);
waitedSoFar += 100;
waitForXMillis(100);
}
}
public void waitForElementToBeGone(WebElement element) {
WebDriverWait myWait = new WebDriverWait(driver, 1);
try {
myWait.until(ExpectedConditions.visibilityOf(element));
myWait.until(ExpectedConditions.invisibilityOf(element));
} catch (Exception e) {
return;
}
int waitTime = PROPERTIES.SHORT_UI_TIMEOUT * 1000;
while (waitTime > 0) {
try {
if (!element.isDisplayed()) {
return;
}
} catch (Exception e) {
return;
}
waitForXMillis(500);
waitTime = waitTime - 500;
}
// int maxTimeout = 1000;
// int waitedSoFar = 0;
//
// try {
// while ((null != element.getText()) && (waitedSoFar < maxTimeout)) {
// waitedSoFar += 100;
// waitForXMillis(100);
// }
// } catch (Exception e) {
// return;
// }
waitForXMillis(500);
}
public void waitForElementToBeGone(By locator) {
WebDriverWait myWait = new WebDriverWait(driver, PROPERTIES.SHORT_UI_TIMEOUT);
try {
myWait.until(ExpectedConditions.visibilityOfElementLocated(locator));
} catch (Exception e) {
return;
}
int waitTime = PROPERTIES.SHORT_UI_TIMEOUT * 1000;
while (waitTime > 0) {
boolean displayed = true;
try {
displayed = driver.findElement(locator).isDisplayed();
} catch (Exception e) {
return;
}
if (!displayed) {
return;
}
waitForXMillis(500);
waitTime = waitTime - 500;
}
}
public void waitForNumberOfWindowsToBe(int noOfWindows) {
try {
......@@ -163,12 +126,13 @@ public class PageComponent {
public void waitForElementToBe(WebElement element) {
wait.until(new ExpectedCondition<Boolean>() {
@Override
public Boolean apply(WebDriver driver) {
return element.getLocation() != null;
}
});
wait.until(ExpectedConditions.visibilityOf(element));
// wait.until(new ExpectedCondition<Boolean>() {
// @Override
// public Boolean apply(WebDriver driver) {
// return element.getLocation() != null;
// }
// });
}
......@@ -221,12 +185,23 @@ public class PageComponent {
}
public void waitForRowsToLoad() {
log.info("waiting for rows to load");
try {
waitForElementToBeGone(loadingBar);
waitForXMillis(100);
int bars = 1;
int waits = 0;
while (bars > 0 && waits < 30) {
Object tmp = ((JavascriptExecutor) driver).executeScript("return document.querySelectorAll('.container .bar').length;");
bars = Integer.valueOf(tmp.toString());
waits++;
waitForXMillis(200);
}
log.debug("waited for rows to load for ms = 200*" + waits);
waitForXMillis(200);
} catch (Exception e) {
}
waitForXMillis(500);
}
......
......@@ -2,6 +2,7 @@ package utils;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import java.util.concurrent.TimeUnit;
......@@ -21,15 +22,24 @@ public class DriverManager {
// }
public static WebDriver getDriver() {
WebDriver driver = new ChromeDriver();
driver.manage().timeouts().implicitlyWait(2, TimeUnit.SECONDS);
driver.manage().timeouts().pageLoadTimeout(20, TimeUnit.SECONDS);
driver.manage().timeouts().setScriptTimeout(10, TimeUnit.SECONDS);
ChromeOptions options = new ChromeOptions();
options.setHeadless(Boolean.valueOf(PROPERTIES.HEADLESS));
options.addArguments("--disable-dev-shm-usage"); // overcome limited resource problems
options.addArguments("--no-sandbox"); // Bypass OS security model
options.addArguments("--disable-dev-shm-usage"); // overcome limited resource problems
options.addArguments("--window-size=1920,1080");
WebDriver driver = new ChromeDriver(options);
driver.manage().timeouts().implicitlyWait(1, TimeUnit.SECONDS);
driver.manage().window().maximize();
return driver;
}
return driver;
}
}
......@@ -6,7 +6,9 @@ public class PROPERTIES {
public static final String UI_BASE_URL = System.getProperty("UI_BASE_URL");
public static final int SHORT_UI_TIMEOUT = 5;
public static final int TIMEOUT = Integer.valueOf(System.getProperty("SHORT_TIMEOUT"));
public static final int LONG_WAIT = Integer.valueOf(System.getProperty("LONG_TIMEOUT"));
public static final String StringHEADLESS = System.getProperty("HEADLESS");
public static final String HEADLESS = "false";
public static final String REPORTS_FOLDER = System.getProperty("reports.folder");
public static final String TESTDATAFILE = System.getProperty("data.folder") + System.getProperty("testdata.file");
......
......@@ -20,7 +20,7 @@ public class TestDataProvider {
content = new String(Files.readAllBytes(Paths.get(PROPERTIES.TESTDATAFILE)));
testData = new JSONObject(content);
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("Error reading test data file: " + PROPERTIES.TESTDATAFILE);
}
}
......
......@@ -31,8 +31,6 @@ public class BaseTest {
protected Logger logger = Logger.getLogger(this.getClass());
@BeforeSuite(alwaysRun = true)
/*Starts the browser and navigates to the homepage. This happens once before the test
suite and the browser window is reused for all tests in suite*/
public void beforeSuite() {
logger.info("Creating necessary data !!!!");
createDomains();
......@@ -42,7 +40,7 @@ public class BaseTest {
@AfterSuite(alwaysRun = true)
/*After the test suite is done we close the browser*/
/*After the test suite is done, we close the browser*/
public void afterSuite() {
logger.info("Deleting created data!!!");
......
......@@ -38,7 +38,7 @@ public class PropertiesPgTest extends BaseTest{
}
/*@Test(description = "PROP-0")*/
@Test(enabled = false)
@Test(description = "PROP-0", enabled = false)
public void verifyParticipantschemeMandatoryProperty(){
SoftAssert soft = new SoftAssert();
......@@ -48,7 +48,7 @@ public class PropertiesPgTest extends BaseTest{
propertiesPage.propertySearch(property);
soft.assertTrue(propertiesPage.grid().rowContainPropertyName(property),"The row does not contain the searching property");
PropertyRowInfo newRow0 = propertiesPage.grid().getRows().get(0);
System.out.println("newRow0.getPropertyvalue() "+newRow0.getPropertyvalue());
if(newRow0.getPropertyvalue().equals("true"))
{
propertiesPage.grid().selectRow(0);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment