- AddToActionsList(Level.DEBUG) method has been changed to only visible when ChBXDevLog is true to avoid DEVS always having it on.
- added Level.DEBUG logs throughout selenium and soak test. Due to having prior issues with selenium and Soaktest - Bug fix in LDS.cs this stops a crossthread exception as its trying to write to AddToActionsList before it loads.
This commit is contained in:
@@ -11,11 +11,13 @@ namespace AiQ_GUI
|
||||
{
|
||||
try
|
||||
{
|
||||
MainForm.Instance.AddToActionsList($"Navigating to {url}", Level.DEBUG);
|
||||
driver.Navigate().GoToUrl(url);
|
||||
|
||||
// Wait until the document is fully loaded
|
||||
WebDriverWait wait = new(driver, TimeSpan.FromSeconds(10));
|
||||
wait.Until(d => ((IJavaScriptExecutor)d).ExecuteScript("return document.readyState").Equals("complete"));
|
||||
MainForm.Instance.AddToActionsList($"Page loaded successfully: {url}", Level.DEBUG);
|
||||
}
|
||||
catch (WebDriverTimeoutException)
|
||||
{
|
||||
@@ -26,6 +28,7 @@ namespace AiQ_GUI
|
||||
// Retrieves lates element ID for Shutter,iris, gain and IR
|
||||
public static ElementID GetElementIds(ChromeDriver driver)
|
||||
{
|
||||
MainForm.Instance.AddToActionsList($"Retrieving element IDs from page", Level.DEBUG);
|
||||
ElementID elementID = new()
|
||||
{
|
||||
modeId = GetLatestElementIdContaining("Mode_", driver),
|
||||
@@ -35,6 +38,7 @@ namespace AiQ_GUI
|
||||
irLevelId = GetLatestElementIdContaining("CameraControls_", driver),
|
||||
CamAct = GetLatestElementIdContaining("CameraActivity_", driver)
|
||||
};
|
||||
MainForm.Instance.AddToActionsList($"Element IDs retrieved: Mode={elementID.modeId}, Shutter={elementID.shutterId}, Iris={elementID.irisId}", Level.DEBUG);
|
||||
|
||||
return elementID;
|
||||
}
|
||||
@@ -70,6 +74,7 @@ namespace AiQ_GUI
|
||||
wait.Until(d => loginBtn.Displayed && loginBtn.Enabled);
|
||||
|
||||
loginBtn.Click();
|
||||
MainForm.Instance.AddToActionsList($"Login button clicked, waiting for authentication", Level.DEBUG);
|
||||
|
||||
MainForm.Instance.AddToActionsList($"Switched user and logged in.", Level.Success);
|
||||
}
|
||||
@@ -85,12 +90,15 @@ namespace AiQ_GUI
|
||||
{
|
||||
try
|
||||
{
|
||||
MainForm.Instance.AddToActionsList($"Attempting to click element: {elementID}", Level.DEBUG);
|
||||
WebDriverWait wait = new(driver, TimeSpan.FromSeconds(10));
|
||||
IWebElement element = wait.Until(driver => driver.FindElement(By.Id(elementID)));
|
||||
element.Click();
|
||||
MainForm.Instance.AddToActionsList($"Element clicked successfully: {elementID}", Level.DEBUG);
|
||||
}
|
||||
catch
|
||||
{
|
||||
MainForm.Instance.AddToActionsList($"Failed to click {elementID}, refreshing page and retrying...", Level.DEBUG);
|
||||
if (tryagain)
|
||||
{
|
||||
driver.Navigate().Refresh();
|
||||
@@ -108,6 +116,7 @@ namespace AiQ_GUI
|
||||
{
|
||||
try
|
||||
{
|
||||
MainForm.Instance.AddToActionsList($"Initializing ChromeDriver with temp profile...", Level.DEBUG);
|
||||
ChromeOptions options = new();
|
||||
options.AddArguments("--app=data:,",
|
||||
"--window-size=960,1040",
|
||||
@@ -121,6 +130,7 @@ namespace AiQ_GUI
|
||||
// Use a unique temporary profile to avoid conflicts
|
||||
string tempProfile = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
|
||||
options.AddArguments($"--user-data-dir={tempProfile}");
|
||||
MainForm.Instance.AddToActionsList($"Chrome temp profile: {tempProfile}", Level.DEBUG);
|
||||
|
||||
// manual driver path
|
||||
string driverPath = @"C:\ProgramData\MAV\AiQ_GUI";
|
||||
@@ -129,6 +139,7 @@ namespace AiQ_GUI
|
||||
|
||||
ChromeDriver driver = new(service, options);
|
||||
driver.Manage().Timeouts().PageLoad = TimeSpan.FromSeconds(5);
|
||||
MainForm.Instance.AddToActionsList($"ChromeDriver initialized successfully", Level.DEBUG);
|
||||
|
||||
return driver;
|
||||
}
|
||||
@@ -146,10 +157,14 @@ namespace AiQ_GUI
|
||||
IWebElement element = wait.Until(driver => driver.FindElement(By.Id(fullId)));
|
||||
|
||||
await Logging.LogMessage($"Changing dropdown {fullId} to value: {value}", SoakLogFile);
|
||||
MainForm.Instance.AddToActionsList($"Dropdown change: {fullId} -> {value}", Level.DEBUG);
|
||||
await Task.Delay(fullId.Contains("Mode_") ? 4000 : 200);
|
||||
|
||||
if (value == element.GetAttribute("value"))
|
||||
{
|
||||
MainForm.Instance.AddToActionsList($"Dropdown {fullId} already set to {value}, no change needed", Level.DEBUG);
|
||||
return; // No change needed setting is already correct
|
||||
}
|
||||
|
||||
SelectElement select = new(element);
|
||||
|
||||
@@ -157,7 +172,14 @@ namespace AiQ_GUI
|
||||
await Task.Delay(500); // Wait for the change to take effect
|
||||
|
||||
if (!await Checkflashline(driver, CamAct))
|
||||
{
|
||||
MainForm.Instance.AddToActionsList($"Flashline check failed after changing {fullId}", Level.DEBUG);
|
||||
Logging.LogWarningMessage("Bad flashline after changing: " + fullId, SoakLogFile);
|
||||
}
|
||||
else
|
||||
{
|
||||
MainForm.Instance.AddToActionsList($"Flashline OK after dropdown change", Level.DEBUG);
|
||||
}
|
||||
}
|
||||
|
||||
// Monitors the flashline element's color to determine success (green) or failure (red) of a camera
|
||||
|
||||
Reference in New Issue
Block a user