My code is running too quickly and waits for URL verification and elements are not helping. These are the waits I have tried
wait.Until(ExpectedConditions.ElementToBeClickable(activationCodePage.ConfirmButton()));
wait.Until(e => e.Url.Contains("verify/activation-code"));
I have even tried a recommendation from a previous stack
But the only thing that seems to work is a Thread.sleep() for 10 seconds and I don't / can't use that for my tests.
Here is the code
verifyEmailPage.ConfirmDepartmentEmailButton().SendKeys(deptEmail);
verifyEmailPage.VerifyEmailPageButton().Click();
//This is where I run into issues, the page and requests haven't completely finished loadingby the
//Time I begin to call my task, this is where I tried both waits, the wait from the previous Thread
//IWait<IWebDriver> wait = new OpenQA.Selenium.Support.UI.WebDriverWait(driver,TimeSpan.FromSeconds(30.00));
//wait.Until(driver1 => ((IJavaScriptExecutor)driver).ExecuteScript("return document.readyState").Equals("complete"));
//and none of these have seemed to have work only Thread.Sleep(10000)
var activationCode = await ActivationCodeService.GetLatestActivationCodeByEmailAsync(deptEmail);
var activationCodePage = new VerifyActivationCodePage(driver);
activationCodePage.ActivationCodeInput().SendKeys(activationCode.Code);
Here is the code for
GetLatestActivationCodeByEmailAsync()
public async Task<ActivationCode> GetLatestActivationCodeByEmailAsync(string email)
{
using (var connection = Connect())
{
var result = await connection
.QueryAsync<ActivationCode>("[qa].[Get_ActivationCodeByEmail]", new { Email = email },
commandTimeout: 120, commandType: CommandType.StoredProcedure);
return result.SingleOrDefault();
}
}
I keep getting an error of
System.NullReferenceException: Object reference not set to an instance of an object.
on my line
activationCodePage.ActivationCodeInput().SendKeys(activationCode.Code);
because, the Stored procedure pulled Null values, due to it being too fast. but when I step through it or add the thread sleep, it's enough time to get the required data from the database.
Any help would be greatly appreciated!