Add highlight of the element we're trying to click

This commit is contained in:
2023-05-07 19:37:26 -05:00
parent 4fa4268051
commit ca622d3f10
2 changed files with 16 additions and 0 deletions

View File

@ -9,6 +9,7 @@ import org.apache.commons.io.FileUtils;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.openqa.selenium.By; import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.OutputType; import org.openqa.selenium.OutputType;
import org.openqa.selenium.StaleElementReferenceException; import org.openqa.selenium.StaleElementReferenceException;
import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebDriver;
@ -261,6 +262,17 @@ public class QSeleniumLib
/*******************************************************************************
**
*******************************************************************************/
public void highlightElement(WebElement element)
{
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("arguments[0].setAttribute('style', 'background: yellow; border: 3px solid red;');", element);
}
@FunctionalInterface @FunctionalInterface
public interface Code<T> public interface Code<T>
{ {

View File

@ -29,6 +29,7 @@ import com.kingsrook.qqq.materialdashboard.lib.javalin.CapturedContext;
import com.kingsrook.qqq.materialdashboard.lib.javalin.QSeleniumJavalin; import com.kingsrook.qqq.materialdashboard.lib.javalin.QSeleniumJavalin;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.openqa.selenium.By; import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import static com.kingsrook.qqq.materialdashboard.tests.QueryScreenTest.addQueryFilterInput; import static com.kingsrook.qqq.materialdashboard.tests.QueryScreenTest.addQueryFilterInput;
import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
@ -95,6 +96,9 @@ public class SavedFiltersTest extends QBaseSeleniumTest
////////////////////////////// //////////////////////////////
qSeleniumLib.takeScreenshotToFile("before-johnny-click"); qSeleniumLib.takeScreenshotToFile("before-johnny-click");
qSeleniumLib.waitForSeconds(1); // wait for the filters menu to fully disappear? if this doesn't work, try a different word to look for... qSeleniumLib.waitForSeconds(1); // wait for the filters menu to fully disappear? if this doesn't work, try a different word to look for...
WebElement webElement = qSeleniumLib.waitForSelectorContaining("DIV.MuiDataGrid-cell", "jdoe@kingsrook.com");
qSeleniumLib.highlightElement(webElement);
qSeleniumLib.takeScreenshotToFile("after-johnny-highlight");
qSeleniumLib.waitForSelectorContaining("DIV.MuiDataGrid-cell", "jdoe@kingsrook.com").click(); qSeleniumLib.waitForSelectorContaining("DIV.MuiDataGrid-cell", "jdoe@kingsrook.com").click();
qSeleniumLib.takeScreenshotToFile("after-johnny-click"); qSeleniumLib.takeScreenshotToFile("after-johnny-click");
qSeleniumLib.waitForSelectorContaining("H5", "Viewing Person: John Doe"); qSeleniumLib.waitForSelectorContaining("H5", "Viewing Person: John Doe");