mirror of
https://github.com/Kingsrook/qqq-frontend-material-dashboard.git
synced 2025-07-17 21:00: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:
14
pom.xml
14
pom.xml
@ -161,6 +161,20 @@
|
||||
<skipUpdateVersion>true</skipUpdateVersion>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<!-- Publish this project's test code as a jar -->
|
||||
<plugin>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>test-jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
@ -18,7 +18,7 @@ import org.openqa.selenium.chrome.ChromeOptions;
|
||||
*******************************************************************************/
|
||||
public class QBaseSeleniumTest
|
||||
{
|
||||
private static ChromeOptions chromeOptions;
|
||||
protected static ChromeOptions chromeOptions;
|
||||
|
||||
protected WebDriver driver;
|
||||
protected QSeleniumJavalin qSeleniumJavalin;
|
||||
@ -52,16 +52,30 @@ public class QBaseSeleniumTest
|
||||
**
|
||||
*******************************************************************************/
|
||||
@BeforeEach
|
||||
void beforeEach()
|
||||
public void beforeEach()
|
||||
{
|
||||
driver = new ChromeDriver(chromeOptions);
|
||||
driver.manage().window().setSize(new Dimension(1700, 1300));
|
||||
qSeleniumLib = new QSeleniumLib(driver);
|
||||
|
||||
if(useInternalJavalin())
|
||||
{
|
||||
qSeleniumJavalin = new QSeleniumJavalin();
|
||||
addJavalinRoutes(qSeleniumJavalin);
|
||||
qSeleniumJavalin.start();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** control if the test needs to start its own javalin server, or if we're running
|
||||
** in an environment where an external web server is being used.
|
||||
*******************************************************************************/
|
||||
protected boolean useInternalJavalin()
|
||||
{
|
||||
return (true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -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