How can I access the variable code_works when it gets updated from the try/catch? I have Lenovo.code_works placed on a button event, but it never updates, it stays at the initialized string "Waiting to Start Proccess", when I try to call the variable from the try/catch it says it isn't found. How would I go about fixing this?
public class Lenovo
{
//Some Variables
public static bool isTrue = true;
public static string idWarranty;
public static string code_works = "Waiting to Start Process";
public static void LenovoMonitor()
{
while (isTrue == true)
{
idWarranty = "u93302";
Driver.Navigate().GoToUrl("https://pcsupport.lenovo.com/us/en/products/monitors-and-projectors/lcd-monitors/lenovo-y44w-10/65ea/65earac1us/" + idWarranty + "/warranty");
//Find Element
try
{
IWebElement inputText = Driver.FindElement(By.XPath("/html/body/div[2]/section[2]/div[2]/div/div[2]/div/div[1]/div/div/div[2]/ul/li[2]/span"));
Console.WriteLine(idWarranty + " Works!");
code_works = idWarranty + " Works!";
} catch
{
Console.WriteLine("Invalid Code // No Warranty");
}