mirror of
https://github.com/Kingsrook/qqq-frontend-material-dashboard.git
synced 2025-07-18 05:10:45 +00:00
Add maven-jar-plugin to publish qfmd's test classes in a jar (e.g., for inclusion in applications for selenium testing); Updates in library classes to support alternative usages
This commit is contained in:
@ -5,6 +5,7 @@ import java.io.File;
|
||||
import java.time.Duration;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
@ -96,6 +97,17 @@ public class QSeleniumLib
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Getter for BASE_URL
|
||||
**
|
||||
*******************************************************************************/
|
||||
public String getBaseUrl()
|
||||
{
|
||||
return BASE_URL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
@ -265,6 +277,31 @@ public class QSeleniumLib
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
public void waitForNumberOfWindowsToBe(int number)
|
||||
{
|
||||
LOG.debug("Waiting for number of windows (tabs) to be [" + number + "]");
|
||||
long start = System.currentTimeMillis();
|
||||
|
||||
do
|
||||
{
|
||||
if(driver.getWindowHandles().size() == number)
|
||||
{
|
||||
LOG.debug("Number of windows (tabs) is [" + number + "]");
|
||||
return;
|
||||
}
|
||||
|
||||
sleepABit();
|
||||
}
|
||||
while(start + (1000 * WAIT_SECONDS) > System.currentTimeMillis());
|
||||
|
||||
fail("Failed waiting for number of windows (tabs) to be [" + number + "] after [" + WAIT_SECONDS + "] seconds.");
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
@ -293,6 +330,53 @@ public class QSeleniumLib
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
public void switchToSecondaryTab()
|
||||
{
|
||||
String originalWindow = driver.getWindowHandle();
|
||||
|
||||
waitForNumberOfWindowsToBe(2);
|
||||
|
||||
Set<String> windowHandles = driver.getWindowHandles();
|
||||
for(String windowHandle : windowHandles)
|
||||
{
|
||||
if(!windowHandle.equals(originalWindow))
|
||||
{
|
||||
driver.switchTo().window(windowHandle);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
fail("Failed to find a window handle not equal to the original window handle. Original=[" + originalWindow + "]. All=[" + windowHandles + "]");
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
public void closeSecondaryTab()
|
||||
{
|
||||
String originalWindow = driver.getWindowHandle();
|
||||
driver.close();
|
||||
|
||||
Set<String> windowHandles = driver.getWindowHandles();
|
||||
for(String windowHandle : windowHandles)
|
||||
{
|
||||
if(!windowHandle.equals(originalWindow))
|
||||
{
|
||||
driver.switchTo().window(windowHandle);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
fail("Failed to find a window handle not equal to the original window handle. Original=[" + originalWindow + "]. All=[" + windowHandles + "]");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@FunctionalInterface
|
||||
public interface Code<T>
|
||||
{
|
||||
|
Reference in New Issue
Block a user