- 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
|
||||
|
||||
@@ -15,6 +15,7 @@ namespace AiQ_GUI
|
||||
|
||||
string SoakLogFile = $"SoakLog_{CamInfo.Serial}_{CamInfo.Model}.log";
|
||||
ChromeDriver driver = null;
|
||||
MainForm.Instance.AddToActionsList($"Soak test started for {CamInfo.Serial} ({CamInfo.Model}) at {CamInfo.IP}", Level.DEBUG);
|
||||
|
||||
try
|
||||
{
|
||||
@@ -24,18 +25,22 @@ namespace AiQ_GUI
|
||||
|
||||
// Keep retrying until connected or cancelled
|
||||
bool connected = false;
|
||||
int attemptCount = 0;
|
||||
while (!connected && !token.IsCancellationRequested)
|
||||
{
|
||||
try
|
||||
{
|
||||
attemptCount++;
|
||||
// Attempt initial connection and navigation to setup tab
|
||||
Selenium.GoToUrl($"http://{CamInfo.IP}", driver);
|
||||
Selenium.SwitchUser(driver);
|
||||
Selenium.ClickElementByID("tabSetup", driver);
|
||||
MainForm.Instance.AddToActionsList($"Successfully connected to {CamInfo.IP} on attempt {attemptCount}", Level.DEBUG);
|
||||
connected = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MainForm.Instance.AddToActionsList($"Connection attempt {attemptCount} failed for {CamInfo.IP}: {ex.Message}", Level.DEBUG);
|
||||
SoakError($"Initial connection failed: {ex.Message}", SoakLogFile, CamInfo.CheckBox);
|
||||
MainForm.Instance.AddToActionsList($"[{CamInfo.IP}] Initial connection failed:{ex.Message}", Level.ERROR);
|
||||
|
||||
@@ -52,20 +57,24 @@ namespace AiQ_GUI
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MainForm.Instance.AddToActionsList($"Failed to get element IDs from {CamInfo.IP}: {ex.Message}", Level.DEBUG);
|
||||
SoakError($"Failed to get element IDs: {ex.Message}", SoakLogFile, CamInfo.CheckBox);
|
||||
return;
|
||||
}
|
||||
|
||||
int lastHour = DateTime.Now.Hour;
|
||||
int loopCount = 0;
|
||||
|
||||
while (!token.IsCancellationRequested)
|
||||
{
|
||||
try
|
||||
{
|
||||
loopCount++;
|
||||
string TheString = "Selenium string: " + driver.Manage().Window.Size; // Fails out if Window doesn't exist.
|
||||
}
|
||||
catch
|
||||
{
|
||||
MainForm.Instance.AddToActionsList($"Driver window lost, cancelling soak for {CamInfo.Serial}", Level.DEBUG);
|
||||
CTS.Cancel();
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user